Skip to main content

messages.deleteHistory

Deletes communication history.

func (c *Client) MessagesDeleteHistory(ctx context.Context, request *MessagesDeleteHistoryRequest) (*MessagesAffectedHistory, error)

Calling this method

client.Run(ctx, func(ctx context.Context) error {
api := client.API()

res, err := api.MessagesDeleteHistory(ctx, &tg.MessagesDeleteHistoryRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // *MessagesAffectedHistory
return nil
})

Parameters

NameTypeRequiredDescription
JustClearboolJust clear history for the current user, without actually removing messages for every chat user
RevokeboolWhether to delete the message history for all chat participants
PeerInputPeerClassyesUser or chat, communication history of which will be deleted
MaxIDintyesMaximum ID of message to delete
MinDateintDelete all messages newer than this UNIX timestamp
MaxDateintDelete all messages older than this UNIX timestamp

Returns

*MessagesAffectedHistory

Possible errors

CodeTypeDescription
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
400CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this.
400CHAT_ID_INVALIDThe provided chat id is invalid.
400CHAT_REVOKE_DATE_UNSUPPORTEDmin_date and max_date are not available for using with non-user peers.
400MAX_DATE_INVALIDThe specified maximum date is invalid.
400MESSAGE_ID_INVALIDThe provided message id is invalid.
400MIN_DATE_INVALIDThe specified minimum date is invalid.
400MSG_ID_INVALIDInvalid message ID provided.
400PEER_ID_INVALIDThe provided peer id is invalid.

References