diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-30 15:51:48 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-16 17:51:07 +0100 |
commit | 0d3e24358b88ce41848c97f3ac37bc813074f260 (patch) | |
tree | e18468c4eb51cbe255b3a7c0eb3317e0526d52f7 /lib | |
parent | ae71032d0af1730c359089f3edc9029a8b5c8acc (diff) | |
download | gitlab-ce-0d3e24358b88ce41848c97f3ac37bc813074f260.tar.gz |
Create Slack Slash command service
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/chat_commands/deploy.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/chat_commands/help.rb | 28 | ||||
-rw-r--r-- | lib/gitlab/chat_commands/presenters/mattermost.rb (renamed from lib/mattermost/presenter.rb) | 0 |
3 files changed, 29 insertions, 1 deletions
diff --git a/lib/gitlab/chat_commands/deploy.rb b/lib/gitlab/chat_commands/deploy.rb index 0eed1fce0dc..6bb854dc080 100644 --- a/lib/gitlab/chat_commands/deploy.rb +++ b/lib/gitlab/chat_commands/deploy.rb @@ -4,7 +4,7 @@ module Gitlab include Gitlab::Routing.url_helpers def self.match(text) - /\Adeploy\s+(?<from>.*)\s+to+\s+(?<to>.*)\z/.match(text) + /\Adeploy\s+(?<from>\S+.*)\s+to+\s+(?<to>\S+.*)\z/.match(text) end def self.help_message diff --git a/lib/gitlab/chat_commands/help.rb b/lib/gitlab/chat_commands/help.rb new file mode 100644 index 00000000000..e76733f5445 --- /dev/null +++ b/lib/gitlab/chat_commands/help.rb @@ -0,0 +1,28 @@ +module Gitlab + module ChatCommands + class Help < BaseCommand + # This class has to be used last, as it always matches. It has to match + # because other commands were not triggered and we want to show the help + # command + def self.match(_text) + true + end + + def self.help_message + 'help' + end + + def self.allowed?(_project, _user) + true + end + + def execute(commands) + Gitlab::ChatCommands::Presenters::Help.new(commands).present(trigger) + end + + def trigger + params[:command] + end + end + end +end diff --git a/lib/mattermost/presenter.rb b/lib/gitlab/chat_commands/presenters/mattermost.rb index 67eda983a74..67eda983a74 100644 --- a/lib/mattermost/presenter.rb +++ b/lib/gitlab/chat_commands/presenters/mattermost.rb |