Browse Source

Use slack-ruby-bot 0.4.0.

master
dB 9 years ago
parent
commit
c43bc25bb0
6 changed files with 27 additions and 28 deletions
  1. +1
    -1
      Gemfile
  2. +16
    -18
      Gemfile.lock
  3. +2
    -2
      slack-mathbot/commands/about.rb
  4. +4
    -4
      slack-mathbot/commands/calculate.rb
  5. +2
    -2
      slack-mathbot/commands/help.rb
  6. +2
    -1
      spec/slack-mathbot/commands/unknown_spec.rb

+ 1
- 1
Gemfile View File

@ -2,7 +2,7 @@ source 'http://rubygems.org'
ruby '2.2.0' ruby '2.2.0'
gem 'slack-ruby-bot', '~> 0.3.0'
gem 'slack-ruby-bot'
gem 'puma' gem 'puma'
gem 'sinatra' gem 'sinatra'
gem 'dentaku' gem 'dentaku'

+ 16
- 18
Gemfile.lock View File

@ -9,8 +9,8 @@ GEM
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.3.8) addressable (2.3.8)
ast (2.0.0) ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
astrolabe (1.3.1)
parser (~> 2.2)
crack (0.4.2) crack (0.4.2)
safe_yaml (~> 1.0.0) safe_yaml (~> 1.0.0)
dentaku (1.2.6) dentaku (1.2.6)
@ -24,7 +24,7 @@ GEM
faraday (~> 0.9.0) faraday (~> 0.9.0)
faraday_middleware (~> 0.9.1) faraday_middleware (~> 0.9.1)
oj (~> 2.0) oj (~> 2.0)
faye-websocket (0.9.2)
faye-websocket (0.10.0)
eventmachine (>= 0.12.0) eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1) websocket-driver (>= 0.5.1)
foreman (0.78.0) foreman (0.78.0)
@ -40,14 +40,12 @@ GEM
launchy (2.4.3) launchy (2.4.3)
addressable (~> 2.3) addressable (~> 2.3)
minitest (5.7.0) minitest (5.7.0)
multi_json (1.11.2)
multipart-post (2.0.0) multipart-post (2.0.0)
oj (2.12.10) oj (2.12.10)
parser (2.3.0.pre.2)
parser (2.2.2.6)
ast (>= 1.1, < 3.0) ast (>= 1.1, < 3.0)
powerpack (0.1.1) powerpack (0.1.1)
puma (2.11.3)
rack (>= 1.1, < 2.0)
puma (2.12.2)
rack (1.6.4) rack (1.6.4)
rack-protection (1.5.3) rack-protection (1.5.3)
rack rack
@ -59,12 +57,12 @@ GEM
rspec-core (~> 3.3.0) rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0) rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0) rspec-mocks (~> 3.3.0)
rspec-core (3.3.1)
rspec-core (3.3.2)
rspec-support (~> 3.3.0) rspec-support (~> 3.3.0)
rspec-expectations (3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0) rspec-support (~> 3.3.0)
rspec-mocks (3.3.1)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0) rspec-support (~> 3.3.0)
rspec-support (3.3.0) rspec-support (3.3.0)
@ -80,17 +78,17 @@ GEM
rack (~> 1.4) rack (~> 1.4)
rack-protection (~> 1.4) rack-protection (~> 1.4)
tilt (>= 1.3, < 3) tilt (>= 1.3, < 3)
slack-api (1.1.6)
faraday (>= 0.7, < 0.10)
faraday_middleware (~> 0.8)
faye-websocket (~> 0.9.2)
multi_json (~> 1.0, >= 1.0.3)
slack-ruby-bot (0.3.0)
slack-ruby-bot (0.4.0)
activesupport activesupport
giphy (~> 2.0.2) giphy (~> 2.0.2)
hashie hashie
slack-api (~> 1.1.6)
slack-ruby-client
websocket-driver (~> 0.5.4) websocket-driver (~> 0.5.4)
slack-ruby-client (0.1.0)
eventmachine
faraday
faraday_middleware
faye-websocket
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (2.0.1) tilt (2.0.1)
@ -116,6 +114,6 @@ DEPENDENCIES
rspec rspec
rubocop (= 0.31.0) rubocop (= 0.31.0)
sinatra sinatra
slack-ruby-bot (~> 0.3.0)
slack-ruby-bot
vcr vcr
webmock webmock

+ 2
- 2
slack-mathbot/commands/about.rb View File

@ -3,8 +3,8 @@ module SlackMathbot
class Default < SlackRubyBot::Commands::Base class Default < SlackRubyBot::Commands::Base
match(/^(?<bot>\w*)$/) match(/^(?<bot>\w*)$/)
def self.call(data, _match)
send_message_with_gif data.channel, SlackMathbot::ABOUT, 'math'
def self.call(client, data, _match)
send_message_with_gif client, data.channel, SlackMathbot::ABOUT, 'math'
end end
end end
end end

+ 4
- 4
slack-mathbot/commands/calculate.rb View File

@ -4,16 +4,16 @@ module SlackMathbot
operator '=' operator '='
command 'calculate' command 'calculate'
def self.call(data, match)
def self.call(client, data, match)
result = Dentaku::Calculator.new.evaluate(match[:expression]) if match.names.include?('expression') result = Dentaku::Calculator.new.evaluate(match[:expression]) if match.names.include?('expression')
result = result.to_s if result result = result.to_s if result
if result && result.length > 0 if result && result.length > 0
send_message data.channel, result
send_message client, data.channel, result
else else
send_message_with_gif data.channel, 'Got nothing.', 'nothing'
send_message_with_gif client, data.channel, 'Got nothing.', 'nothing'
end end
rescue StandardError => e rescue StandardError => e
send_message_with_gif data.channel, "Sorry, #{e.message}.", 'idiot'
send_message_with_gif client, data.channel, "Sorry, #{e.message}.", 'idiot'
end end
end end
end end

+ 2
- 2
slack-mathbot/commands/help.rb View File

@ -1,8 +1,8 @@
module SlackMathbot module SlackMathbot
module Commands module Commands
class Help < SlackRubyBot::Commands::Base class Help < SlackRubyBot::Commands::Base
def self.call(data, _match)
send_message_with_gif data.channel, 'See https://github.com/dblock/slack-mathbot, please.', 'help'
def self.call(client, data, _match)
send_message_with_gif client, data.channel, 'See https://github.com/dblock/slack-mathbot, please.', 'help'
end end
end end
end end

+ 2
- 1
spec/slack-mathbot/commands/unknown_spec.rb View File

@ -4,11 +4,12 @@ describe SlackRubyBot::Commands::Unknown do
def app def app
SlackMathbot::App.new SlackMathbot::App.new
end end
let(:client) { app.send(:client) }
it 'invalid command' do it 'invalid command' do
expect(message: 'mathbot foobar').to respond_with_slack_message("Sorry <@user>, I don't understand that command!") expect(message: 'mathbot foobar').to respond_with_slack_message("Sorry <@user>, I don't understand that command!")
end end
it 'does not respond to sad face' do it 'does not respond to sad face' do
expect(SlackRubyBot::Commands::Base).to_not receive(:send_message) expect(SlackRubyBot::Commands::Base).to_not receive(:send_message)
SlackMathbot::App.new.send(:message, text: ':((')
SlackMathbot::App.new.send(:message, client, text: ':((')
end end
end end

Loading…
Cancel
Save