Skip to content

Commit 5788b3b

Browse files
committed
Extract real-time legacy bots into slack-ruby-bot-server-rtm.
1 parent 34035e6 commit 5788b3b

File tree

37 files changed

+138
-332
lines changed

37 files changed

+138
-332
lines changed

.rubocop_todo.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-07-17 08:36:05 -0400 using RuboCop version 0.81.0.
3+
# on 2020-11-14 17:01:04 -0500 using RuboCop version 0.81.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
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 3
9+
# Offense count: 1
1010
# Cop supports --auto-correct.
1111
# Configuration parameters: EnforcedStyle.
1212
# SupportedStyles: squiggly, active_support, powerpack, unindent
1313
Layout/HeredocIndentation:
1414
Exclude:
1515
- 'lib/slack-ruby-bot-server/info.rb'
16-
- 'sample_apps/sample_app_activerecord/commands/help.rb'
17-
- 'sample_apps/sample_app_mongoid/commands/help.rb'
1816

1917
# Offense count: 1
2018
Lint/AmbiguousOperator:
@@ -27,13 +25,12 @@ Lint/NonDeterministicRequireOrder:
2725
Exclude:
2826
- 'spec/spec_helper.rb'
2927

30-
# Offense count: 2
28+
# Offense count: 1
3129
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
3230
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
3331
Naming/FileName:
3432
Exclude:
3533
- 'lib/slack-ruby-bot-server.rb'
36-
- 'lib/slack-ruby-bot-server/ext/slack-ruby-bot.rb'
3734

3835
# Offense count: 3
3936
# Configuration parameters: ForbiddenDelimiters.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
### Changelog
22

3-
#### 0.12.4 (Next)
3+
#### 0.1.0 (Next)
44

5+
* [#129](https://github.com/slack-ruby/slack-ruby-bot-server/pull/129): Extracted RealTime components into [slack-ruby-bot-server-rtm](https://github.com/slack-ruby/slack-ruby-bot-server-rtm) - [@dblock](https://github.com/dblock).
56
* Your contribution here.
67

78
#### 0.12.3 (2020/11/14)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ The "Add to Slack" button uses the standard OAuth code grant flow as described i
102102
The button itself contains a link that looks like this:
103103

104104
```
105-
https://slack.com/oauth/authorize?scope=bot&client_id=<%= ENV['SLACK_CLIENT_ID'] %>
105+
https://slack.com/oauth/authorize?scope=<%= SlackRubyBotServer::Config.oauth_scope_s %>&client_id=<%= ENV['SLACK_CLIENT_ID'] %>
106106
```
107107

108108
Once clicked, the user is taken through the authorization process at Slack's site. Upon successful completion, a callback containing a temporary code is sent to the redirect URL you specified. The endpoint at that URL contains code that looks like this:
@@ -201,7 +201,7 @@ The [Add to Slack button](https://api.slack.com/docs/slack-button) also allows f
201201
auth = OpenSSL::HMAC.hexdigest("SHA256", "key", "data")
202202
```
203203
```html
204-
<a href="https://slack.com/oauth/authorize?scope=bot&client_id=<%= ENV['SLACK_CLIENT_ID'] %>&state=#{auth)"> ... </a>
204+
<a href="https://slack.com/oauth/authorize?scope=<%= SlackRubyBotServer::Config.oauth_scope_s %>&client_id=<%= ENV['SLACK_CLIENT_ID'] %>&state=#{auth)"> ... </a>
205205
```
206206
```ruby
207207
instance = SlackRubyBotServer::Service.instance

images/slackbotserver.gif

-600 KB
Binary file not shown.

images/slackbutton.gif

-103 KB
Binary file not shown.

lib/slack-ruby-bot-server.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
require 'async/websocket'
1+
require 'async'
22

3+
require 'slack-ruby-client'
34
require 'grape-swagger'
4-
require 'slack-ruby-bot'
55

6+
require_relative 'slack-ruby-bot-server/loggable'
67
require_relative 'slack-ruby-bot-server/service'
7-
require_relative 'slack-ruby-bot-server/server'
88
require_relative 'slack-ruby-bot-server/config'
99
require_relative 'slack-ruby-bot-server/ext'
1010
require_relative 'slack-ruby-bot-server/version'

lib/slack-ruby-bot-server/api/middleware.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
module SlackRubyBotServer
77
module Api
88
class Middleware
9-
def self.logger
10-
@logger ||= begin
11-
STDOUT.sync = true
12-
Logger.new(STDOUT)
13-
end
9+
include SlackRubyBotServer::Loggable
10+
11+
def self.reset!
12+
@instance = nil
1413
end
1514

1615
def self.instance

lib/slack-ruby-bot-server/config.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ module SlackRubyBotServer
22
module Config
33
extend self
44

5-
attr_accessor :server_class
5+
attr_accessor :logger
66
attr_accessor :service_class
77
attr_accessor :database_adapter
88
attr_accessor :view_paths
9+
attr_accessor :oauth_scope
910

1011
def reset!
11-
self.server_class = SlackRubyBotServer::Server
12+
self.logger = nil
1213
self.service_class = SlackRubyBotServer::Service
14+
self.oauth_scope = nil
1315

1416
self.view_paths = [
1517
'views',
@@ -26,6 +28,10 @@ def reset!
2628
end
2729
end
2830

31+
def oauth_scope_s
32+
oauth_scope&.join('+')
33+
end
34+
2935
def activerecord?
3036
database_adapter == :activerecord
3137
end

lib/slack-ruby-bot-server/ext.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
%w[bson/object_id grape/sort_extension slack-ruby-bot].each do |ext|
1+
%w[bson/object_id grape/sort_extension].each do |ext|
22
require_relative "ext/#{ext}"
33
end

lib/slack-ruby-bot-server/ext/activerecord/slack-ruby-bot/commands/base.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)