Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram bot API: get message id to forward it

So, I need my bot to forward a message of a chat. But in order to do so, I need to get the id of the message I want to forward (it's an old message). How can I get the id of that message so I can send it?

This is the code I'm using

@bot.message_handler(func=lambda m: True)
def reply_ids(message):
    cid = message.chat.id
    bot.reply_to(message, "The message id is: " + str(message.message_id) + " This chat ID is: " + str(cid))
like image 993
José María Avatar asked Oct 31 '22 16:10

José María


1 Answers

When receiving a message, the id will be in message.message_id, as documented here.

like image 135
Dean Fenster Avatar answered Nov 03 '22 00:11

Dean Fenster