Skip to content

Commit 54296a6

Browse files
committed
Allow on_disconnect to be used as a static decorator
1 parent 1fdc757 commit 54296a6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pyrogram/client/methods/decorators/on_disconnect.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ def on_disconnect(self):
2828
"""
2929

3030
def decorator(func):
31-
self.add_handler(pyrogram.DisconnectHandler(func))
32-
return func
31+
handler = pyrogram.DisconnectHandler(func)
32+
33+
if self is not None:
34+
self.add_handler(handler)
35+
36+
return handler
3337

3438
return decorator

0 commit comments

Comments
 (0)