diff --git a/slack-mathbot/commands.rb b/slack-mathbot/commands.rb index d6975c4..73a2f68 100644 --- a/slack-mathbot/commands.rb +++ b/slack-mathbot/commands.rb @@ -1,4 +1,4 @@ require 'slack-mathbot/commands/calculate' +require 'slack-mathbot/commands/echo' require 'slack-mathbot/commands/about' require 'slack-mathbot/commands/help' -require 'slack-mathbot/commands/echo' diff --git a/slack-mathbot/commands/echo.rb b/slack-mathbot/commands/echo.rb new file mode 100644 index 0000000..acb4f77 --- /dev/null +++ b/slack-mathbot/commands/echo.rb @@ -0,0 +1,13 @@ +module SlackMathbot + module Commands + class Echo < SlackRubyBot::Commands::Base + command 'echo' + + def self.call(client, data, match) + send_message client, data.channel, match[:expression] + rescue StandardError => e + send_message client, data.channel, "Sorry, #{e.message}." + end + end + end +end