This commit is contained in:
shoopea 2019-06-28 19:04:08 +08:00
parent 6885975ea0
commit eb1de66c07

35
bot.go
View File

@ -38,6 +38,8 @@ func BotHandlers(b *tb.Bot) {
b.Handle("/help", botHelp)
b.Handle("/get_item_id", botGetItemId)
b.Handle(tb.OnPhoto, botPhoto)
b.Handle(tb.OnChannelPost, botChannelPost)
b.Handle(tb.OnQuery, botQuery)
@ -468,3 +470,36 @@ func botTimer(m *tb.Message) {
return
}
func botGetItemId(m *tb.Message) {
if len(m.Payload) > 0 {
objItemID64 := getObjItemID(``, m.Payload)
if objItemID64 != 0 {
c := TGCommand{
Type: commandReplyMsg,
Text: fmt.Sprintf("Identified item #%d", objItemID64),
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
} else {
c := TGCommand{
Type: commandReplyMsg,
Text: "Can''t identify item",
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
}
} else {
c := TGCommand{
Type: commandReplyMsg,
Text: "No item name to identify",
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
}
return
}