Browse Source

Monkey patch to support operator =.

master
dB 9 years ago
parent
commit
13bde4ef24
4 changed files with 32 additions and 7 deletions
  1. +1
    -1
      Gemfile
  2. +11
    -6
      Gemfile.lock
  3. +1
    -0
      slack-mathbot.rb
  4. +19
    -0
      slack-mathbot/hooks/message.rb

+ 1
- 1
Gemfile View File

@ -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'

+ 11
- 6
Gemfile.lock View File

@ -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:
@ -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)
@ -115,6 +120,6 @@ DEPENDENCIES
rspec
rubocop (= 0.31.0)
sinatra
slack-ruby-bot
slack-ruby-bot!
vcr
webmock

+ 1
- 0
slack-mathbot.rb View File

@ -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
- 0
slack-mathbot/hooks/message.rb View File

@ -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

Loading…
Cancel
Save