From 54296a6fdaa9e28d4d9e06e8d446ee89c32a40b4 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 13 Oct 2018 10:47:39 +0200 Subject: [PATCH] Allow on_disconnect to be used as a static decorator --- pyrogram/client/methods/decorators/on_disconnect.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/methods/decorators/on_disconnect.py b/pyrogram/client/methods/decorators/on_disconnect.py index 4bc593e3..a639471b 100644 --- a/pyrogram/client/methods/decorators/on_disconnect.py +++ b/pyrogram/client/methods/decorators/on_disconnect.py @@ -28,7 +28,11 @@ class OnDisconnect(BaseClient): """ def decorator(func): - self.add_handler(pyrogram.DisconnectHandler(func)) - return func + handler = pyrogram.DisconnectHandler(func) + + if self is not None: + self.add_handler(handler) + + return handler return decorator