Is there any way that can handle deleted message by user in one-to-one chat or groups that bot is member of it ? there is method for edited message update but not for deleted message .
handle deleted message by user in telegram bot
Asked Answered
No. There is no way to track whether messages have been deleted or not.
really ?! so :( –
Tenorrhaphy
Unfortunately :( –
Paulsen
This is sad ! :< –
Tenorrhaphy
I would recommend asking @BotSupport to implement this. If enough people ask, they have to listen –
Plumbing
There is actually: core.telegram.org/constructor/updateDeleteMessages –
Hanna
The pyrogram have DeletedMessagesHandler / @Client.on_deleted_messages(). If used as Userbot, It handles in all chat groups channels. I failed to filter. Maybe it will work in a bot
Returns only msg_id –
Hogweed
There is actually an event update from the official API docs: https://core.telegram.org/constructor/updateDeleteMessages
I had the very same problem, 'cause no framework seems to manage this event. I solved by using directly the official Telegam libraries TDLibs with a JS wrapper (TDL in this case). Here it is a simple and working code:
import {Client} from 'tdl'
import {TDLib} from 'tdl-tdlib-addon'
import {getTdjson} from 'prebuilt-tdlib'
// Start bot
const client = new Client(new TDLib(getTdjson()), {
apiHash: YOUR_TELEGRAM_API_HASH,
apiId: YOUR_TELEGRAM_API_ID
})
await client.loginAsBot(YOUR_TELEGRAM_BOT_TOKEN)
// Manage updates
client.on('update', function(update) {
// On deleted message(s) event
if (update._ === 'updateDeleteMessages') {
return yourHandlerFunction()
}
// If Other updates, do other stuff ...
})
// Print errors
client.on('error', console.error)
© 2022 - 2024 — McMap. All rights reserved.