1
0
Fork 0

Added Type helper for Update

This commit is contained in:
Maxim Lebedev 2018-04-19 19:58:28 +05:00
parent a09b274952
commit 86a3f2148e
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
1 changed files with 26 additions and 0 deletions

View File

@ -144,3 +144,29 @@ func (upd *Update) IsShippingQuery() bool {
func (upd *Update) IsPreCheckoutQuery() bool {
return upd != nil && upd.PreCheckoutQuery != nil
}
// Type return update type for current update.
func (upd *Update) Type() string {
switch {
case upd.IsCallbackQuery():
return UpdateCallbackQuery
case upd.IsChannelPost():
return UpdateChannelPost
case upd.IsChosenInlineResult():
return UpdateChosenInlineResult
case upd.IsEditedChannelPost():
return UpdateEditedChannelPost
case upd.IsEditedMessage():
return UpdateEditedMessage
case upd.IsInlineQuery():
return UpdateInlineQuery
case upd.IsMessage():
return UpdateMessage
case upd.IsPreCheckoutQuery():
return UpdatePreCheckoutQuery
case upd.IsShippingQuery():
return UpdateShippingQuery
default:
return ""
}
}