Yedidya kfir
Yedidya kfir

Reputation: 1779

how to delete all messages in telegram chat with python

I am writing a telegram bot in python. One of my bot functionalities is to delete all of the messages in the chat. I find the function bot.delete_message however it delete only one message according to message id and I don't have the ids for every message.

I also saw in the telegram api some functions that can help me, like https://core.telegram.org/method/channels.deleteHistory or https://core.telegram.org/method/messages.getHistory (will allow me to get the id of every message and then delete them). but I don't see how I can call these functions in the python api.

Is there a way to call these functions with the python api? or perhaps is there another way to delete entire chat history?

Upvotes: 0

Views: 3992

Answers (1)

Gagan T K
Gagan T K

Reputation: 728

Telegram Bot API doesn't have methods to delete multiple messages. You have to know message_id to delete it.

The methods which you've mentioned in the question are not part of Telegram Bot API, but they're part of Telegram API. python-telegram-bot library has support to only Bot API. You can make use of telethon library which supports Telegram API.

Upvotes: 1

Related Questions