2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-09-10 11:15:27 +00:00

Only keep MessageHandler

This commit is contained in:
Dan
2018-04-07 23:34:28 +02:00
parent 90a4e4c411
commit ee2d66b416
7 changed files with 11 additions and 107 deletions

View File

@@ -189,25 +189,12 @@ class Client:
self.dispatcher = Dispatcher(self, workers)
self.update_handler = None
def on(self, handler, group: int):
def on_message(self, group: int = 0):
def decorator(f):
self.add_handler(handler(f), group)
return f
self.add_handler(pyrogram.MessageHandler(f), group)
return decorator
def on_message(self, group: int = 0):
return self.on(pyrogram.MessageHandler, group)
def on_edited_message(self, group: int = 0):
return self.on(pyrogram.EditedMessageHandler, group)
def on_channel_post(self, group: int = 0):
return self.on(pyrogram.ChannelPostHandler, group)
def on_edited_channel_post(self, group: int = 0):
return self.on(pyrogram.EditedChannelPostHandler, group)
def add_handler(self, handler: Handler, group: int = 0):
self.dispatcher.add_handler(handler, group)