diff --git a/slack-mathbot/commands/calculate.rb b/slack-mathbot/commands/calculate.rb index d39aaea..0168a80 100644 --- a/slack-mathbot/commands/calculate.rb +++ b/slack-mathbot/commands/calculate.rb @@ -5,7 +5,6 @@ module SlackMathbot command 'calculate' def self.call(client, data, match) - send_message client, data.channel, match result = Dentaku::Calculator.new.evaluate(match[:expression]) if match.names.include?('expression') result = result.to_s if result if result && result.length > 0 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 diff --git a/slack-mathbot/commands/test.rb b/slack-mathbot/commands/test.rb deleted file mode 100644 index 6ca4e0b..0000000 --- a/slack-mathbot/commands/test.rb +++ /dev/null @@ -1,21 +0,0 @@ -module SlackMathbot - module Commands - class Test < SlackRubyBot::Commands::Base - operator ']' - command 'test' - - def self.call(client, data, match) - send_message client, data.channel, match - result = Dentaku::Calculator.new.evaluate(match[:expression]) if match.names.include?('expression') - result = result.to_s if result - if result && result.length > 0 - send_message client, data.channel, result - else - send_message client, data.channel, 'Got nothing.' - end - rescue StandardError => e - send_message client, data.channel, "Sorry, #{e.message}." - end - end - end -end