Skip to content

Commit b423730

Browse files
authored
Fix on_disconnect decorator not working (pyrogram#1134)
* Fix on_disconnect decorator not working * Remove useless if else statment in on_raw_update
1 parent 035bbbb commit b423730

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

pyrogram/methods/decorators/on_disconnect.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def on_disconnect(self=None) -> Callable:
3232
def decorator(func: Callable) -> Callable:
3333
if isinstance(self, pyrogram.Client):
3434
self.add_handler(pyrogram.handlers.DisconnectHandler(func))
35+
else:
36+
if not hasattr(func, "handlers"):
37+
func.handlers = []
38+
39+
func.handlers.append((pyrogram.handlers.DisconnectHandler(func), 0))
3540

3641
return func
3742

pyrogram/methods/decorators/on_raw_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def decorator(func: Callable) -> Callable:
4646
func.handlers.append(
4747
(
4848
pyrogram.handlers.RawUpdateHandler(func),
49-
group if self is None else group
49+
group
5050
)
5151
)
5252

0 commit comments

Comments
 (0)