all repos — telegram-bot-api @ 2df616ce0414ab9a93236bfdab274799c6ce3aac

Golang bindings for the Telegram Bot API

Added SentFrom method to Update type
quenbyako rcooper.xelaj@protonmail.com
Tue, 02 Feb 2021 14:56:51 +0300
commit

2df616ce0414ab9a93236bfdab274799c6ce3aac

parent

54104a08f947e08c460c45d195076e48e61f0a26

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

jump to
M types.gotypes.go

@@ -76,6 +76,29 @@ // optional

PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"` } +// SentFrom return user sender of update. Can be nil, if telegram wont provide info about him in +// update object. +func (u *Update) SentFrom() *User { + switch { + case u.Message != nil: + return u.Message.From + case u.EditedMessage != nil: + return u.EditedMessage.From + case u.InlineQuery != nil: + return u.InlineQuery.From + case u.ChosenInlineResult != nil: + return u.ChosenInlineResult.From + case u.CallbackQuery != nil: + return u.CallbackQuery.From + case u.ShippingQuery != nil: + return u.ShippingQuery.From + case u.PreCheckoutQuery != nil: + return u.PreCheckoutQuery.From + default: + return nil + } +} + // UpdatesChannel is the channel for getting updates. type UpdatesChannel <-chan Update