diff --git a/bot.go b/bot.go index fb47ed9..214bd4f 100644 --- a/bot.go +++ b/bot.go @@ -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 +}