mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 20:59:29 +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):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user