Browse Source

Testing... Well, test

master
Daniel Muckerman 9 years ago
parent
commit
c148fc9b9e
3 changed files with 23 additions and 1 deletions
  1. +1
    -1
      Gemfile
  2. +1
    -0
      slack-mathbot/commands.rb
  3. +21
    -0
      slack-mathbot/commands/test.rb

+ 1
- 1
Gemfile View File

@ -1,6 +1,6 @@
source 'http://rubygems.org'
ruby '2.2.0'
ruby '2.2.3'
gem 'slack-ruby-bot'
gem 'puma'

+ 1
- 0
slack-mathbot/commands.rb View File

@ -1,3 +1,4 @@
require 'slack-mathbot/commands/calculate'
require 'slack-mathbot/commands/about'
require 'slack-mathbot/commands/help'
require 'slack-mathbot/commands/test'

+ 21
- 0
slack-mathbot/commands/test.rb View File

@ -0,0 +1,21 @@
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

Loading…
Cancel
Save