V
V
Valentin_152021-05-13 18:44:46
Bots
Valentin_15, 2021-05-13 18:44:46

How to change message in telegram bot?

I ran into a problem changing or deleting messages sent by the bot.
I am asked for the Id of the message to be changed. But where to get it from? and is it possible to set some kind of Id when sending a message?

(Thanks in advance to whoever answers)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2021-05-14
@shurshur

When a message is sent, a Message object is returned containing the required id.
For example, in telebot:

msg = bot.send_message(my_chat_id, message_text)
msg_id = msg.message_id
bot.edit_message_text(chat_id=my_chat_id, message_id=msg_id, text="(edited) "+message_text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question