Fix retrieving only 1 message in /history
This commit is contained in:
parent
077edae986
commit
570601d1b8
|
@ -676,12 +676,21 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
messages, err := c.client.GetChatHistory(&client.GetChatHistoryRequest{
|
var messages *client.Messages
|
||||||
ChatID: chatID,
|
var err error
|
||||||
Limit: limit,
|
for _ = range make([]struct{}, 2) {
|
||||||
})
|
messages, err = c.client.GetChatHistory(&client.GetChatHistoryRequest{
|
||||||
if err != nil {
|
ChatID: chatID,
|
||||||
return err.Error(), true
|
Limit: limit,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err.Error(), true
|
||||||
|
}
|
||||||
|
|
||||||
|
// TDlib yields only the latest message on the first request
|
||||||
|
if !(len(messages.Messages) == 1 && limit > 1) {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.sendMessagesReverse(chatID, messages.Messages)
|
c.sendMessagesReverse(chatID, messages.Messages)
|
||||||
|
|
Loading…
Reference in a new issue