From 0557b67734fb3db14a2cbefc9c2f1976a3e48b90 Mon Sep 17 00:00:00 2001 From: Davte Date: Thu, 18 Jul 2019 10:17:41 +0200 Subject: [PATCH] Backward compatibility: allow regular functions instead of coroutines Wrap regular functions passed to `set_chosen_inline_result_handler` since it accepts only coroutines. --- davtelepot/__init__.py | 2 +- davtelepot/custombot.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/davtelepot/__init__.py b/davtelepot/__init__.py index 53b150a..ba7f8ab 100644 --- a/davtelepot/__init__.py +++ b/davtelepot/__init__.py @@ -7,7 +7,7 @@ __author__ = "Davide Testa" __email__ = "davide@davte.it" __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __license__ = "GNU General Public License v3.0" -__version__ = "2.1.8" +__version__ = "2.1.9" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/davtelepot/custombot.py b/davtelepot/custombot.py index 446d95b..f43f189 100644 --- a/davtelepot/custombot.py +++ b/davtelepot/custombot.py @@ -246,10 +246,15 @@ class Bot(davtelepot.bot.Bot): This method is deprecated: use `set_chosen_inline_result_handler` instead. """ + if not asyncio.iscoroutinefunction(func): + async def _func(update): + return func(update) + else: + _func = func return self.set_chosen_inline_result_handler( user_id=user_id, result_id=result_id, - handler=func + handler=_func ) async def handle_pinned_message(self, update, user_record=None):