atipugin / telegram-bot-ruby

Ruby wrapper for Telegram's Bot API
https://core.telegram.org/bots/api
Do What The F*ck You Want To Public License
1.35k stars 218 forks source link

Bot throws an exception on message.chat.type when message is a poll #203

Closed ferdi2005 closed 5 years ago

ferdi2005 commented 5 years ago

It should return chat type as usual, but it throws an exception if I use method .chat.type on message when it's a poll. (Workaround: using message.respond_to? :type && message.chat.type == 'private') Error performing GetUpdatesFromBotJob (Job ID: 9cf9f15f-928c-45ea-926e-378074cc52b8) from Sidekiq(default) in 343.81ms: NoMethodError (undefined method 'chat' for #<Telegram::Bot::Types::Poll:0x00007fc111dc28d0>):

atipugin commented 5 years ago

Yes, it's expected, because Poll object doesn't have such attribute. You need to check message type explicitly in your code.

ferdi2005 commented 5 years ago

Why don’t fix this/simplify adding type poll to poll objects? What’s the class in the code?

atipugin commented 5 years ago

Because Chat class implements Chat object from API spec and it's type can be only private, group, supergroup or channel.