chirpnest/client.go

43 lines
920 B
Go
Raw Normal View History

2019-05-30 06:12:01 +02:00
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
2019-05-30 06:15:09 +02:00
if cacheObjGuild[``].ObjID64 != guildID64 && strings.Compare(c.Role, ``) == 0 {
2019-05-30 06:12:01 +02:00
clientSendCWMsg(userID64, "/g_roles")
}
}
} else {
c := ChatWarsClient{
GuildID64: guildID64,
State: state,
LastUpdate: timestamp,
}
clientsCW[userID64] = &c
2019-05-30 06:15:09 +02:00
if cacheObjGuild[``].ObjID64 != guildID64 {
2019-05-30 06:12:01 +02:00
clientSendCWMsg(userID64, "/g_roles")
}
}
}
}