delete_chat_history()¶
- Client.delete_chat_history()¶
Deletes all messages in the chat. For group chats this will release the usernames and remove all members.
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. Defaults to 0.
revoke (``bool``, *optional*) – Pass True to delete messages for all chat members. Always True if using in
CHANNELandSUPERGROUPchats.just_clear (``bool``, *optional*) – Pass True to clear history for the current user, without actually removing chat. For
PRIVATEandGROUPchats only.min_date (:py:obj:`~datetime.datetime`, *optional*) – The minimum date of the messages to delete. Delete all messages newer than this time. For
PRIVATEandGROUPchats only.max_date (:py:obj:`~datetime.datetime`, *optional*) – The maximum date of the messages to delete. Delete all messages older than this time. For
PRIVATEandGROUPchats only.
- Returns:¶
``int`` (Amount of affected messages)
Example
# Delete all messages in channel await app.delete_chat_history(chat_id, revoke=True)