slack-ruby-bot-server 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -0
- data/.rubocop_todo.yml +20 -42
- data/.travis.yml +9 -2
- data/CHANGELOG.md +7 -0
- data/Gemfile +16 -16
- data/LICENSE +1 -1
- data/README.md +31 -3
- data/Rakefile +1 -1
- data/UPGRADING.md +18 -0
- data/lib/slack-ruby-bot-server.rb +1 -0
- data/lib/slack-ruby-bot-server/api/helpers/pagination_parameters.rb +1 -1
- data/lib/slack-ruby-bot-server/api/middleware.rb +3 -3
- data/lib/slack-ruby-bot-server/app.rb +1 -1
- data/lib/slack-ruby-bot-server/config.rb +2 -0
- data/lib/slack-ruby-bot-server/ext.rb +1 -1
- data/lib/slack-ruby-bot-server/ext/activerecord/slack-ruby-bot/commands/base.rb +1 -0
- data/lib/slack-ruby-bot-server/ext/mongoid/slack-ruby-bot/commands/base.rb +1 -0
- data/lib/slack-ruby-bot-server/ping.rb +99 -0
- data/lib/slack-ruby-bot-server/server.rb +19 -1
- data/lib/slack-ruby-bot-server/service.rb +3 -1
- data/lib/slack-ruby-bot-server/version.rb +1 -1
- data/sample_apps/sample_app_activerecord/Gemfile +8 -8
- data/sample_apps/sample_app_activerecord/Rakefile +1 -0
- data/sample_apps/sample_app_activerecord/commands/help.rb +1 -1
- data/sample_apps/sample_app_activerecord/spec/api/root_spec.rb +1 -1
- data/sample_apps/sample_app_activerecord/spec/spec_helper.rb +1 -1
- data/sample_apps/sample_app_mongoid/Gemfile +5 -5
- data/sample_apps/sample_app_mongoid/commands/help.rb +1 -1
- data/sample_apps/sample_app_mongoid/spec/api/root_spec.rb +1 -1
- data/slack-ruby-bot-server.gemspec +6 -7
- data/tasks/db.rake +1 -1
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cc9126666813e0a880a4c970ff259ea90fd0954
|
4
|
+
data.tar.gz: 0eede9635d5aca9c6db238e8bb1a3bcf86614564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea825ac737ceb089ad5460b40ff98607d9424bf2d6b9d196351399e73ce065581303d996c105dc20d9c88d4d21e7fa222f7cc65ad9d07e9b22655c01a9c0bd21
|
7
|
+
data.tar.gz: 91ed370e494c05e9543aba95379dcecdfdd0513f535a75d349983d7244cb9b4f69590584ad25558ccb4c094934f44b02920c7d255d676cb8341930d4c08e19f2
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,56 +1,34 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2018-08-22 08:29:35 -0400 using RuboCop version 0.58.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
|
9
|
+
# Offense count: 3
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: EnforcedStyle.
|
12
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
13
|
+
Layout/IndentHeredoc:
|
11
14
|
Exclude:
|
12
|
-
- 'lib/slack-ruby-bot-server/
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
Metrics/ClassLength:
|
21
|
-
Max: 117
|
22
|
-
|
23
|
-
# Offense count: 2
|
24
|
-
Metrics/CyclomaticComplexity:
|
25
|
-
Max: 11
|
26
|
-
|
27
|
-
# Offense count: 68
|
28
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
29
|
-
# URISchemes: http, https
|
30
|
-
Metrics/LineLength:
|
31
|
-
Max: 163
|
32
|
-
|
33
|
-
# Offense count: 8
|
34
|
-
# Configuration parameters: CountComments.
|
35
|
-
Metrics/MethodLength:
|
36
|
-
Max: 23
|
37
|
-
|
38
|
-
# Offense count: 2
|
39
|
-
Metrics/PerceivedComplexity:
|
40
|
-
Max: 11
|
41
|
-
|
42
|
-
# Offense count: 25
|
43
|
-
Style/Documentation:
|
44
|
-
Enabled: false
|
45
|
-
|
46
|
-
# Offense count: 2
|
47
|
-
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
|
48
|
-
Style/FileName:
|
15
|
+
- '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'
|
18
|
+
|
19
|
+
# Offense count: 3
|
20
|
+
# Configuration parameters: Blacklist.
|
21
|
+
# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
|
22
|
+
Naming/HeredocDelimiterNaming:
|
49
23
|
Exclude:
|
50
|
-
- 'lib/slack-ruby-bot-server.rb'
|
51
|
-
- '
|
24
|
+
- 'lib/slack-ruby-bot-server/info.rb'
|
25
|
+
- 'sample_apps/sample_app_activerecord/commands/help.rb'
|
26
|
+
- 'sample_apps/sample_app_mongoid/commands/help.rb'
|
52
27
|
|
53
28
|
# Offense count: 1
|
29
|
+
# Cop supports --auto-correct.
|
30
|
+
# Configuration parameters: EnforcedStyle.
|
31
|
+
# SupportedStyles: module_function, extend_self
|
54
32
|
Style/ModuleFunction:
|
55
33
|
Exclude:
|
56
34
|
- 'lib/slack-ruby-bot-server/config.rb'
|
data/.travis.yml
CHANGED
@@ -16,9 +16,16 @@ matrix:
|
|
16
16
|
services:
|
17
17
|
- mongodb
|
18
18
|
|
19
|
+
addons:
|
20
|
+
firefox: 54.0
|
21
|
+
|
19
22
|
before_install:
|
20
|
-
-
|
21
|
-
-
|
23
|
+
- export DISPLAY=:99.0
|
24
|
+
- sh -e /etc/init.d/xvfb start
|
25
|
+
- wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
|
26
|
+
- mkdir geckodriver
|
27
|
+
- tar -xzf geckodriver-v0.18.0-linux64.tar.gz -C geckodriver
|
28
|
+
- export PATH=$PATH:$PWD/geckodriver
|
22
29
|
|
23
30
|
script:
|
24
31
|
- bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
### Changelog
|
2
2
|
|
3
|
+
#### 0.7.0 (8/22/2018)
|
4
|
+
|
5
|
+
* [#60](https://github.com/slack-ruby/slack-ruby-bot-server/pull/60): Log caught Standard::Error backtrace at debug-level - [@alexagranov](https://github.com/alexagranov).
|
6
|
+
* [#65](https://github.com/slack-ruby/slack-ruby-bot-server/pull/65): Updated Capybara and selenium-webdriver - [@dblock](https://github.com/dblock).
|
7
|
+
* [#67](https://github.com/slack-ruby/slack-ruby-bot-server/pull/67): Only load the OTR::ActiveRecord::ConnectionManagement middleware when the OTR module is included. This module isn't needed when using Rails - [@darbyfrey](https://github.com/darbyfrey).
|
8
|
+
* [#74](https://github.com/slack-ruby/slack-ruby-bot-server/pull/74): Added ping worker, will restart offline bots - [@dblock](https://github.com/dblock).
|
9
|
+
|
3
10
|
#### 0.6.1 (3/29/2017)
|
4
11
|
|
5
12
|
* [#54](https://github.com/slack-ruby/slack-ruby-bot-server/pull/54): Removing one more Mongoid dependency when rescuing from _invoke - [@alexagranov](https://github.com/alexagranov).
|
data/Gemfile
CHANGED
@@ -2,14 +2,14 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
case ENV['DATABASE_ADAPTER']
|
4
4
|
when 'mongoid' then
|
5
|
-
gem 'mongoid'
|
6
5
|
gem 'kaminari-mongoid'
|
6
|
+
gem 'mongoid'
|
7
7
|
gem 'mongoid-scroll'
|
8
8
|
when 'activerecord' then
|
9
|
+
gem 'activerecord', '~> 5.0.0'
|
10
|
+
gem 'otr-activerecord', '~> 1.2.1'
|
11
|
+
gem 'cursor_pagination' # rubocop:disable Bundler/OrderedGems
|
9
12
|
gem 'pg'
|
10
|
-
gem 'activerecord'
|
11
|
-
gem 'otr-activerecord'
|
12
|
-
gem 'cursor_pagination'
|
13
13
|
when nil then
|
14
14
|
warn "Missing ENV['DATABASE_ADAPTER']."
|
15
15
|
else
|
@@ -19,23 +19,23 @@ end
|
|
19
19
|
gemspec
|
20
20
|
|
21
21
|
group :development, :test do
|
22
|
-
gem 'rack-server-pages'
|
23
22
|
gem 'bundler'
|
24
|
-
gem 'rake'
|
25
|
-
gem 'rspec'
|
26
|
-
gem 'rubocop', '0.40.0'
|
27
23
|
gem 'byebug'
|
28
|
-
gem '
|
29
|
-
gem '
|
30
|
-
gem 'rack-test'
|
31
|
-
gem 'webmock'
|
32
|
-
gem 'vcr'
|
24
|
+
gem 'capybara', '~> 2.15.1'
|
25
|
+
gem 'database_cleaner'
|
33
26
|
gem 'fabrication'
|
34
27
|
gem 'faker'
|
35
|
-
gem '
|
28
|
+
gem 'heroku'
|
36
29
|
gem 'hyperclient'
|
37
|
-
gem '
|
38
|
-
gem '
|
30
|
+
gem 'mongoid-shell'
|
31
|
+
gem 'rack-server-pages'
|
32
|
+
gem 'rack-test'
|
33
|
+
gem 'rake'
|
34
|
+
gem 'rspec'
|
35
|
+
gem 'rubocop', '0.58.2'
|
36
|
+
gem 'selenium-webdriver', '~> 3.4.4'
|
37
|
+
gem 'vcr'
|
38
|
+
gem 'webmock'
|
39
39
|
end
|
40
40
|
|
41
41
|
group :test do
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2015-
|
3
|
+
Copyright (c) 2015-2017 Daniel Doubrovkine & Contributors
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ A library that contains a [Grape](http://github.com/ruby-grape/grape) API servin
|
|
13
13
|
|
14
14
|
### Stable Release
|
15
15
|
|
16
|
-
You're reading the documentation for the **stable** release of slack-ruby-bot-server, 0.
|
16
|
+
You're reading the documentation for the **stable** release of slack-ruby-bot-server, 0.7.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
17
17
|
|
18
18
|
### Try Me
|
19
19
|
|
@@ -152,16 +152,44 @@ SlackRubyBotServer.configure do |config|
|
|
152
152
|
end
|
153
153
|
```
|
154
154
|
|
155
|
+
#### Ping Worker
|
156
|
+
|
157
|
+
Each `SlackRubyBotServer::Server` instance will start a ping worker that will periodically check the online status of the bot via the Slack web [auth.test](https://api.slack.com/methods/auth.test) and [users.getPresence](https://api.slack.com/methods/users.getPresence) APIs, and will forcefully close the connection if the bot goes offline, causing an automatic reconnect.
|
158
|
+
|
159
|
+
You can configure the ping interval, number of retries before restart, and disable the ping worker entirely.
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
SlackRubyBotServer.configure do |config|
|
163
|
+
config.ping = {
|
164
|
+
enabled: true, # set to false to disable the ping worker
|
165
|
+
ping_interval: 30, # interval in seconds
|
166
|
+
retry_count: 3 # number of unsuccessful retries until a restart
|
167
|
+
}
|
168
|
+
end
|
169
|
+
```
|
170
|
+
|
171
|
+
### Access Tokens
|
172
|
+
|
173
|
+
By default the implementation of [Team](lib/slack-ruby-bot-server/models/team) stores a `bot_access_token` that grants a certain amount of privileges to the bot user as described in [Slack OAuth Docs](https://api.slack.com/docs/oauth). You may not want a bot user at all, or may require different auth scopes, such as `users.profile:read` to access user profile information via `Slack::Web::Client#users_profile_get`. To obtain the non-bot access token make the following changes.
|
174
|
+
|
175
|
+
1) Configure your app to require additional scopes in Slack API under _OAuth_, _Permissions_
|
176
|
+
2) Add `access_token` and, optionally, `scope` to your `Team` model
|
177
|
+
3) Change the _Add to Slack_ buttons to require the additional scope, eg. `https://slack.com/oauth/authorize?scope=bot,users.profile:read&client_id=...`
|
178
|
+
4) Store the access token returned from `Slack::Web::Client#oauth_access` and scope when creating a team in your `Teams` API endpoint.
|
179
|
+
|
180
|
+
You can see a sample implementation in [slack-sup#3a497b](https://github.com/dblock/slack-sup/commit/3a497b436d25d3a7738562655cda64b180ae0096).
|
181
|
+
|
155
182
|
### Examples Using Slack Ruby Bot Server
|
156
183
|
|
157
184
|
* [slack-amber-alert](https://github.com/dblock/slack-amber-alert), free service at [missingkidsbot.org](https://www.missingkidsbot.org)
|
185
|
+
* [slack-sup](https://github.com/dblock/slack-sup), free service at [sup.playplay.io](https://sup.playplay.io)
|
158
186
|
* [slack-gamebot](https://github.com/dblock/slack-gamebot), free service at [www.playplay.io](https://www.playplay.io)
|
159
187
|
* [slack-market](https://github.com/dblock/slack-market), free service at [market.playplay.io](https://market.playplay.io)
|
160
|
-
* [slack-
|
188
|
+
* [slack-shellbot](https://github.com/slack-ruby/slack-shellbot), free service at [shell.playplay.io](https://shell.playplay.io)
|
161
189
|
* [slack-api-explorer](https://github.com/slack-ruby/slack-api-explorer), free service at [api-explorer.playplay.io](https://shell.playplay.io)
|
162
190
|
|
163
191
|
### Copyright & License
|
164
192
|
|
165
|
-
Copyright [Daniel Doubrovkine](http://code.dblock.org), 2015-
|
193
|
+
Copyright [Daniel Doubrovkine](http://code.dblock.org) and Contributors, 2015-2017
|
166
194
|
|
167
195
|
[MIT License](LICENSE)
|
data/Rakefile
CHANGED
data/UPGRADING.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
Upgrading Slack-Ruby-Bot-Server
|
2
2
|
===============================
|
3
3
|
|
4
|
+
### Upgrading to >= 0.7.0
|
5
|
+
|
6
|
+
#### New Ping Worker
|
7
|
+
|
8
|
+
Version 0.7.0 will automatically start a ping worker that checks for the bot's online status and forcefully terminate and restart disconnected bots. Set the ping `enabled` option to `false` to disable this behavior.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
SlackRubyBotServer.configure do |config|
|
12
|
+
config.ping = {
|
13
|
+
enabled: false
|
14
|
+
}
|
15
|
+
end
|
16
|
+
```
|
17
|
+
|
18
|
+
If you are currently using a custom ping worker as suggested in [slack-ruby-client#208](https://github.com/slack-ruby/slack-ruby-client/issues/208), delete it.
|
19
|
+
|
20
|
+
See [#74](https://github.com/slack-ruby/slack-ruby-bot-server/pull/74) for more information.
|
21
|
+
|
4
22
|
### Upgrading to >= 0.6.0
|
5
23
|
|
6
24
|
#### Mongoid and ActiveRecord support
|
@@ -8,19 +8,19 @@ module SlackRubyBotServer
|
|
8
8
|
class Middleware
|
9
9
|
def self.logger
|
10
10
|
@logger ||= begin
|
11
|
-
|
11
|
+
STDOUT.sync = true
|
12
12
|
Logger.new(STDOUT)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.instance
|
17
17
|
@instance ||= Rack::Builder.new do
|
18
|
-
use OTR::ActiveRecord::ConnectionManagement if SlackRubyBotServer::Config.activerecord?
|
18
|
+
use OTR::ActiveRecord::ConnectionManagement if SlackRubyBotServer::Config.activerecord? && defined?(::OTR)
|
19
19
|
|
20
20
|
use Rack::Cors do
|
21
21
|
allow do
|
22
22
|
origins '*'
|
23
|
-
resource '*', headers: :any, methods: [
|
23
|
+
resource '*', headers: :any, methods: %i[get post]
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -3,9 +3,11 @@ module SlackRubyBotServer
|
|
3
3
|
extend self
|
4
4
|
|
5
5
|
attr_accessor :server_class
|
6
|
+
attr_accessor :ping
|
6
7
|
attr_accessor :database_adapter
|
7
8
|
|
8
9
|
def reset!
|
10
|
+
self.ping = nil
|
9
11
|
self.server_class = SlackRubyBotServer::Server
|
10
12
|
self.database_adapter = if defined?(::Mongoid)
|
11
13
|
:mongoid
|
@@ -8,6 +8,7 @@ module SlackRubyBot
|
|
8
8
|
_invoke client, data
|
9
9
|
rescue StandardError => e
|
10
10
|
logger.info "#{name.demodulize.upcase}: #{client.owner}, #{e.class}: #{e}"
|
11
|
+
logger.debug e.backtrace.join("\n")
|
11
12
|
client.say(channel: data.channel, text: e.message, gif: 'error')
|
12
13
|
true
|
13
14
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module SlackRubyBotServer
|
2
|
+
class Ping
|
3
|
+
include Celluloid
|
4
|
+
|
5
|
+
attr_reader :client
|
6
|
+
attr_reader :options
|
7
|
+
attr_reader :error_count
|
8
|
+
|
9
|
+
def initialize(client, options = {})
|
10
|
+
@options = options
|
11
|
+
@client = client
|
12
|
+
@error_count = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def start!
|
16
|
+
every ping_interval do
|
17
|
+
check!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def check!
|
24
|
+
if online?
|
25
|
+
@error_count = 0
|
26
|
+
else
|
27
|
+
down!
|
28
|
+
end
|
29
|
+
rescue StandardError => e
|
30
|
+
case e.message
|
31
|
+
when 'account_inactive', 'invalid_auth' then
|
32
|
+
logger.warn "Error pinging team #{owner.id}: #{e.message}, terminating."
|
33
|
+
terminate
|
34
|
+
else
|
35
|
+
logger.warn "Error pinging team #{owner.id}: #{e.message}."
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def offline?
|
40
|
+
!online?
|
41
|
+
end
|
42
|
+
|
43
|
+
def online?
|
44
|
+
presence.online
|
45
|
+
end
|
46
|
+
|
47
|
+
def presence
|
48
|
+
owner.ping![:presence]
|
49
|
+
end
|
50
|
+
|
51
|
+
def down!
|
52
|
+
logger.warn "DOWN: #{owner}, #{retries_left} #{retries_left == 1 ? 'retry' : 'retries'} left"
|
53
|
+
@error_count += 1
|
54
|
+
return if retries_left?
|
55
|
+
restart!
|
56
|
+
end
|
57
|
+
|
58
|
+
def restart!
|
59
|
+
logger.warn "RESTART: #{owner}"
|
60
|
+
driver.emit(:close, WebSocket::Driver::CloseEvent.new(1001, 'bot offline')) if driver
|
61
|
+
terminate
|
62
|
+
end
|
63
|
+
|
64
|
+
def ping_interval
|
65
|
+
options[:ping_interval] || 60
|
66
|
+
end
|
67
|
+
|
68
|
+
def retries_left?
|
69
|
+
retries_left >= 0
|
70
|
+
end
|
71
|
+
|
72
|
+
def retries_left
|
73
|
+
retry_count - error_count
|
74
|
+
end
|
75
|
+
|
76
|
+
def retry_count
|
77
|
+
options[:retry_count] || 2
|
78
|
+
end
|
79
|
+
|
80
|
+
def socket
|
81
|
+
client.instance_variable_get(:@socket) if client
|
82
|
+
end
|
83
|
+
|
84
|
+
def driver
|
85
|
+
socket.instance_variable_get(:@driver) if socket
|
86
|
+
end
|
87
|
+
|
88
|
+
def logger
|
89
|
+
@logger ||= begin
|
90
|
+
STDOUT.sync = true
|
91
|
+
Logger.new(STDOUT)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def owner
|
96
|
+
client.owner
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -7,10 +7,11 @@ module SlackRubyBotServer
|
|
7
7
|
def initialize(attrs = {})
|
8
8
|
attrs = attrs.dup
|
9
9
|
@team = attrs.delete(:team)
|
10
|
+
@ping_options = attrs.delete(:ping) || {}
|
10
11
|
raise 'Missing team' unless @team
|
11
12
|
attrs[:token] = @team.token
|
12
13
|
super(attrs)
|
13
|
-
|
14
|
+
open!
|
14
15
|
end
|
15
16
|
|
16
17
|
def restart!(wait = 1)
|
@@ -18,7 +19,24 @@ module SlackRubyBotServer
|
|
18
19
|
# it would keep retrying without checking for account_inactive or such, we want to restart via service which will disable an inactive team
|
19
20
|
logger.info "#{team.name}: socket closed, restarting ..."
|
20
21
|
SlackRubyBotServer::Service.instance.restart! team, self, wait
|
22
|
+
open!
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :ping_options
|
28
|
+
|
29
|
+
def create_ping
|
30
|
+
return unless !ping_options.key?(:enabled) || ping_options[:enabled]
|
31
|
+
SlackRubyBotServer::Ping.new(client, ping_options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def open!
|
21
35
|
client.owner = team
|
36
|
+
client.on :open do |_event|
|
37
|
+
worker = create_ping
|
38
|
+
worker.start! if worker
|
39
|
+
end
|
22
40
|
end
|
23
41
|
end
|
24
42
|
end
|
@@ -30,7 +30,9 @@ module SlackRubyBotServer
|
|
30
30
|
def start!(team)
|
31
31
|
run_callbacks :starting, team
|
32
32
|
logger.info "Starting team #{team}."
|
33
|
-
|
33
|
+
options = { team: team }
|
34
|
+
options[:ping] = SlackRubyBotServer::Config.ping if SlackRubyBotServer::Config.ping
|
35
|
+
server = SlackRubyBotServer::Config.server_class.new(options)
|
34
36
|
start_server! team, server
|
35
37
|
run_callbacks :started, team
|
36
38
|
server
|
@@ -1,23 +1,23 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem '
|
4
|
-
gem 'activerecord', require: 'active_record'
|
5
|
-
gem 'slack-ruby-bot-server', path: '../../'
|
3
|
+
gem 'activerecord', '~> 5.0.0', require: 'active_record'
|
6
4
|
gem 'newrelic-slack-ruby-bot'
|
5
|
+
gem 'otr-activerecord', '~> 1.2.1'
|
6
|
+
gem 'pg'
|
7
7
|
gem 'rack-server-pages'
|
8
8
|
gem 'rack-test'
|
9
|
-
gem '
|
9
|
+
gem 'slack-ruby-bot-server', path: '../../'
|
10
10
|
|
11
11
|
group :development, :test do
|
12
|
-
gem 'standalone_migrations'
|
12
|
+
gem 'standalone_migrations', '~> 5.2'
|
13
13
|
end
|
14
14
|
|
15
15
|
group :test do
|
16
|
-
gem '
|
17
|
-
gem 'rspec'
|
16
|
+
gem 'database_cleaner'
|
18
17
|
gem 'fabrication'
|
19
18
|
gem 'faker'
|
19
|
+
gem 'rake'
|
20
|
+
gem 'rspec'
|
20
21
|
gem 'vcr'
|
21
22
|
gem 'webmock'
|
22
|
-
gem 'database_cleaner'
|
23
23
|
end
|
@@ -10,7 +10,7 @@ help - get this helpful message
|
|
10
10
|
whoami - print your username
|
11
11
|
|
12
12
|
```
|
13
|
-
EOS
|
13
|
+
EOS
|
14
14
|
def self.call(client, data, _match)
|
15
15
|
client.say(channel: data.channel, text: [HELP, SlackRubyBotServer::INFO].join("\n"))
|
16
16
|
client.say(channel: data.channel, gif: 'help')
|
@@ -11,6 +11,6 @@ describe 'API' do
|
|
11
11
|
get '/api'
|
12
12
|
expect(last_response.status).to eq 200
|
13
13
|
links = JSON.parse(last_response.body)['_links']
|
14
|
-
expect(links.keys.sort).to eq(%w
|
14
|
+
expect(links.keys.sort).to eq(%w[self status team teams].sort)
|
15
15
|
end
|
16
16
|
end
|
@@ -6,7 +6,7 @@ require 'active_record'
|
|
6
6
|
require 'database_cleaner'
|
7
7
|
require 'slack-ruby-bot-server/rspec'
|
8
8
|
|
9
|
-
db_config = YAML.
|
9
|
+
db_config = YAML.safe_load(File.read(File.expand_path('../config/postgresql.yml', __dir__)), [], [], true)[ENV['RACK_ENV']]
|
10
10
|
ActiveRecord::Tasks::DatabaseTasks.create(db_config)
|
11
11
|
ActiveRecord::Base.establish_connection(db_config)
|
12
12
|
|
@@ -1,19 +1,19 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'mongoid'
|
4
|
-
gem 'slack-ruby-bot-server', path: '../../'
|
5
4
|
gem 'newrelic-slack-ruby-bot'
|
5
|
+
gem 'slack-ruby-bot-server', path: '../../'
|
6
6
|
|
7
7
|
gem 'kaminari-mongoid'
|
8
8
|
gem 'mongoid-scroll'
|
9
9
|
|
10
10
|
group :test do
|
11
|
-
gem '
|
12
|
-
gem 'rspec'
|
11
|
+
gem 'database_cleaner'
|
13
12
|
gem 'fabrication'
|
14
13
|
gem 'faker'
|
14
|
+
gem 'rack-test'
|
15
|
+
gem 'rake'
|
16
|
+
gem 'rspec'
|
15
17
|
gem 'vcr'
|
16
18
|
gem 'webmock'
|
17
|
-
gem 'database_cleaner'
|
18
|
-
gem 'rack-test'
|
19
19
|
end
|
@@ -10,7 +10,7 @@ help - get this helpful message
|
|
10
10
|
whoami - print your username
|
11
11
|
|
12
12
|
```
|
13
|
-
EOS
|
13
|
+
EOS
|
14
14
|
def self.call(client, data, _match)
|
15
15
|
client.say(channel: data.channel, text: [HELP, SlackRubyBotServer::INFO].join("\n"))
|
16
16
|
client.say(channel: data.channel, gif: 'help')
|
@@ -11,6 +11,6 @@ describe 'API' do
|
|
11
11
|
get '/api'
|
12
12
|
expect(last_response.status).to eq 200
|
13
13
|
links = JSON.parse(last_response.body)['_links']
|
14
|
-
expect(links.keys.sort).to eq(%w
|
14
|
+
expect(links.keys.sort).to eq(%w[self status team teams].sort)
|
15
15
|
end
|
16
16
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'slack-ruby-bot-server/version'
|
5
4
|
|
@@ -15,15 +14,15 @@ Gem::Specification.new do |spec|
|
|
15
14
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
16
15
|
spec.require_paths = ['lib']
|
17
16
|
|
18
|
-
spec.add_dependency 'slack-ruby-bot'
|
19
17
|
spec.add_dependency 'celluloid-io'
|
20
|
-
spec.add_dependency '
|
18
|
+
spec.add_dependency 'foreman'
|
21
19
|
spec.add_dependency 'grape'
|
22
|
-
spec.add_dependency 'grape-swagger'
|
23
20
|
spec.add_dependency 'grape-roar', '>= 0.4.0'
|
24
|
-
spec.add_dependency '
|
21
|
+
spec.add_dependency 'grape-swagger'
|
25
22
|
spec.add_dependency 'kaminari-grape'
|
23
|
+
spec.add_dependency 'rack-cors'
|
26
24
|
spec.add_dependency 'rack-rewrite'
|
27
25
|
spec.add_dependency 'rack-server-pages'
|
28
|
-
spec.add_dependency '
|
26
|
+
spec.add_dependency 'slack-ruby-bot'
|
27
|
+
spec.add_dependency 'unicorn'
|
29
28
|
end
|
data/tasks/db.rake
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-ruby-bot-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: celluloid-io
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: foreman
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: grape
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: grape
|
56
|
+
name: grape-roar
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.4.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.4.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: grape-swagger
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,19 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: grape
|
84
|
+
name: kaminari-grape
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0
|
89
|
+
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rack-cors
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rack-rewrite
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: rack-
|
126
|
+
name: rack-server-pages
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: slack-ruby-bot
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: unicorn
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
@@ -225,6 +225,7 @@ files:
|
|
225
225
|
- lib/slack-ruby-bot-server/models/team/activerecord.rb
|
226
226
|
- lib/slack-ruby-bot-server/models/team/methods.rb
|
227
227
|
- lib/slack-ruby-bot-server/models/team/mongoid.rb
|
228
|
+
- lib/slack-ruby-bot-server/ping.rb
|
228
229
|
- lib/slack-ruby-bot-server/rspec.rb
|
229
230
|
- lib/slack-ruby-bot-server/rspec/fabricators/team.rb
|
230
231
|
- lib/slack-ruby-bot-server/server.rb
|
@@ -294,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
294
295
|
version: '0'
|
295
296
|
requirements: []
|
296
297
|
rubyforge_project:
|
297
|
-
rubygems_version: 2.6.
|
298
|
+
rubygems_version: 2.6.12
|
298
299
|
signing_key:
|
299
300
|
specification_version: 4
|
300
301
|
summary: A Grape API serving a Slack bot to multiple teams.
|