43 lines
954 B
Go
43 lines
954 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func clientSendCWMsg(userID64 int64, s string) {
|
||
|
c := TGCommand{
|
||
|
Type: commandSendMsg,
|
||
|
Text: s,
|
||
|
FromUserID64: userID64,
|
||
|
ToChatID64: userID64ChtWrsBot,
|
||
|
}
|
||
|
MQTGCmdQueue <- c
|
||
|
}
|
||
|
|
||
|
func clientMsgMe(userID64 int64, guildID64 int64, state string, timestamp time.Time) {
|
||
|
if _, ok := clientsQueue[userID64]; ok {
|
||
|
if c, ok := clientsCW[userID64]; ok {
|
||
|
if c.LastUpdate.Before(timestamp) {
|
||
|
c.GuildID64 = guildID64
|
||
|
c.State = state
|
||
|
c.LastUpdate = timestamp
|
||
|
if strings.Compare(cacheObjGuild[guildID64].Name, ``) != 0 && strings.Compare(c.Role, ``) == 0 {
|
||
|
clientSendCWMsg(userID64, "/g_roles")
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
c := ChatWarsClient{
|
||
|
GuildID64: guildID64,
|
||
|
State: state,
|
||
|
LastUpdate: timestamp,
|
||
|
}
|
||
|
clientsCW[userID64] = &c
|
||
|
if strings.Compare(cacheObjGuild[guildID64].Name, ``) != 0 {
|
||
|
clientSendCWMsg(userID64, "/g_roles")
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|