-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undefined method 'from' for nil:NilClass #226
Comments
I fixed this by adding |
Hi @TheStu, Logging incoming message is already supported. You can pass a logger implementation as an option like here. |
Sure I've added logging, will update if / when another nil message appears. |
Hi @TheStu, |
Had 3 more of these nil messages in the last 24 hours. From logs, all 3 look like this: If there's anything else you want me to try, happy to do it. |
https://core.telegram.org/bots/api#chatmemberupdated Some examples JSON: {"update_id"=>800341877, "my_chat_member"=>{"chat"=>{"id"=>-1001190057467, "title"=>"Chat Black Clover", "username"=>"Chat_BlackClover", "type"=>"supergroup"}, "from"=>{"id"=>1424079759, "is_bot"=>false, "first_name"=>"ℳ𝒾ℊ𝓊ℯ𝓁", "username"=>"Yami_Sukehiro23", "language_code"=>"es"}, "date"=>1615346331, "old_chat_member"=>{"user"=>{"id"=>666864939, "is_bot"=>true, "first_name"=>"Dankie", "username"=>"dankiebot"}, "status"=>"administrator", "can_be_edited"=>false, "can_manage_chat"=>true, "can_change_info"=>true, "can_delete_messages"=>true, "can_invite_users"=>true, "can_restrict_members"=>true, "can_pin_messages"=>true, "can_promote_members"=>false, "can_manage_voice_chats"=>true, "is_anonymous"=>false}, "new_chat_member"=>{"user"=>{"id"=>666864939, "is_bot"=>true, "first_name"=>"Dankie", "username"=>"dankiebot"}, "status"=>"restricted", "until_date"=>0, "can_send_messages"=>false, "can_send_media_messages"=>false, "can_send_polls"=>false, "can_send_other_messages"=>false, "can_add_web_page_previews"=>false, "can_change_info"=>false, "can_invite_users"=>false, "can_pin_messages"=>false, "is_member"=>true}}} |
INFO -- : {"update_id"=>488112826, "my_chat_member"=>{"chat"=>{"id"=>817383630, "first_name"=>"Shubham", "username"=>"Shubhamp17", "type"=>"private"}, "from"=>{"id"=>817383630, "is_bot"=>false, "first_name"=>"Shubham", "username"=>"Shubhamp17"}, "date"=>1615441774, "old_chat_member"=>{"user"=>{"id"=>1073977886, "is_bot"=>true, "first_name"=>"TradrPro™ Alerts", "username"=>"tradr_pro_alerts_bot"}, "status"=>"member"}, "new_chat_member"=>{"user"=>{"id"=>1073977886, "is_bot"=>true, "first_name"=>"TradrPro™ Alerts", "username"=>"tradr_pro_alerts_bot"}, "status"=>"kicked", "until_date"=>0}}} |
@ldebortoli @TheStu thanks for the examples.
but I think we need to add support for the new fields in I have opened #228 thought I don't have time right now to test it. P.S. |
Great thanks, I've got it running, seems good. I'll update if I see any more nil messages. |
One thing, newly added types / fields don't respond to
|
I suggest you to check message type before doing anything with it, because Telegram::Bot::Client.run(ENV['TELEGRAM_AUTHORIZATION_TOKEN_V2']) do |bot|
bot.listen do |message|
case message
when Telegram::Bot::Types::Message
process_message(message)
when Telegram::Bot::Types::PollAnswer
process_poll_answer(message)
else
bot.logger.info('Not sure what to do with this type of message')
end
end
end |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Started seeing
undefined method 'from' for nil:NilClass
about 12 hours ago. Any message to the bot seems to trigger it. Doesn't correspond to any code changes on our implementation of the bot. It does however seem to correspond to the latest release of the Telegram Bot API (https://core.telegram.org/bots/api#march-9-2021). We're running an implementation of the bot that has the same basic structure as the example in the readme:All calls to
from
are coded like this:message.from.present? ? message.from.first_name : 'Telegram User'
This code has been successfully working for years, basically untouched. Not entirely sure what went wrong. The error would imply that
message
is nil, but to get to any calls tomessage.from
, the call tomessage.text
would have to evaluate to something.Any insights are much appreciated!
The text was updated successfully, but these errors were encountered: