mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Allow on_raw_update to be used as a static decorator
This commit is contained in:
parent
345ac6e16a
commit
1fdc757f2a
@ -21,7 +21,7 @@ from ...ext import BaseClient
|
|||||||
|
|
||||||
|
|
||||||
class OnRawUpdate(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
|
"""Use this decorator to automatically register a function for handling
|
||||||
raw updates. This does the same thing as :meth:`add_handler` using the
|
raw updates. This does the same thing as :meth:`add_handler` using the
|
||||||
:class:`RawUpdateHandler`.
|
:class:`RawUpdateHandler`.
|
||||||
@ -32,7 +32,14 @@ class OnRawUpdate(BaseClient):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
self.add_handler(pyrogram.RawUpdateHandler(func), group)
|
handler = pyrogram.RawUpdateHandler(func)
|
||||||
return 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
|
return decorator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user