From 1fdc757f2afd30b1f30ee64dce345e34fca73f87 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 13 Oct 2018 10:45:48 +0200 Subject: [PATCH] Allow on_raw_update to be used as a static decorator --- pyrogram/client/methods/decorators/on_raw_update.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pyrogram/client/methods/decorators/on_raw_update.py b/pyrogram/client/methods/decorators/on_raw_update.py index 902d9854..7675a4f0 100644 --- a/pyrogram/client/methods/decorators/on_raw_update.py +++ b/pyrogram/client/methods/decorators/on_raw_update.py @@ -21,7 +21,7 @@ from ...ext import BaseClient class OnRawUpdate(BaseClient): - def on_raw_update(self, group: int = 0): + def on_raw_update(self=None, group: int = 0): """Use this decorator to automatically register a function for handling raw updates. This does the same thing as :meth:`add_handler` using the :class:`RawUpdateHandler`. @@ -32,7 +32,14 @@ class OnRawUpdate(BaseClient): """ def decorator(func): - self.add_handler(pyrogram.RawUpdateHandler(func), group) - return func + handler = pyrogram.RawUpdateHandler(func) + + if isinstance(self, int): + return handler, group if self is None else group + + if self is not None: + self.add_handler(handler, group) + + return handler, group return decorator