-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module SlackRubyBot | ||
module Commands | ||
class Commands < Base | ||
BUILTIN_COMMAND_CLASSES = [SlackRubyBot::Commands::Help, SlackRubyBot::Commands::Hi].freeze | ||
|
||
class << self | ||
def call(client, data, _match) | ||
commands = (BUILTIN_COMMAND_CLASSES + external_command_classes).map { |c| c.routes.keys }.flatten | ||
client.say(channel: data.channel, text: "*Possible commands:*\n#{commands.join("\n")}") | ||
end | ||
|
||
private | ||
|
||
def command_classes | ||
SlackRubyBot::Commands::Base.descendants | ||
end | ||
|
||
def external_command_classes | ||
command_classes.reject do |k| | ||
k.name && k.name.start_with?('SlackRubyBot::Commands') || k == SlackRubyBot::Bot | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |