diff --git a/td.go b/td.go index 0bbfc24..e436088 100644 --- a/td.go +++ b/td.go @@ -111,6 +111,8 @@ func getHistory(c *tdlib.Client) { var lastMsgID64 int64 = int64(math.MaxInt64) var msgCount int32 = 0 + fmt.Printf("Retrieving chat.\n", msgCount) + conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.Queue) if err != nil { log.Fatal(err) @@ -145,7 +147,7 @@ func getHistory(c *tdlib.Client) { logOnError(err, "Cannot get history") lastMsgID64 = -1 } - } else { + } else if msgs.TotalCount > 0 { for _, msg := range msgs.Messages { switch msg.Content.GetMessageContentEnum() { case tdlib.MessageTextType: @@ -180,6 +182,8 @@ func getHistory(c *tdlib.Client) { log.Printf("getHistory : no handler for %s\n", msg.Content.GetMessageContentEnum()) } } + } else { + lastMsgID64 = -1 } } log.Printf("Exported %d messages.\n", msgCount)