slacky 0.3.2 → 0.3.3
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/Gemfile.lock +21 -17
- data/lib/slacky.rb +1 -0
- data/lib/slacky/bot.rb +8 -13
- data/lib/slacky/cronner.rb +16 -0
- data/lib/slacky/version.rb +1 -1
- data/slacky.gemspec +3 -4
- metadata +10 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f64d6b38573e8b85b0902c5e8c8445aee9f13a6d9af4228e9710c7b6d0c1f381
|
|
4
|
+
data.tar.gz: 9b95b176b787e8371a3047d7f10503993d2431f05580e87eadca417ef2e3cc7b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f3be5fad70e8f134037fab97543758cfdd051838545d510bae177eff11c26992c45b9a332fc684782a79bad3b5ecc4bd8433cc50084044c5712010ebfb0336c
|
|
7
|
+
data.tar.gz: b8a76cec99a509b7d46ddfa90ccabe165682b52aa7ecaedb0c6f8e17b9af3b307031deea5c96cabec98f227dd81d9502dfd99f1d397f8f12cef4ea1024aef7b0
|
data/Gemfile.lock
CHANGED
|
@@ -1,48 +1,51 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
slacky (0.3.
|
|
4
|
+
slacky (0.3.3)
|
|
5
|
+
async-websocket (~> 0.8.0)
|
|
5
6
|
dotenv
|
|
6
|
-
|
|
7
|
-
eventmachine
|
|
8
|
-
faye-websocket
|
|
7
|
+
parse-cron
|
|
9
8
|
pg
|
|
10
|
-
slack-ruby-client
|
|
9
|
+
slack-ruby-client
|
|
11
10
|
tzinfo
|
|
12
11
|
tzinfo-data
|
|
13
12
|
|
|
14
13
|
GEM
|
|
15
14
|
remote: http://rubygems.org/
|
|
16
15
|
specs:
|
|
17
|
-
activesupport (5.
|
|
16
|
+
activesupport (5.2.3)
|
|
18
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
19
18
|
i18n (>= 0.7, < 2)
|
|
20
19
|
minitest (~> 5.1)
|
|
21
20
|
tzinfo (~> 1.1)
|
|
22
|
-
|
|
21
|
+
async (1.20.0)
|
|
22
|
+
console (~> 1.0)
|
|
23
|
+
nio4r (~> 2.3)
|
|
24
|
+
timers (~> 4.1)
|
|
25
|
+
async-io (1.23.3)
|
|
26
|
+
async (~> 1.14)
|
|
27
|
+
async-websocket (0.8.0)
|
|
28
|
+
async-io
|
|
29
|
+
websocket-driver (~> 0.7.0)
|
|
30
|
+
concurrent-ruby (1.1.5)
|
|
31
|
+
console (1.4.0)
|
|
23
32
|
dotenv (2.7.4)
|
|
24
|
-
em-cron (0.2.0)
|
|
25
|
-
eventmachine
|
|
26
|
-
parse-cron (~> 0.1)
|
|
27
|
-
eventmachine (1.2.7)
|
|
28
33
|
factory_girl (4.9.0)
|
|
29
34
|
activesupport (>= 3.0.0)
|
|
30
35
|
faraday (0.15.4)
|
|
31
36
|
multipart-post (>= 1.2, < 3)
|
|
32
37
|
faraday_middleware (0.13.1)
|
|
33
38
|
faraday (>= 0.7.4, < 1.0)
|
|
34
|
-
faye-websocket (0.10.9)
|
|
35
|
-
eventmachine (>= 0.12.0)
|
|
36
|
-
websocket-driver (>= 0.5.1)
|
|
37
39
|
gli (2.18.1)
|
|
38
40
|
hashie (3.6.0)
|
|
39
|
-
i18n (1.
|
|
41
|
+
i18n (1.6.0)
|
|
40
42
|
concurrent-ruby (~> 1.0)
|
|
41
43
|
minitest (5.11.3)
|
|
42
44
|
multipart-post (2.1.1)
|
|
45
|
+
nio4r (2.4.0)
|
|
43
46
|
parse-cron (0.1.4)
|
|
44
47
|
pg (1.1.4)
|
|
45
|
-
rake (12.3.
|
|
48
|
+
rake (12.3.2)
|
|
46
49
|
slack-ruby-client (0.14.2)
|
|
47
50
|
activesupport
|
|
48
51
|
faraday (>= 0.9)
|
|
@@ -51,9 +54,10 @@ GEM
|
|
|
51
54
|
hashie
|
|
52
55
|
websocket-driver
|
|
53
56
|
thread_safe (0.3.6)
|
|
57
|
+
timers (4.3.0)
|
|
54
58
|
tzinfo (1.2.5)
|
|
55
59
|
thread_safe (~> 0.1)
|
|
56
|
-
tzinfo-data (1.2019.
|
|
60
|
+
tzinfo-data (1.2019.2)
|
|
57
61
|
tzinfo (>= 1.0.0)
|
|
58
62
|
websocket-driver (0.7.1)
|
|
59
63
|
websocket-extensions (>= 0.1.0)
|
data/lib/slacky.rb
CHANGED
data/lib/slacky/bot.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'slack-ruby-client'
|
|
2
2
|
require 'set'
|
|
3
3
|
require 'tzinfo'
|
|
4
|
-
require 'em/cron'
|
|
5
4
|
|
|
6
5
|
module Slacky
|
|
7
6
|
class Bot
|
|
@@ -24,7 +23,7 @@ module Slacky
|
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
Slack::RealTime.configure do |cfg|
|
|
27
|
-
cfg.concurrency = Slack::RealTime::Concurrency::
|
|
26
|
+
cfg.concurrency = Slack::RealTime::Concurrency::Async
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
@client = Slack::RealTime::Client.new
|
|
@@ -159,15 +158,10 @@ module Slacky
|
|
|
159
158
|
|
|
160
159
|
Thread.report_on_exception = false if defined? Thread.report_on_exception
|
|
161
160
|
|
|
162
|
-
@client.start! do
|
|
163
|
-
# This code must run in the callback / block because it requires EventMachine
|
|
164
|
-
# be running before it gets executed. If we can find another way to handle
|
|
165
|
-
# this cron syntax we can move to using the async-websocket library instead
|
|
166
|
-
# of EventMachine. -mike
|
|
167
|
-
|
|
161
|
+
@client.start! do |driver|
|
|
168
162
|
@cron_handlers.each do |h|
|
|
169
163
|
cron, handler = h.values_at :cron, :handler
|
|
170
|
-
|
|
164
|
+
Cronner.schedule cron do |time|
|
|
171
165
|
handler.call
|
|
172
166
|
end
|
|
173
167
|
end
|
|
@@ -218,10 +212,11 @@ module Slacky
|
|
|
218
212
|
end
|
|
219
213
|
|
|
220
214
|
on :pong do |data|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
215
|
+
if data.stamp
|
|
216
|
+
now = Time.now.to_f
|
|
217
|
+
delta = now - data.stamp
|
|
218
|
+
raise Exception.new("Slow ping pong response: #{delta}s") if delta > 5
|
|
219
|
+
end
|
|
225
220
|
end
|
|
226
221
|
end
|
|
227
222
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'async'
|
|
2
|
+
require 'parse-cron'
|
|
3
|
+
|
|
4
|
+
module Slacky
|
|
5
|
+
class Cronner
|
|
6
|
+
def self.schedule(cron_string, &blk)
|
|
7
|
+
cron_parser = CronParser.new(cron_string)
|
|
8
|
+
next_time = cron_parser.next(Time.now)
|
|
9
|
+
Async do |task|
|
|
10
|
+
task.sleep next_time - Time.now
|
|
11
|
+
result = yield next_time
|
|
12
|
+
schedule(cron_string, &blk) unless result == :stop
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/slacky/version.rb
CHANGED
data/slacky.gemspec
CHANGED
|
@@ -16,11 +16,10 @@ Gem::Specification.new do |s|
|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
17
17
|
s.require_paths = ["lib"]
|
|
18
18
|
|
|
19
|
-
s.add_runtime_dependency 'slack-ruby-client'
|
|
19
|
+
s.add_runtime_dependency 'slack-ruby-client'
|
|
20
20
|
s.add_runtime_dependency 'pg'
|
|
21
|
-
s.add_runtime_dependency '
|
|
22
|
-
s.add_runtime_dependency '
|
|
23
|
-
s.add_runtime_dependency 'em-cron'
|
|
21
|
+
s.add_runtime_dependency 'async-websocket', "~> 0.8.0"
|
|
22
|
+
s.add_runtime_dependency 'parse-cron'
|
|
24
23
|
s.add_runtime_dependency 'tzinfo'
|
|
25
24
|
s.add_runtime_dependency 'tzinfo-data'
|
|
26
25
|
s.add_runtime_dependency 'dotenv'
|
metadata
CHANGED
|
@@ -1,31 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slacky
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Wynholds
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: slack-ruby-client
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.14'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0.14'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: pg
|
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
|
30
16
|
requirements:
|
|
31
17
|
- - ">="
|
|
@@ -39,7 +25,7 @@ dependencies:
|
|
|
39
25
|
- !ruby/object:Gem::Version
|
|
40
26
|
version: '0'
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
28
|
+
name: pg
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
44
30
|
requirements:
|
|
45
31
|
- - ">="
|
|
@@ -53,21 +39,21 @@ dependencies:
|
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
40
|
version: '0'
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
42
|
+
name: async-websocket
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
58
44
|
requirements:
|
|
59
|
-
- - "
|
|
45
|
+
- - "~>"
|
|
60
46
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
47
|
+
version: 0.8.0
|
|
62
48
|
type: :runtime
|
|
63
49
|
prerelease: false
|
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
51
|
requirements:
|
|
66
|
-
- - "
|
|
52
|
+
- - "~>"
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
54
|
+
version: 0.8.0
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
56
|
+
name: parse-cron
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
59
|
- - ">="
|
|
@@ -183,6 +169,7 @@ files:
|
|
|
183
169
|
- lib/slacky/channel.rb
|
|
184
170
|
- lib/slacky/cli.rb
|
|
185
171
|
- lib/slacky/config.rb
|
|
172
|
+
- lib/slacky/cronner.rb
|
|
186
173
|
- lib/slacky/message.rb
|
|
187
174
|
- lib/slacky/service.rb
|
|
188
175
|
- lib/slacky/user.rb
|