A
A
AlmazKayum2018-03-18 16:24:56
Python
AlmazKayum, 2018-03-18 16:24:56

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)

3. When exactly is it necessary to set .wait() ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2018-03-19
@AlmazKayum

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.

T
test293, 2021-12-03
@test293

AsyncTeleBot is now asynchronous, but not yet in release.
See examples:
https://github.com/eternnoir/pyTelegramBotAPI/tree...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question