A
A
ambal2452021-10-31 18:51:53
PHP
ambal245, 2021-10-31 18:51:53

Delete previous message in telegram bot?

How to delete the previous message in the bot when receiving a message from another chat?

I can give the following example:
1. The user writes the \start command to the bot and follows step-by-step recommendations. In the last recommendation, the bot sends a message: "Add the bot @nikname_bot to the administrators. After adding, send a command from the private chat\group \register @nikname_bot"
2. The user adds and gives admin rights, sends a message with the command \register @nikname_bot
3. My bot receives this ( \register @nikname_bot) message and process it if ($text == "\register @nikname_bot"){}and send the message using the sendMessage()"Your Channel\Chat is Connected" method. At this point, you need to delete the previous message. deleteMessage()

method can only be deleted if the message was sent inside the bot, having the chat id and the message id. We have the chat ID, but not the message ID. In is the ID of the message of the group \ chat. $data['message']['message_id']

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2021-10-31
@nokimaro

When sending a "previous message", its id must be saved in your database in order to find and delete it later by id.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question