From 8168c717a8bebd1f7ab1298aa0a12c384ab511b8 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Wed, 6 Dec 2017 13:07:45 +0530 Subject: [PATCH] Return help text if message text is unavailable --- .../telegram/telegram_command_controller.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/discourse_chat/provider/telegram/telegram_command_controller.rb b/lib/discourse_chat/provider/telegram/telegram_command_controller.rb index 2d7a5db..7fb41de 100644 --- a/lib/discourse_chat/provider/telegram/telegram_command_controller.rb +++ b/lib/discourse_chat/provider/telegram/telegram_command_controller.rb @@ -60,18 +60,14 @@ module DiscourseChat::Provider::TelegramProvider channel = DiscourseChat::Channel.with_provider(provider).with_data_value('chat_id', chat_id).first - if channel.nil? - return I18n.t( - "chat_integration.provider.telegram.unknown_chat", - site_title: CGI::escapeHTML(SiteSetting.title), - chat_id: chat_id, - ) - end - + text_key = "unknown_chat" if channel.nil? # If slash commands disabled, send a generic message - if !SiteSetting.chat_integration_telegram_enable_slash_commands + text_key = "known_chat" if !SiteSetting.chat_integration_telegram_enable_slash_commands + text_key = "help" if message['text'].blank? + + if text_key.present? return I18n.t( - "chat_integration.provider.telegram.known_chat", + "chat_integration.provider.telegram.#{text_key}", site_title: CGI::escapeHTML(SiteSetting.title), chat_id: chat_id, )