1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Fix handler.

This commit is contained in:
eternnoir 2017-05-25 11:45:44 +08:00
parent 84b1aca939
commit 708635e420

View File

@ -148,8 +148,8 @@ class TeleBot:
new_inline_querys = [] new_inline_querys = []
new_chosen_inline_results = [] new_chosen_inline_results = []
new_callback_querys = [] new_callback_querys = []
new_shipping_query = [] new_shipping_querys = []
new_pre_checkout_query= [] new_pre_checkout_querys = []
for update in updates: for update in updates:
if update.update_id > self.last_update_id: if update.update_id > self.last_update_id:
@ -169,9 +169,9 @@ class TeleBot:
if update.callback_query: if update.callback_query:
new_callback_querys.append(update.callback_query) new_callback_querys.append(update.callback_query)
if update.shipping_query: if update.shipping_query:
new_shipping_query.append(update.shipping_query) new_shipping_querys.append(update.shipping_query)
if update.pre_checkout_query: if update.pre_checkout_query:
new_pre_checkout_query.append(update.pre_checkout_query) new_pre_checkout_querys.append(update.pre_checkout_query)
logger.debug('Received {0} new updates'.format(len(updates))) logger.debug('Received {0} new updates'.format(len(updates)))
if len(new_messages) > 0: if len(new_messages) > 0:
@ -188,6 +188,10 @@ class TeleBot:
self.process_new_chosen_inline_query(new_chosen_inline_results) self.process_new_chosen_inline_query(new_chosen_inline_results)
if len(new_callback_querys) > 0: if len(new_callback_querys) > 0:
self.process_new_callback_query(new_callback_querys) self.process_new_callback_query(new_callback_querys)
if len(new_pre_checkout_querys) > 0:
self.process_new_pre_checkout_query(new_pre_checkout_querys)
if len(new_shipping_querys) > 0:
self.process_new_shipping_query(new_shipping_querys)
def process_new_messages(self, new_messages): def process_new_messages(self, new_messages):
self._append_pre_next_step_handler() self._append_pre_next_step_handler()
@ -214,6 +218,12 @@ class TeleBot:
def process_new_callback_query(self, new_callback_querys): def process_new_callback_query(self, new_callback_querys):
self._notify_command_handlers(self.callback_query_handlers, new_callback_querys) self._notify_command_handlers(self.callback_query_handlers, new_callback_querys)
def process_new_shipping_query(self, new_shipping_querys):
self._notify_command_handlers(self.shipping_query_handlers, new_shipping_querys)
def process_new_pre_checkout_query(self, pre_checkout_querys):
self._notify_command_handlers(self.pre_checkout_query_handlers, pre_checkout_querys)
def __notify_update(self, new_messages): def __notify_update(self, new_messages):
for listener in self.update_listener: for listener in self.update_listener:
self._exec_task(listener, new_messages) self._exec_task(listener, new_messages)
@ -909,7 +919,7 @@ class TeleBot:
def pre_checkout_query_handler(self, func, **kwargs): def pre_checkout_query_handler(self, func, **kwargs):
def decorator(handler): def decorator(handler):
handler_dict = self._build_handler_dict(handler, func=func, **kwargs) handler_dict = self._build_handler_dict(handler, func=func, **kwargs)
self.add_pre_checkout_queryhandler(handler_dict) self.add_pre_checkout_query_handler(handler_dict)
return handler return handler
return decorator return decorator