From 9165c7f591d4cfb8ba7e315e919a2f5bc64c3add Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 10 Apr 2018 14:54:39 +0200 Subject: [PATCH] Rework decorators impl --- pyrogram/client/client.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 179b11e2..6545e9a2 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -203,18 +203,19 @@ class Client: self.dispatcher = Dispatcher(self, workers) self.update_handler = None - def on(self, handler, group, filters=None): + def on_message(self, filters=None, group: int = 0): def decorator(func): - self.add_handler(handler(func, filters), group) + self.add_handler(pyrogram.MessageHandler(func, filters), group) return func return decorator - def on_message(self, filters=None, group: int = 0): - return self.on(pyrogram.MessageHandler, group, filters) - def on_raw_update(self, group: int = 0): - return self.on(pyrogram.RawUpdateHandler, group) + def decorator(func): + self.add_handler(pyrogram.RawUpdateHandler(func), group) + return func + + return decorator def add_handler(self, handler: Handler, group: int = 0): self.dispatcher.add_handler(handler, group)