mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Move the check method into Handler superclass
This commit is contained in:
parent
f0d059da07
commit
429cfd0882
@ -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