all repos — telegram-bot-api @ 01e6fd26dd0cb3f3614caa8508cae9f0c6a57d8e

Golang bindings for the Telegram Bot API

Added more methods to Updates
quenbyako rcooper.xelaj@protonmail.com
Tue, 02 Feb 2021 15:38:41 +0300
commit

01e6fd26dd0cb3f3614caa8508cae9f0c6a57d8e

parent

2df616ce0414ab9a93236bfdab274799c6ce3aac

1 files changed, 24 insertions(+), 0 deletions(-)

jump to
M types.gotypes.go

@@ -99,6 +99,30 @@ return nil

} } +func (u *Update) CallbackData() string { + if u.CallbackQuery != nil { + return u.CallbackQuery.Data + } + return "" +} + +func (u *Update) FromChat() *Chat { + switch { + case u.Message != nil: + return u.Message.Chat + case u.EditedMessage != nil: + return u.EditedMessage.Chat + case u.ChannelPost != nil: + return u.ChannelPost.Chat + case u.EditedChannelPost != nil: + return u.EditedChannelPost.Chat + case u.CallbackQuery != nil: + return u.CallbackQuery.Message.Chat + default: + return nil + } +} + // UpdatesChannel is the channel for getting updates. type UpdatesChannel <-chan Update