Skip to content

Commit 2e16499

Browse files
committed
Allow decorators to be stacked
E.g: app1.on_message(...) app2.on_message(...) app3.on_message(...) def on_message(client, message): ...
1 parent fafa3b5 commit 2e16499

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

pyrogram/client/methods/decorators/on_callback_query.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def on_callback_query(self=None, filters=None, group: int = 0):
3737
"""
3838

3939
def decorator(func):
40+
if isinstance(func, tuple):
41+
func = func[0].callback
42+
4043
handler = pyrogram.CallbackQueryHandler(func, filters)
4144

4245
if isinstance(self, Filter):

pyrogram/client/methods/decorators/on_deleted_messages.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def on_deleted_messages(self=None, filters=None, group: int = 0):
3737
"""
3838

3939
def decorator(func):
40+
if isinstance(func, tuple):
41+
func = func[0].callback
42+
4043
handler = pyrogram.DeletedMessagesHandler(func, filters)
4144

4245
if isinstance(self, Filter):

pyrogram/client/methods/decorators/on_message.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def on_message(self=None, filters=None, group: int = 0):
3737
"""
3838

3939
def decorator(func):
40+
if isinstance(func, tuple):
41+
func = func[0].callback
42+
4043
handler = pyrogram.MessageHandler(func, filters)
4144

4245
if isinstance(self, Filter):

pyrogram/client/methods/decorators/on_raw_update.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ def on_raw_update(self=None, group: int = 0):
3232
"""
3333

3434
def decorator(func):
35+
if isinstance(func, tuple):
36+
func = func[0].callback
37+
3538
handler = pyrogram.RawUpdateHandler(func)
3639

3740
if isinstance(self, int):

pyrogram/client/methods/decorators/on_user_status.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def on_user_status(self=None, filters=None, group: int = 0):
3636
"""
3737

3838
def decorator(func):
39+
if isinstance(func, tuple):
40+
func = func[0].callback
41+
3942
handler = pyrogram.UserStatusHandler(func, filters)
4043

4144
if isinstance(self, Filter):

0 commit comments

Comments
 (0)