test
This commit is contained in:
parent
7f980e16bb
commit
f66a73f5f7
8
td.go
8
td.go
@ -73,6 +73,7 @@ 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
|
||||
@ -95,13 +96,15 @@ 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 {
|
||||
for lastParsedID64 >= 0 && loopCount > 0 {
|
||||
msgs, err := c.GetChatHistory(chat, lastParsedID64, 0, 33, false)
|
||||
loopCount = 0
|
||||
if err != nil {
|
||||
if err.Error() == "timeout" {
|
||||
logOnError(err, "Waiting...")
|
||||
fmt.Printf("Waiting : %d messages retrieved out of %d dating back %s (%d) ...\n", msgCount, msgParsed, lastParsedTime.Format(time.RFC3339), lastParsedID64)
|
||||
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
|
||||
@ -149,6 +152,7 @@ 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)
|
||||
|
Loading…
Reference in New Issue
Block a user