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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc5284b6978388549e27e9f7e438064e0eb36dbe6528363e966cb024d5cad4e7
4
- data.tar.gz: a3dea56debef65e4e9cd3b3e2733571721fa8e370ad97026dfe35f9836f4f285
3
+ metadata.gz: f19a34da68467369374e1e2bdf6a59413b95c97c27f8a7a975282c1e94ec04f6
4
+ data.tar.gz: bceb757371af914f3c3182c6c51bdc28b759f5dbb7e83392f032bc91f5a44bfe
5
5
  SHA512:
6
- metadata.gz: c2b70ce96e94bf8b27e03694becf8abb7c7bec14a130c6d887bddc8db65f3ec638197603798130056cdce4e30ca3b211317134a363035680fa547b83fcd30a1d
7
- data.tar.gz: 376585b302cd52381fed5539c4fc00d75f3d93c7c530d042bdf73ee6acf3e8c1a07623a57c1823de38b3b7a9ee4be5063401caecebe17efa2f0e84b4543500fd
6
+ metadata.gz: 2f94184d31ab800e6d21405c6886b2469b8c4e38effedd6e23be84b5af2b4d00ad2f908e2ae74c7d8e7574b7fd62427bbb94c305760294430370d7547326425f
7
+ data.tar.gz: 52a4d5228a5f4ef0725711e0356b49010f04750c939cdcd6bb1d56556633692ba610145f04626af1375764fcf8677427ac720bd0eeb26872a57587482c9d664a
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/slack-smart-bot.svg)](https://rubygems.org/gems/slack-smart-bot)
4
4
  [![Build Status](https://travis-ci.com/MarioRuiz/slack-smart-bot.svg?branch=master)](https://github.com/MarioRuiz/slack-smart-bot)
5
+ [![Coverage Status](https://coveralls.io/repos/github/MarioRuiz/slack-smart-bot/badge.svg?branch=master)](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
 
@@ -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][:next_run] == "" and @routines[@channel_id][name][:at] != "" #coming from start after pause for 'at'
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(every_in_seconds - elapsed) unless elapsed > every_in_seconds
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.0
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-25 00:00:00.000000000 Z
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