From 5dc1275c716d88c5f0cf6c627513e0256e10d9c7 Mon Sep 17 00:00:00 2001 From: shoopea Date: Fri, 3 May 2019 19:01:50 +0800 Subject: [PATCH] upd --- td.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)