telegram-bot – Is it possible to get back the text of the message sent by the bot in the Telegram Bot Api?

Question:

Case: a bot sends some arbitrary message. After some time, you need to edit this message, but the bot does not remember its text. Although the chat id and message id are known. Is it possible to somehow get back its text? The getUpdates method, as far as I understand, allows you to do this only with messages from users, it does not show its own messages.

Answer:

No, you won't be able to get the text of an arbitrary message by chat_id and message_id just like that . Therefore, you need to either memorize the text of the sent messages, or construct it anew.

However, if you need to edit a message for certain events, then perhaps the getUpdates method will be useful – it returns the contents of all relevant messages. For example, when you click on the inline button, the bot receives the text of the message with this button; when responding, the bot sees the message that was answered, etc.

Scroll to Top
AllEscort