slack-smart-bot 1.1.0 → 1.1.1
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/README.md +1 -0
- data/lib/slack-smart-bot.rb +10 -0
- data/lib/slack/smart-bot/commands/on_bot/admin/start_routine.rb +13 -0
- data/lib/slack/smart-bot/utils.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f19a34da68467369374e1e2bdf6a59413b95c97c27f8a7a975282c1e94ec04f6
|
4
|
+
data.tar.gz: bceb757371af914f3c3182c6c51bdc28b759f5dbb7e83392f032bc91f5a44bfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f94184d31ab800e6d21405c6886b2469b8c4e38effedd6e23be84b5af2b4d00ad2f908e2ae74c7d8e7574b7fd62427bbb94c305760294430370d7547326425f
|
7
|
+
data.tar.gz: 52a4d5228a5f4ef0725711e0356b49010f04750c939cdcd6bb1d56556633692ba610145f04626af1375764fcf8677427ac720bd0eeb26872a57587482c9d664a
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/slack-smart-bot)
|
4
4
|
[](https://github.com/MarioRuiz/slack-smart-bot)
|
5
|
+
[](https://coveralls.io/github/MarioRuiz/slack-smart-bot?branch=master)
|
5
6
|
|
6
7
|
Create a Slack bot that is really smart and so easy to expand.
|
7
8
|
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -231,6 +231,16 @@ class SlackSmartBot
|
|
231
231
|
end
|
232
232
|
update_routines()
|
233
233
|
|
234
|
+
if config.simulate #not necessary to wait until bot started (client.on :hello)
|
235
|
+
@routines.each do |ch, rout|
|
236
|
+
rout.each do |k, v|
|
237
|
+
if !v[:running] and v[:channel_name] == config.channel
|
238
|
+
create_routine_thread(k)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
234
244
|
client.on :close do |_data|
|
235
245
|
m = "Connection closing, exiting. #{Time.now}"
|
236
246
|
@logger.info m
|
@@ -15,6 +15,19 @@ class SlackSmartBot
|
|
15
15
|
respond "It's only possible to start routines from MASTER channel from a direct message with the bot.", dest
|
16
16
|
elsif @routines.key?(@channel_id) and @routines[@channel_id].key?(name)
|
17
17
|
@routines[@channel_id][name][:status] = :on
|
18
|
+
if @routines[@channel_id][name][:at]!=''
|
19
|
+
started = Time.now
|
20
|
+
if started.strftime("%k:%M:%S") < @routines[@channel_id][name][:at]
|
21
|
+
nt = @routines[@channel_id][name][:at].split(":")
|
22
|
+
next_run = Time.new(started.year, started.month, started.day, nt[0], nt[1], nt[2])
|
23
|
+
else
|
24
|
+
next_run = started + (24 * 60 * 60) # one more day
|
25
|
+
nt = @routines[@channel_id][name][:at].split(":")
|
26
|
+
next_run = Time.new(next_run.year, next_run.month, next_run.day, nt[0], nt[1], nt[2])
|
27
|
+
end
|
28
|
+
@routines[@channel_id][name][:next_run] = next_run.to_s
|
29
|
+
@routines[@channel_id][name][:sleeping] = (next_run - started).ceil
|
30
|
+
end
|
18
31
|
update_routines()
|
19
32
|
respond "The routine *`#{name}`* has been started. The change will take effect in less than 30 secs.", dest
|
20
33
|
else
|
@@ -116,7 +116,7 @@ class SlackSmartBot
|
|
116
116
|
elapsed = 0
|
117
117
|
require "time"
|
118
118
|
every_in_seconds = Time.parse(@routines[@channel_id][name][:next_run]) - Time.now
|
119
|
-
elsif @routines[@channel_id][name][:
|
119
|
+
elsif @routines[@channel_id][name][:at] != "" #coming from start after pause for 'at'
|
120
120
|
if started.strftime("%k:%M:%S") < @routines[@channel_id][name][:at]
|
121
121
|
nt = @routines[@channel_id][name][:at].split(":")
|
122
122
|
next_run = Time.new(started.year, started.month, started.day, nt[0], nt[1], nt[2])
|
@@ -135,9 +135,9 @@ class SlackSmartBot
|
|
135
135
|
@routines[@channel_id][name][:next_run] = (started + every_in_seconds).to_s
|
136
136
|
end
|
137
137
|
@routines[@channel_id][name][:running] = true
|
138
|
-
@routines[@channel_id][name][:sleeping] = every_in_seconds - elapsed
|
138
|
+
@routines[@channel_id][name][:sleeping] = (every_in_seconds - elapsed).ceil
|
139
139
|
update_routines()
|
140
|
-
sleep(
|
140
|
+
sleep(@routines[@channel_id][name][:sleeping]) unless elapsed > every_in_seconds
|
141
141
|
else
|
142
142
|
sleep 30
|
143
143
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-smart-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|