Update types.go

bot-api-6.1
Syfaro 2021-11-08 12:37:50 -08:00 committed by GitHub
parent 01e6fd26dd
commit 8806fb3bad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -76,8 +76,8 @@ 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 // SentFrom returns the user who sent an update. Can be nil, if Telegram did not provide information
// update object. // about the user in the update object.
func (u *Update) SentFrom() *User { func (u *Update) SentFrom() *User {
switch { switch {
case u.Message != nil: case u.Message != nil:
@ -99,6 +99,7 @@ func (u *Update) SentFrom() *User {
} }
} }
// CallbackData returns the callback query data, if it exists.
func (u *Update) CallbackData() string { func (u *Update) CallbackData() string {
if u.CallbackQuery != nil { if u.CallbackQuery != nil {
return u.CallbackQuery.Data return u.CallbackQuery.Data
@ -106,6 +107,7 @@ func (u *Update) CallbackData() string {
return "" return ""
} }
// FromChat returns the chat where an update occured.
func (u *Update) FromChat() *Chat { func (u *Update) FromChat() *Chat {
switch { switch {
case u.Message != nil: case u.Message != nil: