messages.getHistory
Returns the message history in a peer. Results are ordered by date (descending).
func (c *Client) MessagesGetHistory(ctx context.Context, request *MessagesGetHistoryRequest) (MessagesMessagesClass, error)
Calling this method
client.Run(ctx, func(ctx context.Context) error {
api := client.API()
res, err := api.MessagesGetHistory(ctx, &tg.MessagesGetHistoryRequest{
// see Parameters
})
if err != nil {
return err
}
_ = res // MessagesMessagesClass
return nil
})
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
Peer | InputPeerClass | yes | Target peer |
OffsetID | int | yes | Only return messages starting from the specified message ID |
OffsetDate | int | yes | Only return messages sent before the specified date |
AddOffset | int | yes | Number of list elements to be skipped, negative values are also accepted. |
Limit | int | yes | Number of results to return |
MaxID | int | yes | If a positive value was transferred, the method will return only messages with IDs less than max_id |
MinID | int | yes | If a positive value was transferred, the method will return only messages with IDs more than min_id |
Hash | int64 | yes | Result hash |
Returns
Possible errors
| Code | Type | Description |
|---|---|---|
| 400 | CHANNEL_INVALID | The provided channel is invalid. |
| 406 | CHANNEL_PRIVATE | You haven't joined this channel/supergroup. |
| 400 | CHAT_ID_INVALID | The provided chat id is invalid. |
| 400 | CHAT_NOT_MODIFIED | No changes were made to chat information because the new information you passed is identical to the current information. |
| 400 | FROZEN_PARTICIPANT_MISSING | The current account is frozen, and cannot access the specified peer. |
| 400 | MSG_ID_INVALID | Invalid message ID provided. |
| 500 | NEED_DOC_INVALID | |
| 400 | PEER_ID_INVALID | The provided peer id is invalid. |
| 400 | TAKEOUT_INVALID | The specified takeout ID is invalid. |
| 500 | VOLUME_MOVE_INVALID |
References
- Official documentation
- Generated Go reference
- TL definition:
messages.getHistory#4423e6c5