Added SentFrom method to Update type
parent
54104a08f9
commit
2df616ce04
23
types.go
23
types.go
|
@ -76,6 +76,29 @@ type Update struct {
|
||||||
PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"`
|
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.
|
// UpdatesChannel is the channel for getting updates.
|
||||||
type UpdatesChannel <-chan Update
|
type UpdatesChannel <-chan Update
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue