test callback

This commit is contained in:
shoopea 2020-02-05 11:45:55 +08:00
parent 64e4921a96
commit 70ea651bd1
2 changed files with 12 additions and 1 deletions

3
def.go
View File

@ -17,6 +17,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 ChatWarsCallback struct { type ChatWarsCallback struct {
@ -50,6 +52,7 @@ const (
commandDeleteMsg = 4 commandDeleteMsg = 4
commandRefreshMsg = 5 commandRefreshMsg = 5
commandSendDocument = 6 commandSendDocument = 6
commandCallback = 7
cmdParseModePlain = 1 cmdParseModePlain = 1
cmdParseModeMarkDown = 2 cmdParseModeMarkDown = 2

10
td.go
View File

@ -295,8 +295,16 @@ func clientMsg(c *tdlib.Client, m TGCommand) {
MQCWMsgQueue <- r MQCWMsgQueue <- r
} }
case commandCallback:
p := CallbackQueryPayloadData{
Data: m.CallbackData,
}
a, err := c.GetCallbackQueryAnswer(m.FromChatID64, m.FromMsgID64, p)
logOnError(err, "clientMsg : GetCallbackQueryAnswer")
b, _ := json.Marshal(a)
log.Printf("GetCallbackQueryAnswer :\n%s\n", string(b))
default: default:
log.Printf("ListenMQ : No handler for command %d.\n", m.Type) log.Printf("clientMsg : No handler for command %d.\n", m.Type)
} }
} }