mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Filter clearance
1. Filter optimization: should not store empty filters 2. Filter order: chat_type, content, others 3. Default session timeout set to 600 instead of "forever". 4. Type
This commit is contained in:
parent
78fb69ded1
commit
f70b135359
@ -2425,7 +2425,9 @@ class TeleBot:
|
|||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
'function': handler,
|
'function': handler,
|
||||||
'filters': filters
|
'filters': {ftype: fvalue for ftype, fvalue in filters.items() if fvalue is not None}
|
||||||
|
# Remove None values, they are skipped in _test_filter anyway
|
||||||
|
#'filters': filters
|
||||||
}
|
}
|
||||||
|
|
||||||
def middleware_handler(self, update_types=None):
|
def middleware_handler(self, update_types=None):
|
||||||
@ -2521,10 +2523,10 @@ class TeleBot:
|
|||||||
|
|
||||||
def decorator(handler):
|
def decorator(handler):
|
||||||
handler_dict = self._build_handler_dict(handler,
|
handler_dict = self._build_handler_dict(handler,
|
||||||
|
chat_types=chat_types,
|
||||||
content_types=content_types,
|
content_types=content_types,
|
||||||
commands=commands,
|
commands=commands,
|
||||||
regexp=regexp,
|
regexp=regexp,
|
||||||
chat_types=chat_types,
|
|
||||||
func=func,
|
func=func,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.add_message_handler(handler_dict)
|
self.add_message_handler(handler_dict)
|
||||||
@ -2552,13 +2554,14 @@ class TeleBot:
|
|||||||
:return: decorated function
|
:return: decorated function
|
||||||
"""
|
"""
|
||||||
handler_dict = self._build_handler_dict(callback,
|
handler_dict = self._build_handler_dict(callback,
|
||||||
|
chat_types=chat_types,
|
||||||
content_types=content_types,
|
content_types=content_types,
|
||||||
commands=commands,
|
commands=commands,
|
||||||
regexp=regexp,
|
regexp=regexp,
|
||||||
func=func,
|
func=func,
|
||||||
chat_types=chat_types,
|
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.add_message_handler(handler_dict)
|
self.add_message_handler(handler_dict)
|
||||||
|
|
||||||
def edited_message_handler(self, commands=None, regexp=None, func=None, content_types=None, chat_types=None, **kwargs):
|
def edited_message_handler(self, commands=None, regexp=None, func=None, content_types=None, chat_types=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Edit message handler decorator
|
Edit message handler decorator
|
||||||
@ -2576,11 +2579,11 @@ class TeleBot:
|
|||||||
|
|
||||||
def decorator(handler):
|
def decorator(handler):
|
||||||
handler_dict = self._build_handler_dict(handler,
|
handler_dict = self._build_handler_dict(handler,
|
||||||
|
chat_types=chat_types,
|
||||||
|
content_types=content_types,
|
||||||
commands=commands,
|
commands=commands,
|
||||||
regexp=regexp,
|
regexp=regexp,
|
||||||
func=func,
|
func=func,
|
||||||
content_types=content_types,
|
|
||||||
chat_types=chat_types,
|
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.add_edited_message_handler(handler_dict)
|
self.add_edited_message_handler(handler_dict)
|
||||||
return handler
|
return handler
|
||||||
@ -2607,13 +2610,14 @@ class TeleBot:
|
|||||||
:return: decorated function
|
:return: decorated function
|
||||||
"""
|
"""
|
||||||
handler_dict = self._build_handler_dict(callback,
|
handler_dict = self._build_handler_dict(callback,
|
||||||
|
chat_types=chat_types,
|
||||||
content_types=content_types,
|
content_types=content_types,
|
||||||
commands=commands,
|
commands=commands,
|
||||||
regexp=regexp,
|
regexp=regexp,
|
||||||
func=func,
|
func=func,
|
||||||
chat_types=chat_types,
|
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.add_edited_message_handler(handler_dict)
|
self.add_edited_message_handler(handler_dict)
|
||||||
|
|
||||||
def channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
|
def channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Channel post handler decorator
|
Channel post handler decorator
|
||||||
@ -2630,10 +2634,10 @@ class TeleBot:
|
|||||||
|
|
||||||
def decorator(handler):
|
def decorator(handler):
|
||||||
handler_dict = self._build_handler_dict(handler,
|
handler_dict = self._build_handler_dict(handler,
|
||||||
|
content_types=content_types,
|
||||||
commands=commands,
|
commands=commands,
|
||||||
regexp=regexp,
|
regexp=regexp,
|
||||||
func=func,
|
func=func,
|
||||||
content_types=content_types,
|
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.add_channel_post_handler(handler_dict)
|
self.add_channel_post_handler(handler_dict)
|
||||||
return handler
|
return handler
|
||||||
@ -2665,6 +2669,7 @@ class TeleBot:
|
|||||||
func=func,
|
func=func,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.add_channel_post_handler(handler_dict)
|
self.add_channel_post_handler(handler_dict)
|
||||||
|
|
||||||
def edited_channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
|
def edited_channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Edit channel post handler decorator
|
Edit channel post handler decorator
|
||||||
@ -2681,10 +2686,10 @@ class TeleBot:
|
|||||||
|
|
||||||
def decorator(handler):
|
def decorator(handler):
|
||||||
handler_dict = self._build_handler_dict(handler,
|
handler_dict = self._build_handler_dict(handler,
|
||||||
|
content_types=content_types,
|
||||||
commands=commands,
|
commands=commands,
|
||||||
regexp=regexp,
|
regexp=regexp,
|
||||||
func=func,
|
func=func,
|
||||||
content_types=content_types,
|
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.add_edited_channel_post_handler(handler_dict)
|
self.add_edited_channel_post_handler(handler_dict)
|
||||||
return handler
|
return handler
|
||||||
@ -2783,7 +2788,6 @@ class TeleBot:
|
|||||||
handler_dict = self._build_handler_dict(callback, func=func, **kwargs)
|
handler_dict = self._build_handler_dict(callback, func=func, **kwargs)
|
||||||
self.add_chosen_inline_handler(handler_dict)
|
self.add_chosen_inline_handler(handler_dict)
|
||||||
|
|
||||||
|
|
||||||
def callback_query_handler(self, func, **kwargs):
|
def callback_query_handler(self, func, **kwargs):
|
||||||
"""
|
"""
|
||||||
Callback request handler decorator
|
Callback request handler decorator
|
||||||
@ -2913,9 +2917,7 @@ class TeleBot:
|
|||||||
:param func:
|
:param func:
|
||||||
:return: decorated function
|
:return: decorated function
|
||||||
"""
|
"""
|
||||||
handler_dict = self._build_handler_dict(callback,
|
handler_dict = self._build_handler_dict(callback, func=func, **kwargs)
|
||||||
func=func,
|
|
||||||
**kwargs)
|
|
||||||
self.add_poll_handler(handler_dict)
|
self.add_poll_handler(handler_dict)
|
||||||
|
|
||||||
def poll_answer_handler(self, func=None, **kwargs):
|
def poll_answer_handler(self, func=None, **kwargs):
|
||||||
@ -2948,9 +2950,7 @@ class TeleBot:
|
|||||||
:param func:
|
:param func:
|
||||||
:return: decorated function
|
:return: decorated function
|
||||||
"""
|
"""
|
||||||
handler_dict = self._build_handler_dict(callback,
|
handler_dict = self._build_handler_dict(callback, func=func, **kwargs)
|
||||||
func=func,
|
|
||||||
**kwargs)
|
|
||||||
self.add_poll_answer_handler(handler_dict)
|
self.add_poll_answer_handler(handler_dict)
|
||||||
|
|
||||||
def my_chat_member_handler(self, func=None, **kwargs):
|
def my_chat_member_handler(self, func=None, **kwargs):
|
||||||
@ -2983,9 +2983,7 @@ class TeleBot:
|
|||||||
:param func:
|
:param func:
|
||||||
:return: decorated function
|
:return: decorated function
|
||||||
"""
|
"""
|
||||||
handler_dict = self._build_handler_dict(callback,
|
handler_dict = self._build_handler_dict(callback, func=func, **kwargs)
|
||||||
func=func,
|
|
||||||
**kwargs)
|
|
||||||
self.add_my_chat_member_handler(handler_dict)
|
self.add_my_chat_member_handler(handler_dict)
|
||||||
|
|
||||||
def chat_member_handler(self, func=None, **kwargs):
|
def chat_member_handler(self, func=None, **kwargs):
|
||||||
|
@ -33,7 +33,7 @@ READ_TIMEOUT = 30
|
|||||||
|
|
||||||
LONG_POLLING_TIMEOUT = 10 # Should be positive, short polling should be used for testing purposes only (https://core.telegram.org/bots/api#getupdates)
|
LONG_POLLING_TIMEOUT = 10 # Should be positive, short polling should be used for testing purposes only (https://core.telegram.org/bots/api#getupdates)
|
||||||
|
|
||||||
SESSION_TIME_TO_LIVE = None # In seconds. None - live forever, 0 - one-time
|
SESSION_TIME_TO_LIVE = 600 # In seconds. None - live forever, 0 - one-time
|
||||||
|
|
||||||
RETRY_ON_ERROR = False
|
RETRY_ON_ERROR = False
|
||||||
RETRY_TIMEOUT = 2
|
RETRY_TIMEOUT = 2
|
||||||
|
Loading…
Reference in New Issue
Block a user