From 42e5fb878576be3d52dba436f4218c8901d0b81f Mon Sep 17 00:00:00 2001 From: shoopea Date: Wed, 5 Feb 2020 11:28:34 +0800 Subject: [PATCH] create clientcallback func --- client.go | 13 +++++++++++++ def.go | 3 +++ workers.go | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 2f1f8b5..18c8b8e 100644 --- a/client.go +++ b/client.go @@ -231,6 +231,19 @@ func clientRefreshCWMsg(userID64 int64, chatID64 int64, msgID64 int64) { MQTGCmdQueue <- c } +func clientCallbackDelay(userID64 int64, msgID64 int64, chatID64 int64, name string, data []byte, d time.Duration) { + c := TGCommand{ + Type: commandCallback, + FromUserID64: userID64, + FromChatID64: chatID64, + FromMsgID64: msgID64, + Delay: d, + CallbackName: name, + CallbackData: data, + } + MQTGCmdQueue <- c +} + func clientMsgMeAck(m *ChatWarsMessageMeAck) { if clt, ok := getLockedClient(m.Msg.TGUserID64, false); ok { if clt.Active { diff --git a/def.go b/def.go index 9b1ea3f..1b99f62 100644 --- a/def.go +++ b/def.go @@ -108,6 +108,8 @@ type TGCommand struct { Document tb.Document `json:"document"` ParseMode int64 `json:"parse_mode"` Delay time.Duration `json:"delay"` + CallbackName string `json:"callback_name"` + CallbackData []byte `json:"callback_data"` } type ChatWarsCastle struct { @@ -541,6 +543,7 @@ const ( commandDeleteMsg = 4 commandRefreshMsg = 5 commandSendDocument = 6 + commandCallback = 7 cmdParseModePlain = 1 cmdParseModeMarkDown = 2 diff --git a/workers.go b/workers.go index b6c9b99..b740268 100644 --- a/workers.go +++ b/workers.go @@ -317,7 +317,7 @@ func SQLCWMsgWorker(id int, msgs <-chan ChatWarsMessage, objIds chan<- int64) { for _, c := range m.Callbacks { log.Printf("SQLCWMsgWorker[%d] (%d) : Callback : %s : %s\n", id, m.ID64, c.Name, string(c.Data)) if c.Name == `📯Arena` { - log.Printf("SQLCWMsgWorker[%d] (%d) : Callback : Arena spotted\n") + log.Printf("SQLCWMsgWorker[%d] (%d) : Callback : Arena spotted\n", id, m.ID64) } } }