Skip to content

Commit 7d2517d

Browse files
committed
Upgrade to work with latest slack-ruby-bot.
1 parent 217a4c5 commit 7d2517d

File tree

29 files changed

+86
-49
lines changed

29 files changed

+86
-49
lines changed

.rubocop_todo.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-11-15 20:50:06 UTC using RuboCop version 1.3.0.
3+
# on 2020-11-15 22:07:57 UTC using RuboCop version 1.3.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -23,6 +23,18 @@ Layout/EmptyLinesAroundAttributeAccessor:
2323
- 'slack-shellbot/models/current_directory_entry.rb'
2424
- 'slack-shellbot/models/parent_directory_entry.rb'
2525

26+
# Offense count: 8
27+
Lint/MixedRegexpCaptureTypes:
28+
Exclude:
29+
- 'slack-shellbot/commands/cat.rb'
30+
- 'slack-shellbot/commands/cd.rb'
31+
- 'slack-shellbot/commands/echo.rb'
32+
- 'slack-shellbot/commands/mkdir.rb'
33+
- 'slack-shellbot/commands/rm.rb'
34+
- 'slack-shellbot/commands/rmdir.rb'
35+
- 'slack-shellbot/commands/touch.rb'
36+
- 'slack-shellbot/commands/vi.rb'
37+
2638
# Offense count: 2
2739
# Cop supports --auto-correct.
2840
Lint/NonDeterministicRequireOrder:
@@ -51,7 +63,7 @@ Naming/HeredocDelimiterNaming:
5163
- 'slack-shellbot/commands/help.rb'
5264
- 'slack-shellbot/info.rb'
5365

54-
# Offense count: 43
66+
# Offense count: 19
5567
# Cop supports --auto-correct.
5668
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
5769
# URISchemes: http, https

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ gem 'rack-robotz'
1313
gem 'rack-server-pages'
1414
gem 'slack-ruby-bot-server'
1515
gem 'slack-ruby-bot-server-mailchimp'
16-
gem 'slack-ruby-bot-server-rtm', github: 'slack-ruby/slack-ruby-bot-server-rtm', branch: 'main'
16+
gem 'slack-ruby-bot-server-rtm'
1717
gem 'unicorn'
1818

1919
group :development, :test do

Gemfile.lock

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
GIT
2-
remote: git://github.com/slack-ruby/slack-ruby-bot-server-rtm.git
3-
revision: b6b030c89a303bee09cb060fe1118a61703fc20b
4-
branch: main
5-
specs:
6-
slack-ruby-bot-server-rtm (0.1.1)
7-
async-websocket (~> 0.8.0)
8-
slack-ruby-bot (>= 0.12.0)
9-
slack-ruby-bot-server (>= 1.0.0)
10-
111
GEM
122
remote: https://rubygems.org/
133
specs:
@@ -256,6 +246,10 @@ GEM
256246
slack-ruby-bot-server-mailchimp (0.2.0)
257247
mailchimp_api_v3
258248
slack-ruby-bot-server (>= 0.10.0)
249+
slack-ruby-bot-server-rtm (0.1.1)
250+
async-websocket (~> 0.8.0)
251+
slack-ruby-bot (>= 0.12.0)
252+
slack-ruby-bot-server (>= 1.0.0)
259253
slack-ruby-client (0.14.6)
260254
activesupport
261255
faraday (>= 0.9)
@@ -314,7 +308,7 @@ DEPENDENCIES
314308
selenium-webdriver
315309
slack-ruby-bot-server
316310
slack-ruby-bot-server-mailchimp
317-
slack-ruby-bot-server-rtm!
311+
slack-ruby-bot-server-rtm
318312
unicorn
319313
vcr
320314
webmock

config/initializers/slack-ruby-bot/hooks/message.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ def call(client, data)
66
return if client.message_to_self?(data)
77

88
Thread.current[:stdout] = []
9-
data = Hashie::Mash.new(data)
109
return if data.subtype
1110

1211
if data.key?(:text)
1312
data.text = Slack::Messages::Formatting.unescape(data.text)
1413
command, redirect_to = split_redirect(data.text)
1514
data.text = command if command
1615
end
16+
1717
fs = client.owner.fs[data.channel] if data.channel
1818
if fs && fs.program
1919
client.logger.info "PROGRAM: #{client.owner}, #{fs}, program=#{fs.program._type}, user=#{data.user}, message_ts=#{fs.program.message_ts}"

slack-shellbot/commands/cat.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module SlackShellbot
22
module Commands
33
class Cat < SlackRubyBot::Commands::Base
4+
match(/^cat([\s])?(?<file>.*)$/)
5+
46
def self.call(client, data, match)
57
fs = client.owner.fs[data.channel]
6-
file = Shellwords.split(match['expression']).first if match.names.include?('expression')
8+
file = Shellwords.split(match['file']).first if match.names.include?('file')
79
raise 'usage: cat <file> ...' unless file
810

911
file_entry = fs.current_directory_entry.find(file)

slack-shellbot/commands/cd.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module SlackShellbot
22
module Commands
33
class Cd < SlackRubyBot::Commands::Base
4+
match(/^cd([\s])?(?<path>.*)$/)
5+
46
def self.call(client, data, match)
57
fs = client.owner.fs[data.channel]
6-
directory = Shellwords.split(match['expression']).first if match.names.include?('expression')
8+
directory = Shellwords.split(match['path']).first if match.names.include?('path')
79
raise 'usage: cd directory ...' unless directory
810

911
directory_entry = fs.cd(directory)

slack-shellbot/commands/echo.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
module SlackShellbot
22
module Commands
33
class Echo < SlackRubyBot::Commands::Base
4+
match(/^echo$/)
5+
match(/^echo([\s])?(?<text>.*)$/)
6+
47
def self.call(client, data, match)
58
fs = client.owner.fs[data.channel]
6-
expression = match['expression'] if match.names.include?('expression')
7-
client.say(channel: data.channel, text: expression || "\n")
8-
logger.info "ECHO: #{client.owner}, #{fs}, expression=#{expression}, user=#{data.user}"
9+
text = match['text'] if match.names.include?('text')
10+
client.say(channel: data.channel, text: text || "\n")
11+
logger.info "ECHO: #{client.owner}, #{fs}, text=#{text}, user=#{data.user}"
912
end
1013
end
1114
end

slack-shellbot/commands/help.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module SlackShellbot
22
module Commands
33
class Help < SlackRubyBot::Commands::Base
4+
command 'help'
5+
46
HELP = <<~EOS.freeze
57
I am your friendly Shellbot, here to help.
68

slack-shellbot/commands/ls.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module SlackShellbot
22
module Commands
33
class Ls < SlackRubyBot::Commands::Base
4+
match(/^ls$/)
5+
46
def self.call(client, data, _match)
57
fs = client.owner.fs[data.channel]
68
dirs = fs.current_directory_entry.map(&:to_s).join("\n")

slack-shellbot/commands/mkdir.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module SlackShellbot
22
module Commands
33
class Mkdir < SlackRubyBot::Commands::Base
4+
match(/^mkdir([\s])?(?<path>.*)$/)
5+
46
def self.call(client, data, match)
57
fs = client.owner.fs[data.channel]
6-
directory = Shellwords.split(match['expression']).first if match.names.include?('expression')
8+
directory = Shellwords.split(match['path']).first if match.names.include?('path')
79
raise 'usage: mkdir <directory> ...' unless directory
810

911
directory_entry = fs.current_directory_entry.mkdir(directory)

0 commit comments

Comments
 (0)