From b9a0c3e5114b986d21647310dbf5eb69894d7fe9 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 16 Jun 2016 11:49:51 +0300 Subject: [PATCH] + More flexibility for different handlers(callback_query_handler and etc.): now they are not limited in input arguments so can be easily extended by subclassing arguments --- telebot/__init__.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 4b86c06..25e2e20 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -535,9 +535,6 @@ class TeleBot: def unban_chat_member(self, chat_id, user_id): return apihelper.unban_chat_member(self.token, chat_id, user_id) - def answer_callback_query(self, callback_query_id, text=None, show_alert=None): - return apihelper.answer_callback_query(self.token, callback_query_id, text, show_alert) - def edit_message_text(self, text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None, disable_web_page_preview=None, reply_markup=None): result = apihelper.edit_message_text(self.token, text, chat_id, message_id, inline_message_id, parse_mode, @@ -723,9 +720,9 @@ class TeleBot: def add_edited_message_handler(self, handler_dict): self.edited_message_handlers.append(handler_dict) - def inline_handler(self, func): + def inline_handler(self, func, **kwargs): def decorator(handler): - handler_dict = self._build_handler_dict(handler, func=func) + handler_dict = self._build_handler_dict(handler, func=func, **kwargs) self.add_inline_handler(handler_dict) return handler @@ -734,9 +731,9 @@ class TeleBot: def add_inline_handler(self, handler_dict): self.inline_handlers.append(handler_dict) - def chosen_inline_handler(self, func): + def chosen_inline_handler(self, func, **kwargs): def decorator(handler): - handler_dict = self._build_handler_dict(handler, func=func) + handler_dict = self._build_handler_dict(handler, func=func, **kwargs) self.add_chosen_inline_handler(handler_dict) return handler @@ -745,9 +742,9 @@ class TeleBot: def add_chosen_inline_handler(self, handler_dict): self.chosen_inline_handlers.append(handler_dict) - def callback_query_handler(self, func): + def callback_query_handler(self, func, **kwargs): def decorator(handler): - handler_dict = self._build_handler_dict(handler, func=func) + handler_dict = self._build_handler_dict(handler, func=func, **kwargs) self.add_callback_query_handler(handler_dict) return decorator