test
This commit is contained in:
parent
c33c3ba90f
commit
bc218d176f
18
td.go
18
td.go
@ -68,10 +68,9 @@ func ListenCW(c *tdlib.Client) {
|
||||
}
|
||||
|
||||
func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) {
|
||||
var lastMsgID64 int64 = int64(math.MaxInt64)
|
||||
var msgCount int32 = 0
|
||||
var msgParsed int32 = 0
|
||||
var lastMsgTime time.Time = time.Now()
|
||||
var lastParsedID64 int64 = int64(math.MaxInt64)
|
||||
var lastParsedTime time.Time = time.Now()
|
||||
var chat int64
|
||||
var m ChatWarsMessage
|
||||
@ -84,8 +83,8 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) {
|
||||
|
||||
fmt.Printf("Exporting historic messages for chat %d from user %d ...\n", chat, *senderUserID64)
|
||||
|
||||
for lastMsgID64 >= 0 {
|
||||
msgs, err := c.GetChatHistory(chat, lastMsgID64, 0, 10, false)
|
||||
for lastParsedID64 >= 0 {
|
||||
msgs, err := c.GetChatHistory(chat, lastParsedID64, 0, 10, false)
|
||||
if err != nil {
|
||||
if err.Error() == "timeout" {
|
||||
logOnError(err, "Waiting...")
|
||||
@ -127,23 +126,22 @@ func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) {
|
||||
|
||||
if m.ID64 != 0 && (*senderUserID64 == 0 || m.SenderUserID64 == *senderUserID64) {
|
||||
MQCWMsgQueue <- m
|
||||
|
||||
if m.ID64 < lastMsgID64 {
|
||||
lastMsgID64 = m.ID64
|
||||
lastMsgTime = time.Unix(int64(m.Date), 0)
|
||||
}
|
||||
msgCount = msgCount + 1
|
||||
}
|
||||
default:
|
||||
log.Printf("getHistory : no handler for %s\n", msg.Content.GetMessageContentEnum())
|
||||
}
|
||||
if m.ID64 < lastParsedID64 {
|
||||
lastParsedID64 = msg.ID
|
||||
lastParsedTime = time.Unix(int64(m.Date), 0)
|
||||
}
|
||||
if msgParsed%1000 == 0 {
|
||||
fmt.Printf("Waiting : %d messages retrieved from %s ...\n", msgParsed, lastParsedTime.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
lastMsgID64 = -1
|
||||
lastParsedID64 = -1
|
||||
}
|
||||
}
|
||||
log.Printf("Exported %d messages.\n", msgCount)
|
||||
|
Loading…
Reference in New Issue
Block a user