create clientcallback func

This commit is contained in:
shoopea 2020-02-05 11:28:34 +08:00
parent b1431e9769
commit 42e5fb8785
3 changed files with 17 additions and 1 deletions

View File

@ -231,6 +231,19 @@ func clientRefreshCWMsg(userID64 int64, chatID64 int64, msgID64 int64) {
MQTGCmdQueue <- c 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) { func clientMsgMeAck(m *ChatWarsMessageMeAck) {
if clt, ok := getLockedClient(m.Msg.TGUserID64, false); ok { if clt, ok := getLockedClient(m.Msg.TGUserID64, false); ok {
if clt.Active { if clt.Active {

3
def.go
View File

@ -108,6 +108,8 @@ type TGCommand struct {
Document tb.Document `json:"document"` Document tb.Document `json:"document"`
ParseMode int64 `json:"parse_mode"` ParseMode int64 `json:"parse_mode"`
Delay time.Duration `json:"delay"` Delay time.Duration `json:"delay"`
CallbackName string `json:"callback_name"`
CallbackData []byte `json:"callback_data"`
} }
type ChatWarsCastle struct { type ChatWarsCastle struct {
@ -541,6 +543,7 @@ const (
commandDeleteMsg = 4 commandDeleteMsg = 4
commandRefreshMsg = 5 commandRefreshMsg = 5
commandSendDocument = 6 commandSendDocument = 6
commandCallback = 7
cmdParseModePlain = 1 cmdParseModePlain = 1
cmdParseModeMarkDown = 2 cmdParseModeMarkDown = 2

View File

@ -317,7 +317,7 @@ func SQLCWMsgWorker(id int, msgs <-chan ChatWarsMessage, objIds chan<- int64) {
for _, c := range m.Callbacks { for _, c := range m.Callbacks {
log.Printf("SQLCWMsgWorker[%d] (%d) : Callback : %s : %s\n", id, m.ID64, c.Name, string(c.Data)) log.Printf("SQLCWMsgWorker[%d] (%d) : Callback : %s : %s\n", id, m.ID64, c.Name, string(c.Data))
if c.Name == `📯Arena` { 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)
} }
} }
} }