diff --git a/def.go b/def.go index 4605dba..f08aa83 100644 --- a/def.go +++ b/def.go @@ -21,6 +21,14 @@ type MQClient struct { Queue amqp.Queue } +type ChatWarsClient struct { + UserID64 int64 `json:"user_id"` + GuildID64 int64 `json:"guild_id"` + Role string `json:"role"` + State string `json:"state"` + BusyUntil time.Time `json:"busy_until"` +} + type TGCommand struct { Type int64 `json:"type"` FromChatID64 int64 `json:"from_chat_id"` diff --git a/main.go b/main.go index 01a702c..626f0f4 100644 --- a/main.go +++ b/main.go @@ -52,6 +52,7 @@ var ( msgParsingRules map[int]MessageParsingRule clientsKeepAlive map[int64]*MQKeepAlive clientsQueue map[int64]*MQClient + clientsCW map[int64]*ChatWarsClient ) func PrintText(m *tb.Message) { @@ -125,6 +126,7 @@ func main() { MQTGCmdQueue = make(chan TGCommand, MQTGCmdQueueSize) clientsQueue = make(map[int64]*MQClient) clientsKeepAlive = make(map[int64]*MQKeepAlive) + clientsProfile = make(map[int64]*ChatWarsClient) for w := 1; w <= MQGetMsgWorkers; w++ { go MQGetMsgWorker(w, MQCWMsgQueue) diff --git a/workers.go b/workers.go index 706d926..0eb202a 100644 --- a/workers.go +++ b/workers.go @@ -385,7 +385,7 @@ func MQKeepAliveWorker() { logOnError(err, "MQKeepAliveWorker : Can't unmarshal.\n"+string(d.Body)) if err == nil { if x.Date.Add(time.Minute).Before(time.Now()) { - // outdate keep-alive + // outdated keep-alive } else if _, ok := clientsKeepAlive[x.UserID64]; ok { clientsKeepAlive[x.UserID64].Date = x.Date } else { @@ -419,6 +419,21 @@ func MQKeepAliveWorker() { } TGCmdQueue <- c + c = TGCommand{ + Type: commandSendMsg, + FromUserID64: x.UserID64, + ToChatID64: userID64ChtWrsBot, + Text: `🏅Me`, + } + MQTGCmdQueue <- c + c = TGCommand{ + Type: commandSendMsg, + FromUserID64: x.UserID64, + ToChatID64: userID64ChtWrsBot, + Text: `/hero`, + } + MQTGCmdQueue <- c + } } }