2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 12:57:52 +00:00

Fix on_disconnect decorator not working (#1134)

* Fix on_disconnect decorator not working

* Remove useless if else statment in on_raw_update
This commit is contained in:
Sam 2022-11-13 21:18:42 +08:00 committed by GitHub
parent 035bbbb76e
commit b423730dcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -32,6 +32,11 @@ class OnDisconnect:
def decorator(func: Callable) -> Callable:
if isinstance(self, pyrogram.Client):
self.add_handler(pyrogram.handlers.DisconnectHandler(func))
else:
if not hasattr(func, "handlers"):
func.handlers = []
func.handlers.append((pyrogram.handlers.DisconnectHandler(func), 0))
return func

View File

@ -46,7 +46,7 @@ class OnRawUpdate:
func.handlers.append(
(
pyrogram.handlers.RawUpdateHandler(func),
group if self is None else group
group
)
)