Answer the question
In order to leave comments, you need to log in
How to use AsyncTeleBot?
Good day!
It is necessary to make an asynchronous Telegram bot.
I write in Python using the PyTelegramBotApi library .
I understand that you need to use aiohttp webhook and use AsyncTeleBot instead of TeleBot .
The official github repository of the library has an example of how to use AsyncTeleBot, but it is short and completely incomprehensible. Googling led absolutely nowhere, I did not find examples of how to use it.
1. How to make an asynchronous bot right ?
2. How to use AsyncTeleBot in code:
bot = telebot.AsyncTeleBot(conf.token)
@bot.message_hanler(commands=['start']
def start(m):
bot.send_message(chat_id, text)
@bot.callback_query_handler(func=lambda call: call.data == 'call1')
def call1(call):
bot.send_message(chat_id, text)
Answer the question
In order to leave comments, you need to log in
AsyncTeleBot simply runs blocking operations on separate threads. It has nothing to do with aiohttp. You need to call the wait method when you need the result of a blocking operation, and in those parts of the code where they are needed. If you do not need it, then you can not call wait.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question