Added SentFrom method to Update type
quenbyako rcooper.xelaj@protonmail.com
Tue, 02 Feb 2021 14:56:51 +0300
1 files changed,
23 insertions(+),
0 deletions(-)
jump to
M
types.go
→
types.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