How do I use async methods without async for __init__ method? #3775
-
I want to make a wrapper class for a bot. I want to encapsulate some attributes. For example, is this bot on a specific channel and its admin etc. For this I need to use get_member but it is async. Is there non-async versions of it or should I do it myself via the plain telegram API? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
PTB is asyncio-only as of V20. You can probably use asyncio.loop.run_until_complete to your advantage or define a coroutine methods |
Beta Was this translation helpful? Give feedback.
PTB is asyncio-only as of V20. You can probably use asyncio.loop.run_until_complete to your advantage or define a coroutine methods
intialize
for your wrapper class that is used for any I/O related initialization. The latter approach is also what the PTB classes likr Bot & Application do: https://docs.python-telegram-bot.org/en/stable/telegram.bot.html#telegram.Bot.initialize