Skip to content

Commit

Permalink
Monkey patch to support operator =.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jul 2, 2015
1 parent 365a751 commit 13bde4e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'http://rubygems.org'

ruby '2.1.6'

gem 'slack-ruby-bot'
gem 'slack-ruby-bot', github: 'dblock/slack-ruby-bot'
gem 'puma'
gem 'sinatra'
gem 'dentaku'
Expand Down
17 changes: 11 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
GIT
remote: git://github.com/dblock/slack-ruby-bot.git
revision: fa17932abf5ad0c5d25c652f4a46cec1d93a99d4
specs:
slack-ruby-bot (0.2.0)
activesupport
giphy (~> 2.0.2)
hashie
slack-api (~> 1.1.6)

GEM
remote: http://rubygems.org/
specs:
Expand Down Expand Up @@ -85,11 +95,6 @@ GEM
faraday_middleware (~> 0.8)
faye-websocket (~> 0.9.2)
multi_json (~> 1.0, >= 1.0.3)
slack-ruby-bot (0.1.0)
activesupport
giphy (~> 2.0.2)
hashie
slack-api (~> 1.1.6)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
Expand All @@ -115,6 +120,6 @@ DEPENDENCIES
rspec
rubocop (= 0.31.0)
sinatra
slack-ruby-bot
slack-ruby-bot!
vcr
webmock
1 change: 1 addition & 0 deletions slack-mathbot.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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'
19 changes: 19 additions & 0 deletions slack-mathbot/hooks/message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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

0 comments on commit 13bde4e

Please sign in to comment.