mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
code duplication lessened
This commit is contained in:
parent
eb4d58bec1
commit
1b47e5cc62
@ -723,52 +723,34 @@ class TeleBot:
|
|||||||
|
|
||||||
def inline_handler(self, func):
|
def inline_handler(self, func):
|
||||||
def decorator(handler):
|
def decorator(handler):
|
||||||
self.add_inline_handler(handler, func)
|
handler_dict = self._build_handler_dict(handler, func=func)
|
||||||
|
self.add_inline_handler(handler_dict)
|
||||||
return handler
|
return handler
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
def add_inline_handler(self, handler, func):
|
def add_inline_handler(self, handler_dict):
|
||||||
filters = {'lambda': func}
|
|
||||||
|
|
||||||
handler_dict = {
|
|
||||||
'function': handler,
|
|
||||||
'filters': filters
|
|
||||||
}
|
|
||||||
|
|
||||||
self.inline_handlers.append(handler_dict)
|
self.inline_handlers.append(handler_dict)
|
||||||
|
|
||||||
def chosen_inline_handler(self, func):
|
def chosen_inline_handler(self, func):
|
||||||
def decorator(handler):
|
def decorator(handler):
|
||||||
self.add_chosen_inline_handler(handler, func)
|
handler_dict = self._build_handler_dict(handler, func=func)
|
||||||
|
self.add_chosen_inline_handler(handler_dict)
|
||||||
return handler
|
return handler
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
def add_chosen_inline_handler(self, handler, func):
|
def add_chosen_inline_handler(self, handler_dict):
|
||||||
filters = {'lambda': func}
|
|
||||||
|
|
||||||
handler_dict = {
|
|
||||||
'function': handler,
|
|
||||||
'filters': filters
|
|
||||||
}
|
|
||||||
|
|
||||||
self.chosen_inline_handlers.append(handler_dict)
|
self.chosen_inline_handlers.append(handler_dict)
|
||||||
|
|
||||||
def callback_query_handler(self, func):
|
def callback_query_handler(self, func):
|
||||||
def decorator(handler):
|
def decorator(handler):
|
||||||
self.add_callback_query_handler(handler, func)
|
handler_dict = self._build_handler_dict(handler, func=func)
|
||||||
|
self.add_callback_query_handler(handler_dict)
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
def add_callback_query_handler(self, handler, func):
|
def add_callback_query_handler(self, handler_dict):
|
||||||
filters = {'lambda': func}
|
|
||||||
|
|
||||||
handler_dict = {
|
|
||||||
'function': handler,
|
|
||||||
'filters': filters
|
|
||||||
}
|
|
||||||
|
|
||||||
self.callback_query_handlers.append(handler_dict)
|
self.callback_query_handlers.append(handler_dict)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -786,7 +768,7 @@ class TeleBot:
|
|||||||
return message.content_type == 'text' and re.search(filter_value, message.text)
|
return message.content_type == 'text' and re.search(filter_value, message.text)
|
||||||
if filter == 'commands':
|
if filter == 'commands':
|
||||||
return message.content_type == 'text' and util.extract_command(message.text) in filter_value
|
return message.content_type == 'text' and util.extract_command(message.text) in filter_value
|
||||||
if filter == 'lambda':
|
if filter == 'func':
|
||||||
return filter_value(message)
|
return filter_value(message)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user