chirpnest/client.go

44 lines
953 B
Go
Raw Normal View History

2019-05-30 06:12:01 +02:00
package main
import (
"strings"
)
func clientSendCWMsg(userID64 int64, s string) {
c := TGCommand{
Type: commandSendMsg,
Text: s,
FromUserID64: userID64,
ToChatID64: userID64ChtWrsBot,
}
MQTGCmdQueue <- c
}
2019-05-30 07:50:21 +02:00
func clientMsgMe(m *ChatWarsMessageMeAck) {
2019-05-30 07:49:11 +02:00
if _, ok := clientsQueue[m.UserID64]; ok {
t, err := getObjMsgDate(m.ObjID64)
2019-05-30 07:51:57 +02:00
logOnError(err, "clientMsgMe : getObjMsgDate")
2019-05-30 07:49:11 +02:00
if c, ok := clientsCW[m.UserID64]; ok {
if c.LastUpdate.Before(t) {
c.GuildID64 = m.GuildID64
c.State = m.State
c.LastUpdate = t
if cacheObjGuild[``].ObjID64 != m.GuildID64 && strings.Compare(c.Role, ``) == 0 {
2019-05-30 07:50:21 +02:00
clientSendCWMsg(m.UserID64, "/g_roles")
2019-05-30 06:12:01 +02:00
}
}
} else {
c := ChatWarsClient{
2019-05-30 07:49:11 +02:00
GuildID64: m.GuildID64,
2019-05-30 07:50:21 +02:00
State: m.State,
2019-05-30 07:49:11 +02:00
LastUpdate: t,
2019-05-30 06:12:01 +02:00
}
2019-05-30 07:49:11 +02:00
clientsCW[m.UserID64] = &c
if cacheObjGuild[``].ObjID64 != m.GuildID64 {
clientSendCWMsg(m.UserID64, "/g_roles")
2019-05-30 06:12:01 +02:00
}
}
}
}