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:
parent
a01ff8c486
commit
0557b67734
@ -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"
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user