Return help text if message text is unavailable

This commit is contained in:
Vinoth Kannan 2017-12-06 13:07:45 +05:30
parent 2ca3fb1d21
commit 8168c717a8
1 changed files with 6 additions and 10 deletions

View File

@ -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,
)