delete_chat_history()
- Client.delete_chat_history()
Delete the history of a chat.
Usable by Users Bots
- Parameters:
chat_id (
int
|str
) – Unique identifier (int) or username (str) of the target chat.max_id (
int
, optional) – Maximum ID of message to delete.revoke (
bool
, optional) – Deletes messages history for everyone. RequiredTrue
if using in channel.just_clear (
bool
, optional) – If True, clear history for the current user, without actually removing chat. For private and simple group chats only.min_date (
datetime
, optional) – Delete all messages newer than this time. For private and simple group chats only.max_date (
datetime
, optional) – Delete all messages older than this time. For private and simple group chats only.
- Returns:
int
– Amount of affected messages
Example
# Delete all messages in channel await app.delete_chat_history(chat_id, revoke=True)