handle deleted message by user in telegram bot
Asked Answered
T

3

10

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 .

Tenorrhaphy answered 28/1, 2018 at 7:49 Comment(0)
P
11

No. There is no way to track whether messages have been deleted or not.

Paulsen answered 28/1, 2018 at 10:43 Comment(5)
really ?! so :(Tenorrhaphy
Unfortunately :(Paulsen
This is sad ! :<Tenorrhaphy
I would recommend asking @BotSupport to implement this. If enough people ask, they have to listenPlumbing
There is actually: core.telegram.org/constructor/updateDeleteMessagesHanna
H
0

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

Hogweed answered 4/6, 2022 at 9:45 Comment(1)
Returns only msg_idHogweed
H
0

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)
Hanna answered 2/6, 2023 at 18:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.