K
K
ki ki2019-12-04 19:13:57
Python
ki ki, 2019-12-04 19:13:57

How to determine the message_id, knowing the channel id and the text of the message?

I am writing a bot in Python using pyTelegramBotAPI.
After a user request, my bot should remove the message from the channel. This site gave me the following:

bot.delete_message(chat_id=message.chat_id,
                   message_id=message.message_id,
                   *args,
                   **kwargs)

How to determine the message_id, knowing the text of the post and the channel id?
Or how to get the message_id when posting to a channel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Ninazu, 2019-12-04
@kiiii

It is possible to determine message_id but not with 100% probability. Since the message can be duplicated in the channel. To do this, you need to connect to the channel and load its history. For example, using MTProto
When publishing to a channel, the method returns a message_id in response))
But the easiest and most correct way is to send a message from the channel to the bot. Then his ID will arrive exactly in the request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question