DeleteMessagesRequest

Both users and bots can use this request. See code examples.

---functions---
messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector<int> = messages.AffectedMessages

Returns

messages.AffectedMessages

This type can only be an instance of:

AffectedMessages

Parameters

idintA list must be supplied.
revokeflagThis argument defaults to None and can be omitted.

Known RPC errors

This request can cause 1 known error:

MessageDeleteForbiddenErrorYou can't delete one of the messages you tried to delete, most likely because it is a service message..

You can import these from telethon.errors.

Example

Please refer to the documentation of client.delete_messages() to learn about the parameters and see several code examples on how to use it.

The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.messages.DeleteMessagesRequest(
        id=[42],
        revoke=True
    ))
    print(result.stringify())