I am using pyTelegramBotApi and I would like to get the id of the message sent to a chat and then forward it to other chats the problem is that i always get this exception 'AsyncTask' object has no attribute 'message_id'
while the message is sent correctly how to solve?
bot = telebot.AsyncTeleBot(bot_token)
res = bot.send_message(cid,message)
try:
message_id = res.message_id
print(message_id)
except Exception as e:
print(e)
Since send_message()
is an AsyncTask, you'll need to .wait()
until the event is done;
res = bot.send_message(cid,message)
try:
result = res.wait()
print(result.message_id)
except Exception as e:
print(e)
More telegram-bot docs .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.