1
0

Added poll utils

This commit is contained in:
Maxim Lebedev 2019-08-09 12:23:21 +05:00
parent df9a37c6bd
commit 52ea28b0c7
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
2 changed files with 13 additions and 4 deletions

View File

@ -190,6 +190,7 @@ const (
UpdateEditedMessage string = "edited_message" UpdateEditedMessage string = "edited_message"
UpdateInlineQuery string = "inline_query" UpdateInlineQuery string = "inline_query"
UpdateMessage string = "message" UpdateMessage string = "message"
UpdatePoll string = "poll"
UpdatePreCheckoutQuery string = "pre_checkout_query" UpdatePreCheckoutQuery string = "pre_checkout_query"
UpdateShippingQuery string = "shipping_query" UpdateShippingQuery string = "shipping_query"
) )

View File

@ -1860,6 +1860,11 @@ func (m *Message) IsSuccessfulPayment() bool {
return m != nil && m.SuccessfulPayment != nil return m != nil && m.SuccessfulPayment != nil
} }
// IsPoll checks that the current message is a poll.
func (m *Message) IsPoll() bool {
return m != nil && m.Poll != nil
}
// HasEntities checks that the current message contains entities. // HasEntities checks that the current message contains entities.
func (m *Message) HasEntities() bool { func (m *Message) HasEntities() bool {
return m != nil && len(m.Entities) > 0 return m != nil && len(m.Entities) > 0
@ -1991,10 +1996,6 @@ func (m *Message) SmallChatPhoto() *PhotoSize {
return &sp[0] return &sp[0]
} }
func (m *Message) HasPoll() bool {
return m != nil && m.Poll != nil
}
func decrypt(pk *rsa.PrivateKey, s, h, d string) (obj []byte, err error) { func decrypt(pk *rsa.PrivateKey, s, h, d string) (obj []byte, err error) {
// Note that all base64-encoded fields should be decoded before use. // Note that all base64-encoded fields should be decoded before use.
secret, err := decodeField(s) secret, err := decodeField(s)
@ -2581,6 +2582,11 @@ func (u *Update) IsPreCheckoutQuery() bool {
return u != nil && u.PreCheckoutQuery != nil return u != nil && u.PreCheckoutQuery != nil
} }
// IsPoll checks that the current update is a poll update.
func (u *Update) IsPoll() bool {
return u != nil && u.Poll != nil
}
// Type return update type for current update. // Type return update type for current update.
func (u *Update) Type() string { func (u *Update) Type() string {
switch { switch {
@ -2602,6 +2608,8 @@ func (u *Update) Type() string {
return UpdatePreCheckoutQuery return UpdatePreCheckoutQuery
case u.IsShippingQuery(): case u.IsShippingQuery():
return UpdateShippingQuery return UpdateShippingQuery
case u.IsPoll():
return UpdatePoll
default: default:
return "" return ""
} }