Backward compatibility: allow regular functions instead of coroutines

Wrap regular functions passed to `set_chosen_inline_result_handler` 
since it accepts only coroutines.
This commit is contained in:
Davte 2019-07-18 10:17:41 +02:00
parent a01ff8c486
commit 0557b67734
2 changed files with 7 additions and 2 deletions

View File

@ -7,7 +7,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.1.8" __version__ = "2.1.9"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -246,10 +246,15 @@ class Bot(davtelepot.bot.Bot):
This method is deprecated: use `set_chosen_inline_result_handler` This method is deprecated: use `set_chosen_inline_result_handler`
instead. instead.
""" """
if not asyncio.iscoroutinefunction(func):
async def _func(update):
return func(update)
else:
_func = func
return self.set_chosen_inline_result_handler( return self.set_chosen_inline_result_handler(
user_id=user_id, user_id=user_id,
result_id=result_id, result_id=result_id,
handler=func handler=_func
) )
async def handle_pinned_message(self, update, user_record=None): async def handle_pinned_message(self, update, user_record=None):