This commit is contained in:
shoopea 2019-11-05 10:43:06 +08:00
parent 8eadfe3353
commit da40b74b6c
2 changed files with 4 additions and 2 deletions

View File

@ -107,6 +107,9 @@ func main() {
ownUserID32 = OwnUserID(client) ownUserID32 = OwnUserID(client)
ownUserID64 = int64(OwnUserID(client)) ownUserID64 = int64(OwnUserID(client))
lastChatTDMsg = make(map[int64]time.Time)
lastChatTDMsgMux = make(map[int64]*sync.Mutex)
MQCWMsgQueue = make(chan ChatWarsMessage, 100) MQCWMsgQueue = make(chan ChatWarsMessage, 100)
for w := 1; w <= 3; w++ { for w := 1; w <= 3; w++ {
go MQSendMsgWorker(w, MQCWMsgQueue) go MQSendMsgWorker(w, MQCWMsgQueue)

3
td.go
View File

@ -75,8 +75,7 @@ func ListenTG(c *tdlib.Client) {
lastChatMsgMux.RUnlock() lastChatMsgMux.RUnlock()
lastChatMsgMux.Lock() lastChatMsgMux.Lock()
if _, ok := lastChatTDMsg[m.ChatID64]; !ok { if _, ok := lastChatTDMsg[m.ChatID64]; !ok {
initTime := time.Now().Add(-1 * time.Second) lastChatTDMsg[m.ChatID64] = time.Now().Add(-1 * time.Second)
lastChatTDMsg[m.ChatID64] = initTime
lastChatTDMsgMux[m.ChatID64] = new(sync.Mutex) lastChatTDMsgMux[m.ChatID64] = new(sync.Mutex)
} }
lastChatMsgMux.Unlock() lastChatMsgMux.Unlock()