From 509e7bc9978135abf4b548258f85997b4353e8e8 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 19 Jul 2017 17:28:36 +0100 Subject: [PATCH] Add telegram slash commands --- config/locales/server.en.yml | 35 +++++++++++++++++-- .../telegram/telegram_command_controller.rb | 5 ++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index e2c496a..5f58b00 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -47,7 +47,6 @@ en: not_found: tag: "The *%{name}* tag cannot be found." category: "The *%{name}* category cannot be found. Available categories: *%{list}*" - help: | *New rule:* `/discourse [watch|follow|mute] [category] [tag:name]` (you must specify a rule type and at least one category or tag) @@ -68,4 +67,36 @@ en: message: |- %{user} posted in %{title} -
%{post_excerpt}
\ No newline at end of file +
%{post_excerpt}
+ + status: + header: | + Rules for this channel + (if multiple rules match a post, the topmost rule is executed) + no_rules: "There are no rules set up for this channel. Run /help for instructions." + rule_string: "%{index}) %{filter} posts in %{category}" + rule_string_tags_suffix: " with tags: %{tags}" + parse_error: "Sorry, I didn't understand that. Run /help for instructions." + create: + created: "Rule created successfully" + updated: "Rule updated successfully" + error: "Sorry, an error occured while creating that rule." + delete: + success: "Rule deleted successfully" + error: "Sorry, an error occured while deleting that rule. Run /status for a list of rules." + not_found: + tag: "The %{name} tag cannot be found." + category: "The %{name} category cannot be found. Available categories: %{list}" + help: | + New rule: /[watch|follow|mute] [category] [tag:name] + (you must specify a rule type and at least one category or tag) + - watch – notify this channel for new topics and new replies + - follow – notify this channel for new topics + - mute – block notifications to this channel + + Remove rule: /remove [rule number] + ([rule number] can be found by running /status) + + List rules: /status + + Help: /help \ No newline at end of file diff --git a/lib/discourse_chat/provider/telegram/telegram_command_controller.rb b/lib/discourse_chat/provider/telegram/telegram_command_controller.rb index 2df2195..f3aba2f 100644 --- a/lib/discourse_chat/provider/telegram/telegram_command_controller.rb +++ b/lib/discourse_chat/provider/telegram/telegram_command_controller.rb @@ -62,10 +62,9 @@ module DiscourseChat::Provider::TelegramProvider tokens = message['text'].split(" ") - return "I don't understand how to do that yet" - - + tokens[0][0] = '' # Remove the slash from the first token + return ::DiscourseChat::Helper.process_command(channel, tokens) end def telegram_token_valid?