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 .

alireza
  • 1,173
  • 4
  • 19
  • 40

3 Answers3

10

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

Maak
  • 4,720
  • 3
  • 28
  • 39
Sean Wei
  • 7,433
  • 1
  • 19
  • 39
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

QSST
  • 1
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)
Jacopo Pace
  • 460
  • 7
  • 14