Browse Source

Remove the monkey-patch for supporting operators.

master
dblock 9 years ago
parent
commit
59e3b1d6c5
4 changed files with 22 additions and 40 deletions
  1. +20
    -20
      Gemfile.lock
  2. +0
    -1
      slack-mathbot.rb
  3. +2
    -0
      slack-mathbot/commands/calculate.rb
  4. +0
    -19
      slack-mathbot/hooks/message.rb

+ 20
- 20
Gemfile.lock View File

@ -1,6 +1,6 @@
GIT
remote: git://github.com/dblock/slack-ruby-bot.git
revision: fa17932abf5ad0c5d25c652f4a46cec1d93a99d4
revision: 8385892c5ff6b7860435ca4b1f46017bb45175db
specs:
slack-ruby-bot (0.2.0)
activesupport
@ -28,7 +28,7 @@ GEM
eventmachine (1.0.7)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.9.1)
faraday_middleware (0.9.2)
faraday (>= 0.7.4, < 0.10)
faraday_middleware-parse_oj (0.3.0)
faraday (~> 0.9.0)
@ -50,34 +50,34 @@ GEM
launchy (2.4.3)
addressable (~> 2.3)
minitest (5.7.0)
multi_json (1.11.1)
multi_json (1.11.2)
multipart-post (2.0.0)
oj (2.12.9)
parser (2.3.0.pre.2)
ast (>= 1.1, < 3.0)
powerpack (0.1.1)
puma (2.11.0)
puma (2.11.3)
rack (>= 1.1, < 2.0)
rack (1.6.0)
rack (1.6.4)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rainbow (2.0.0)
rake (10.4.2)
rspec (3.2.0)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.3)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.1)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.1)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.1)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
rubocop (0.31.0)
astrolabe (~> 1.3)
parser (>= 2.2.2.1, < 3.0)
@ -86,10 +86,10 @@ GEM
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.5)
safe_yaml (1.0.4)
sinatra (1.4.5)
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
tilt (>= 1.3, < 3)
slack-api (1.1.6)
faraday (>= 0.7, < 0.10)
faraday_middleware (~> 0.8)
@ -97,14 +97,14 @@ GEM
multi_json (~> 1.0, >= 1.0.3)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
tilt (2.0.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
vcr (2.9.3)
webmock (1.21.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
websocket-driver (0.5.4)
websocket-driver (0.6.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)

+ 0
- 1
slack-mathbot.rb View File

@ -1,6 +1,5 @@
require 'slack-ruby-bot'
require 'slack-mathbot/version'
require 'slack-mathbot/about'
require 'slack-mathbot/hooks/message'
require 'slack-mathbot/commands'
require 'slack-mathbot/app'

+ 2
- 0
slack-mathbot/commands/calculate.rb View File

@ -1,6 +1,8 @@
module SlackMathbot
module Commands
class Calculate < SlackRubyBot::Commands::Base
operator '='
def self.call(data, _command, arguments)
result = Dentaku::Calculator.new.evaluate(arguments.join)
result = result.to_s if result

+ 0
- 19
slack-mathbot/hooks/message.rb View File

@ -1,19 +0,0 @@
module SlackRubyBot
module Hooks
module Message
private
# TODO: remove monkey-patch
def parse_command(text)
return unless text
text = '= ' + text[1..text.length] if text[0] == '='
parts = text.split.reject(&:blank?)
if parts && parts[0] == '='
parts[0] = SlackRubyBot.config.user
parts.insert 1, 'calculate'
end
[parts.first.downcase, parts[1].try(:downcase), parts[2..parts.length]] if parts && parts.any?
end
end
end
end

Loading…
Cancel
Save