goalie1998
goalie1998

Reputation: 1432

Telegram Bot delete sent photos?

I am looking to delete a photo sent by my bot (reply_photo()), I can't find any specific reference to doing so in the documentation, and have tried delete_message(), but don't know how to delete a photo. Is it currently possible?

Upvotes: 0

Views: 2102

Answers (3)

Gagan T K
Gagan T K

Reputation: 728

You need to have the chat_id and the message_id of that message sent by bot, then you can delete using context.bot.delete_message(chat_id, message_id).

Note: Bot cannot delete a message if it was sent more than 48 hours ago.

Upvotes: 0

goalie1998
goalie1998

Reputation: 1432

I found a workaround (that I am currently still playing with). I named the photo I sent, then when I want to delete it, I delete it using .delete(). For example:

photo = x.message.reply_photo(...)
...
...
photo.delete()

Upvotes: 0

Amir Maleki
Amir Maleki

Reputation: 419

It's currently possible in Telegram API, not the Bot API unfortunately. It's a shame :(

Upvotes: 0

Related Questions