debian-mirror-gitlab/lib/gitlab/slash_commands/presenters/help.rb

28 lines
755 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
module Gitlab
2017-09-10 17:25:29 +05:30
module SlashCommands
2017-08-17 22:00:37 +05:30
module Presenters
class Help < Presenters::Base
def present(trigger, text)
ephemeral_response(text: help_message(trigger, text))
end
private
def help_message(trigger, text)
return "No commands available :thinking_face:" unless @resource.present?
if text.start_with?('help')
header_with_list("Available commands", full_commands(trigger))
else
2018-03-17 18:26:18 +05:30
header_with_list("Unknown command, these commands are available", full_commands(trigger))
2017-08-17 22:00:37 +05:30
end
end
def full_commands(trigger)
@resource.map { |command| "#{trigger} #{command.help_message}" }
end
end
end
end
end