mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Merge branch 'raw-updates-swallowing' into develop
This commit is contained in:
commit
ccecbd6a50
@ -128,35 +128,35 @@ class Dispatcher:
|
|||||||
|
|
||||||
parser = self.update_parsers.get(type(update), None)
|
parser = self.update_parsers.get(type(update), None)
|
||||||
|
|
||||||
if parser is None:
|
parsed_update, handler_type = (
|
||||||
continue
|
parser(update, users, chats)
|
||||||
|
if parser is not None
|
||||||
parsed_update, handler_type = parser(update, users, chats)
|
else (None, type(None))
|
||||||
|
)
|
||||||
|
|
||||||
for group in self.groups.values():
|
for group in self.groups.values():
|
||||||
try:
|
for handler in group:
|
||||||
for handler in group:
|
args = None
|
||||||
args = None
|
|
||||||
|
|
||||||
if isinstance(handler, RawUpdateHandler):
|
if isinstance(handler, handler_type):
|
||||||
args = (update, users, chats)
|
if handler.check(parsed_update):
|
||||||
elif isinstance(handler, handler_type):
|
args = (parsed_update,)
|
||||||
if handler.check(parsed_update):
|
elif isinstance(handler, RawUpdateHandler):
|
||||||
args = (parsed_update,)
|
args = (update, users, chats)
|
||||||
|
|
||||||
if args is None:
|
if args is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
handler.callback(self.client, *args)
|
handler.callback(self.client, *args)
|
||||||
except StopIteration:
|
except pyrogram.StopPropagation:
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e, exc_info=True)
|
log.error(e, exc_info=True)
|
||||||
|
|
||||||
break
|
|
||||||
except StopIteration:
|
|
||||||
break
|
break
|
||||||
|
except pyrogram.StopPropagation:
|
||||||
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.error(e, exc_info=True)
|
log.error(e, exc_info=True)
|
||||||
|
|
||||||
|
@ -45,10 +45,3 @@ class CallbackQueryHandler(Handler):
|
|||||||
|
|
||||||
def __init__(self, callback: callable, filters=None):
|
def __init__(self, callback: callable, filters=None):
|
||||||
super().__init__(callback, filters)
|
super().__init__(callback, filters)
|
||||||
|
|
||||||
def check(self, callback_query):
|
|
||||||
return (
|
|
||||||
self.filters(callback_query)
|
|
||||||
if callable(self.filters)
|
|
||||||
else True
|
|
||||||
)
|
|
||||||
|
@ -48,8 +48,4 @@ class DeletedMessagesHandler(Handler):
|
|||||||
super().__init__(callback, filters)
|
super().__init__(callback, filters)
|
||||||
|
|
||||||
def check(self, messages):
|
def check(self, messages):
|
||||||
return (
|
return super().check(messages.messages[0])
|
||||||
self.filters(messages.messages[0])
|
|
||||||
if callable(self.filters)
|
|
||||||
else True
|
|
||||||
)
|
|
||||||
|
@ -21,3 +21,10 @@ class Handler:
|
|||||||
def __init__(self, callback: callable, filters=None):
|
def __init__(self, callback: callable, filters=None):
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.filters = filters
|
self.filters = filters
|
||||||
|
|
||||||
|
def check(self, update):
|
||||||
|
return (
|
||||||
|
self.filters(update)
|
||||||
|
if callable(self.filters)
|
||||||
|
else True
|
||||||
|
)
|
||||||
|
@ -46,10 +46,3 @@ class MessageHandler(Handler):
|
|||||||
|
|
||||||
def __init__(self, callback: callable, filters=None):
|
def __init__(self, callback: callable, filters=None):
|
||||||
super().__init__(callback, filters)
|
super().__init__(callback, filters)
|
||||||
|
|
||||||
def check(self, message):
|
|
||||||
return (
|
|
||||||
self.filters(message)
|
|
||||||
if callable(self.filters)
|
|
||||||
else True
|
|
||||||
)
|
|
||||||
|
@ -45,10 +45,3 @@ class UserStatusHandler(Handler):
|
|||||||
|
|
||||||
def __init__(self, callback: callable, filters=None):
|
def __init__(self, callback: callable, filters=None):
|
||||||
super().__init__(callback, filters)
|
super().__init__(callback, filters)
|
||||||
|
|
||||||
def check(self, user_status):
|
|
||||||
return (
|
|
||||||
self.filters(user_status)
|
|
||||||
if callable(self.filters)
|
|
||||||
else True
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user