diff --git a/td.go b/td.go index 7515178..9e86f67 100644 --- a/td.go +++ b/td.go @@ -73,7 +73,6 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) { var msgCount int32 = 0 var msgParsed int32 = 0 var lastParsedID64 int64 = int64(math.MaxInt64) - var loopCount int32 = 1 var lastParsedTime time.Time = time.Now() var chat int64 var m ChatWarsMessage @@ -96,15 +95,13 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) { fmt.Printf("Exporting historic messages for chat %d (%s) ...\n", chat, chatDetails.Title) } - for lastParsedID64 >= 0 && loopCount > 0 { + for lastParsedID64 >= 0 { msgs, err := c.GetChatHistory(chat, lastParsedID64, 0, 33, false) - loopCount = 0 if err != nil { if err.Error() == "timeout" { logOnError(err, "Waiting...") fmt.Printf("Timeout : %d messages retrieved out of %d dating back %s (%d) ...\n", msgCount, msgParsed, lastParsedTime.Format(time.RFC3339), lastParsedID64) time.Sleep(5 * time.Second) - loopCount = 1 } else { logOnError(err, "Cannot get history") lastParsedID64 = -1 @@ -152,7 +149,6 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) { if m.ID64 < lastParsedID64 { lastParsedID64 = msg.ID lastParsedTime = m.Date - loopCount = loopCount + 1 } if msgParsed%1000 == 0 { fmt.Printf("Waiting : %d messages retrieved out of %d dating back %s (%d) ...\n", msgCount, msgParsed, lastParsedTime.Format(time.RFC3339), lastParsedID64)