From c50e0d44b8a16945fc6ee5688947753c39b94c5e Mon Sep 17 00:00:00 2001 From: Daniel Muckerman Date: Fri, 9 Oct 2015 17:20:43 -0400 Subject: [PATCH] Changed test to echo. Might actually do a thing now --- slack-mathbot/commands/calculate.rb | 1 - slack-mathbot/commands/echo.rb | 13 +++++++++++++ slack-mathbot/commands/test.rb | 21 --------------------- 3 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 slack-mathbot/commands/echo.rb delete mode 100644 slack-mathbot/commands/test.rb 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