aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-06 12:27:25 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-01-06 12:27:25 +0300
commit570601d1b8aaaa82b4e618d84a9a95095ed5791a (patch)
treeb9fd1b9cde9eabb7df71edee52470bca57fa6247
parent077edae986f2229d263f978b7cf35ed88254c042 (diff)
Fix retrieving only 1 message in /history
-rw-r--r--telegram/commands.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/telegram/commands.go b/telegram/commands.go
index 82dca91..56945bc 100644
--- a/telegram/commands.go
+++ b/telegram/commands.go
@@ -676,12 +676,21 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
}
- messages, err := c.client.GetChatHistory(&client.GetChatHistoryRequest{
- ChatID: chatID,
- Limit: limit,
- })
- if err != nil {
- return err.Error(), true
+ var messages *client.Messages
+ var err error
+ for _ = range make([]struct{}, 2) {
+ messages, err = c.client.GetChatHistory(&client.GetChatHistoryRequest{
+ ChatID: chatID,
+ 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)