revert mistakeremove loop
This commit is contained in:
parent
8300d53ae2
commit
70d026c2e1
6
td.go
6
td.go
@ -73,7 +73,6 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) {
|
|||||||
var msgCount int32 = 0
|
var msgCount int32 = 0
|
||||||
var msgParsed int32 = 0
|
var msgParsed int32 = 0
|
||||||
var lastParsedID64 int64 = int64(math.MaxInt64)
|
var lastParsedID64 int64 = int64(math.MaxInt64)
|
||||||
var loopCount int32 = 1
|
|
||||||
var lastParsedTime time.Time = time.Now()
|
var lastParsedTime time.Time = time.Now()
|
||||||
var chat int64
|
var chat int64
|
||||||
var m ChatWarsMessage
|
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)
|
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)
|
msgs, err := c.GetChatHistory(chat, lastParsedID64, 0, 33, false)
|
||||||
loopCount = 0
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Error() == "timeout" {
|
if err.Error() == "timeout" {
|
||||||
logOnError(err, "Waiting...")
|
logOnError(err, "Waiting...")
|
||||||
fmt.Printf("Timeout : %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)
|
time.Sleep(5 * time.Second)
|
||||||
loopCount = 1
|
|
||||||
} else {
|
} else {
|
||||||
logOnError(err, "Cannot get history")
|
logOnError(err, "Cannot get history")
|
||||||
lastParsedID64 = -1
|
lastParsedID64 = -1
|
||||||
@ -152,7 +149,6 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) {
|
|||||||
if m.ID64 < lastParsedID64 {
|
if m.ID64 < lastParsedID64 {
|
||||||
lastParsedID64 = msg.ID
|
lastParsedID64 = msg.ID
|
||||||
lastParsedTime = m.Date
|
lastParsedTime = m.Date
|
||||||
loopCount = loopCount + 1
|
|
||||||
}
|
}
|
||||||
if msgParsed%1000 == 0 {
|
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)
|
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