From 6fdb90e4a47d2a7187e195b1556edbde18686795 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 13 Oct 2018 10:54:13 +0200 Subject: [PATCH] Allow on_deleted_messages to be used as a static decorator --- .../client/methods/decorators/on_deleted_messages.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/methods/decorators/on_deleted_messages.py b/pyrogram/client/methods/decorators/on_deleted_messages.py index 3f603c41..e4b2bc97 100644 --- a/pyrogram/client/methods/decorators/on_deleted_messages.py +++ b/pyrogram/client/methods/decorators/on_deleted_messages.py @@ -17,6 +17,7 @@ # along with Pyrogram. If not, see . import pyrogram +from pyrogram.client.filters.filter import Filter from ...ext import BaseClient @@ -36,7 +37,14 @@ class OnDeletedMessages(BaseClient): """ def decorator(func): - self.add_handler(pyrogram.DeletedMessagesHandler(func, filters), group) - return func + handler = pyrogram.DeletedMessagesHandler(func, filters) + + if isinstance(self, Filter): + return pyrogram.DeletedMessagesHandler(func, self), group if filters is None else filters + + if self is not None: + self.add_handler(handler, group) + + return handler, group return decorator