Browse Source

Upgraded to slack-ruby-bot 0.3.0.

master
dB 8 years ago
parent
commit
240bf536fc
7 changed files with 18 additions and 11 deletions
  1. +5
    -1
      .rubocop_todo.yml
  2. +1
    -1
      .travis.yml
  3. +2
    -2
      Gemfile
  4. +3
    -3
      Gemfile.lock
  5. +3
    -1
      slack-mathbot/commands/about.rb
  6. +3
    -2
      slack-mathbot/commands/calculate.rb
  7. +1
    -1
      slack-mathbot/commands/help.rb

+ 5
- 1
.rubocop_todo.yml View File

@ -1,5 +1,5 @@
# This configuration was generated by `rubocop --auto-gen-config` # This configuration was generated by `rubocop --auto-gen-config`
# on 2015-07-09 16:07:58 -0400 using RuboCop version 0.31.0.
# on 2015-07-19 14:05:31 -0400 using RuboCop version 0.31.0.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
@ -9,6 +9,10 @@
Lint/RescueException: Lint/RescueException:
Enabled: false Enabled: false
# Offense count: 1
Metrics/AbcSize:
Max: 17
# Offense count: 11 # Offense count: 11
# Configuration parameters: AllowURI, URISchemes. # Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength: Metrics/LineLength:

+ 1
- 1
.travis.yml View File

@ -1,3 +1,3 @@
rvm: rvm:
- 2.1.6
- 2.2.0

+ 2
- 2
Gemfile View File

@ -1,8 +1,8 @@
source 'http://rubygems.org' source 'http://rubygems.org'
ruby '2.1.6'
ruby '2.2.0'
gem 'slack-ruby-bot', '~> 0.2.0'
gem 'slack-ruby-bot', '~> 0.3.0'
gem 'puma' gem 'puma'
gem 'sinatra' gem 'sinatra'
gem 'dentaku' gem 'dentaku'

+ 3
- 3
Gemfile.lock View File

@ -42,7 +42,7 @@ GEM
minitest (5.7.0) minitest (5.7.0)
multi_json (1.11.2) multi_json (1.11.2)
multipart-post (2.0.0) multipart-post (2.0.0)
oj (2.12.9)
oj (2.12.10)
parser (2.3.0.pre.2) parser (2.3.0.pre.2)
ast (>= 1.1, < 3.0) ast (>= 1.1, < 3.0)
powerpack (0.1.1) powerpack (0.1.1)
@ -85,7 +85,7 @@ GEM
faraday_middleware (~> 0.8) faraday_middleware (~> 0.8)
faye-websocket (~> 0.9.2) faye-websocket (~> 0.9.2)
multi_json (~> 1.0, >= 1.0.3) multi_json (~> 1.0, >= 1.0.3)
slack-ruby-bot (0.2.0)
slack-ruby-bot (0.3.0)
activesupport activesupport
giphy (~> 2.0.2) giphy (~> 2.0.2)
hashie hashie
@ -116,6 +116,6 @@ DEPENDENCIES
rspec rspec
rubocop (= 0.31.0) rubocop (= 0.31.0)
sinatra sinatra
slack-ruby-bot (~> 0.2.0)
slack-ruby-bot (~> 0.3.0)
vcr vcr
webmock webmock

+ 3
- 1
slack-mathbot/commands/about.rb View File

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

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

@ -2,9 +2,10 @@ module SlackMathbot
module Commands module Commands
class Calculate < SlackRubyBot::Commands::Base class Calculate < SlackRubyBot::Commands::Base
operator '=' operator '='
command 'calculate'
def self.call(data, _command, arguments)
result = Dentaku::Calculator.new.evaluate(arguments.join)
def self.call(data, match)
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 data.channel, result

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

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

Loading…
Cancel
Save