Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
coder2020official committed Aug 16, 2021
1 parent f4ef236 commit 56cd397
Showing 1 changed file with 180 additions and 3 deletions.
183 changes: 180 additions & 3 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def polling(self, none_stop: bool=False, skip_pending=False, interval: int=0, ti
This allows the bot to retrieve Updates automagically and notify listeners and message handlers accordingly.
Warning: Do not call this function more than once!
Always get updates.
:param interval: Delay between two update retrivals
:param none_stop: Do not stop polling when an ApiException occurs.
Expand Down Expand Up @@ -2520,6 +2520,23 @@ def add_message_handler(self, handler_dict):
"""
self.message_handlers.append(handler_dict)

def register_message_handler(self, callback, content_types=None, commands=None, regexp=None, func=None, **kwargs):
"""
Registers message handler.
:param callback: function to be called
:param content_types: list of content_types
:param commands: list of commands
:param regexp:
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
content_types=content_types,
commands=commands,
regexp=regexp,
func=func,
**kwargs)
self.add_message_handler(handler_dict)
def edited_message_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
"""
Edit message handler decorator
Expand Down Expand Up @@ -2554,6 +2571,23 @@ def add_edited_message_handler(self, handler_dict):
"""
self.edited_message_handlers.append(handler_dict)

def register_edited_message_handler(self, callback, content_types=None, commands=None, regexp=None, func=None, **kwargs):
"""
Registers edited message handler.
:param callback: function to be called
:param content_types: list of content_types
:param commands: list of commands
:param regexp:
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
content_types=content_types,
commands=commands,
regexp=regexp,
func=func,
**kwargs)
self.add_edited_message_handler(handler_dict)
def channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
"""
Channel post handler decorator
Expand Down Expand Up @@ -2587,7 +2621,24 @@ def add_channel_post_handler(self, handler_dict):
:return:
"""
self.channel_post_handlers.append(handler_dict)


def register_channel_post_handler(self, callback, content_types=None, commands=None, regexp=None, func=None, **kwargs):
"""
Registers channel post message handler.
:param callback: function to be called
:param content_types: list of content_types
:param commands: list of commands
:param regexp:
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
content_types=content_types,
commands=commands,
regexp=regexp,
func=func,
**kwargs)
self.add_channel_post_handler(handler_dict)
def edited_channel_post_handler(self, commands=None, regexp=None, func=None, content_types=None, **kwargs):
"""
Edit channel post handler decorator
Expand Down Expand Up @@ -2622,6 +2673,24 @@ def add_edited_channel_post_handler(self, handler_dict):
"""
self.edited_channel_post_handlers.append(handler_dict)

def register_edited_channel_post_handler(self, callback, content_types=None, commands=None, regexp=None, func=None, **kwargs):
"""
Registers edited channel post message handler.
:param callback: function to be called
:param content_types: list of content_types
:param commands: list of commands
:param regexp:
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
content_types=content_types,
commands=commands,
regexp=regexp,
func=func,
**kwargs)
self.add_edited_channel_post_handler(handler_dict)

def inline_handler(self, func, **kwargs):
"""
Inline call handler decorator
Expand All @@ -2645,6 +2714,18 @@ def add_inline_handler(self, handler_dict):
"""
self.inline_handlers.append(handler_dict)

def register_inline_handler(self, callback, func, **kwargs):
"""
Registers inline handler.
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_inline_handler(handler_dict)

def chosen_inline_handler(self, func, **kwargs):
"""
Description: TBD
Expand All @@ -2668,6 +2749,19 @@ def add_chosen_inline_handler(self, handler_dict):
"""
self.chosen_inline_handlers.append(handler_dict)

def register_chosen_inline_handler(self, callback, func, **kwargs):
"""
Registers chosen inline handler.
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_chosen_inline_handler(handler_dict)


def callback_query_handler(self, func, **kwargs):
"""
Callback request handler decorator
Expand All @@ -2691,6 +2785,18 @@ def add_callback_query_handler(self, handler_dict):
"""
self.callback_query_handlers.append(handler_dict)

def register_callback_query_handler(self, callback, func, **kwargs):
"""
Registers callback query handler..
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_callback_query_handler(handler_dict)

def shipping_query_handler(self, func, **kwargs):
"""
Shipping request handler
Expand All @@ -2714,6 +2820,18 @@ def add_shipping_query_handler(self, handler_dict):
"""
self.shipping_query_handlers.append(handler_dict)

def register_shipping_query_handler(self, callback, func, **kwargs):
"""
Registers shipping query handler.
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_shipping_query_handler(handler_dict)

def pre_checkout_query_handler(self, func, **kwargs):
"""
Pre-checkout request handler
Expand All @@ -2736,6 +2854,18 @@ def add_pre_checkout_query_handler(self, handler_dict):
:return:
"""
self.pre_checkout_query_handlers.append(handler_dict)

def register_pre_checkout_query_handler(self, callback, func, **kwargs):
"""
Registers pre-checkout request handler.
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_pre_checkout_query_handler(handler_dict)

def poll_handler(self, func, **kwargs):
"""
Expand All @@ -2760,6 +2890,18 @@ def add_poll_handler(self, handler_dict):
"""
self.poll_handlers.append(handler_dict)

def register_poll_handler(self, callback, func, **kwargs):
"""
Registers poll handler.
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_poll_handler(handler_dict)

def poll_answer_handler(self, func=None, **kwargs):
"""
Poll_answer request handler
Expand All @@ -2782,7 +2924,19 @@ def add_poll_answer_handler(self, handler_dict):
:return:
"""
self.poll_answer_handlers.append(handler_dict)


def register_poll_answer_handler(self, callback, func, **kwargs):
"""
Registers poll answer handler.
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_poll_answer_handler(handler_dict)

def my_chat_member_handler(self, func=None, **kwargs):
"""
my_chat_member handler
Expand All @@ -2806,6 +2960,18 @@ def add_my_chat_member_handler(self, handler_dict):
"""
self.my_chat_member_handlers.append(handler_dict)

def register_my_chat_member_handler(self, callback, func=None, **kwargs):
"""
Registers my chat member handler.
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_my_chat_member_handler(handler_dict)

def chat_member_handler(self, func=None, **kwargs):
"""
chat_member handler
Expand All @@ -2829,6 +2995,17 @@ def add_chat_member_handler(self, handler_dict):
"""
self.chat_member_handlers.append(handler_dict)

def register_chat_member_handler(self, callback, func=None, **kwargs):
"""
Registers chat member handler.
:param callback: function to be called
:param func:
:return: decorated function
"""
handler_dict = self._build_handler_dict(callback,
func=func,
**kwargs)
self.add_chat_member_handler(handler_dict)

def _test_message_handler(self, message_handler, message):
"""
Expand Down

0 comments on commit 56cd397

Please sign in to comment.