mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 20:14:51 +00:00
Allow decorators to be stacked
E.g:
app1.on_message(...)
app2.on_message(...)
app3.on_message(...)
def on_message(client, message):
...
This commit is contained in:
parent
fafa3b5131
commit
2e16499369
5 changed files with 15 additions and 0 deletions
|
|
@ -37,6 +37,9 @@ class OnCallbackQuery(BaseClient):
|
|||
"""
|
||||
|
||||
def decorator(func):
|
||||
if isinstance(func, tuple):
|
||||
func = func[0].callback
|
||||
|
||||
handler = pyrogram.CallbackQueryHandler(func, filters)
|
||||
|
||||
if isinstance(self, Filter):
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ class OnDeletedMessages(BaseClient):
|
|||
"""
|
||||
|
||||
def decorator(func):
|
||||
if isinstance(func, tuple):
|
||||
func = func[0].callback
|
||||
|
||||
handler = pyrogram.DeletedMessagesHandler(func, filters)
|
||||
|
||||
if isinstance(self, Filter):
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ class OnMessage(BaseClient):
|
|||
"""
|
||||
|
||||
def decorator(func):
|
||||
if isinstance(func, tuple):
|
||||
func = func[0].callback
|
||||
|
||||
handler = pyrogram.MessageHandler(func, filters)
|
||||
|
||||
if isinstance(self, Filter):
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ class OnRawUpdate(BaseClient):
|
|||
"""
|
||||
|
||||
def decorator(func):
|
||||
if isinstance(func, tuple):
|
||||
func = func[0].callback
|
||||
|
||||
handler = pyrogram.RawUpdateHandler(func)
|
||||
|
||||
if isinstance(self, int):
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ class OnUserStatus(BaseClient):
|
|||
"""
|
||||
|
||||
def decorator(func):
|
||||
if isinstance(func, tuple):
|
||||
func = func[0].callback
|
||||
|
||||
handler = pyrogram.UserStatusHandler(func, filters)
|
||||
|
||||
if isinstance(self, Filter):
|
||||
|
|
|
|||
Loading…
Reference in a new issue