diff --git a/td.go b/td.go index 9e86f67..e086b82 100644 --- a/td.go +++ b/td.go @@ -96,6 +96,7 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) { } for lastParsedID64 >= 0 { + prevLastParsedID64 := lastParsedID64 msgs, err := c.GetChatHistory(chat, lastParsedID64, 0, 33, false) if err != nil { if err.Error() == "timeout" { @@ -158,6 +159,10 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) { } else { lastParsedID64 = -1 } + if prevLastParsedID64 == lastParsedID64 { + // we should be at the end ! + lastParsedID64 = -1 + } } log.Printf("Exported %d messages.\n", msgCount) fmt.Printf("Exported %d messages.\n", msgCount)