From 05d4338a125606303c4e62121f10d8102975d4bf Mon Sep 17 00:00:00 2001 From: Saj Goonatilleke Date: Wed, 20 Nov 2019 21:45:34 +1100 Subject: [PATCH] FIX: telegram: Not all channel posts contain text (#34) The `text` field is marked optional, and is not guaranteed to exist: https://core.telegram.org/bots/api#message We should silently ignore these actions (while responding with a positive acknowledgement) instead of throwing a `NoMethodError`. --- .../provider/telegram/telegram_command_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/discourse_chat/provider/telegram/telegram_command_controller.rb b/lib/discourse_chat/provider/telegram/telegram_command_controller.rb index 27b5344..96c31d3 100644 --- a/lib/discourse_chat/provider/telegram/telegram_command_controller.rb +++ b/lib/discourse_chat/provider/telegram/telegram_command_controller.rb @@ -29,7 +29,7 @@ module DiscourseChat::Provider::TelegramProvider DiscourseChat::Provider::TelegramProvider.sendMessage(message) - elsif params.key?('channel_post') && params['channel_post']['text'].include?('/getchatid') + elsif params.dig('channel_post', 'text')&.include?('/getchatid') chat_id = params['channel_post']['chat']['id'] message_text = I18n.t(