slackbot_frd 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/slackbot-frd +13 -1
- data/lib/slackbot_frd/initializer/bot_starter.rb +6 -1
- data/lib/slackbot_frd/lib/slack_connection.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa152b1ba0a87880770f4d05ef4c542e3c8b3ecf
|
4
|
+
data.tar.gz: 3b4575361545d9aa5348587f2e9ce54ee87c68ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d97def19fe272337ff98b4f2646a3a1d19f6ee25e546e111e3799c34c92de34fea395a87d552a83035e58c08a36b6f3fdeaebe32554197c7b5e9955711ff29a
|
7
|
+
data.tar.gz: e875be0725ffbdfe47f29b31fc96411ce0bdb096330cb784533a6d3b1c1d4136213f746bc77cfd65877f33993b4f05719e2b4993e6f79547783bc4474c199267
|
data/bin/slackbot-frd
CHANGED
@@ -186,7 +186,6 @@ class SlackbotFrdBin < Thor
|
|
186
186
|
|
187
187
|
> $ slackbot-frd stop -- Stop all running bots
|
188
188
|
LONGDESC
|
189
|
-
|
190
189
|
def stop
|
191
190
|
# first kill the watcher, then kill the connection
|
192
191
|
kill_pid(watcher_pid)
|
@@ -196,6 +195,19 @@ class SlackbotFrdBin < Thor
|
|
196
195
|
delfile(ERROR_FILE)
|
197
196
|
end
|
198
197
|
|
198
|
+
desc "bump", "Kill the bots, but not the watcher"
|
199
|
+
long_desc <<-LONGDESC
|
200
|
+
bump will kill the connection process, but not the watcher.
|
201
|
+
this causes the watcher to restart the connection. This
|
202
|
+
can be helpful when your slack connection is lost but
|
203
|
+
the WSS event stream is not terminated
|
204
|
+
|
205
|
+
> $ slackbot-frd bump -- Kill all running bots
|
206
|
+
LONGDESC
|
207
|
+
def bump
|
208
|
+
kill_pid(connection_pid)
|
209
|
+
end
|
210
|
+
|
199
211
|
desc "restart", "Stop all bots and restart them"
|
200
212
|
long_desc <<-LONGDESC
|
201
213
|
restart will restart all bots
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'file-append'
|
4
4
|
require 'thor'
|
5
|
+
require 'active_support/all'
|
5
6
|
|
6
7
|
require 'slackbot_frd/lib/slack_connection'
|
7
8
|
require 'slackbot_frd/lib/bot'
|
@@ -13,7 +14,11 @@ end
|
|
13
14
|
|
14
15
|
class BotStarter
|
15
16
|
def self.start_bots(errors_file, token, botdir, enabled_bots)
|
16
|
-
bot_enabled = ->(bot)
|
17
|
+
bot_enabled = ->(bot) do
|
18
|
+
enabled_bots.empty? ||
|
19
|
+
enabled_bots.include?(bot) ||
|
20
|
+
enabled_bots.include?(bot.gsub("-", "_").camelize)
|
21
|
+
end
|
17
22
|
|
18
23
|
# Create a new Connection to pass to the bot classes
|
19
24
|
slack_connection = SlackbotFrd::SlackConnection.new(token, errors_file)
|
@@ -309,6 +309,13 @@ module SlackbotFrd
|
|
309
309
|
user
|
310
310
|
end
|
311
311
|
|
312
|
+
private
|
313
|
+
def extract_ts(message)
|
314
|
+
ts = message["ts"]
|
315
|
+
ts = message["message"]["ts"] if message["message"] && message["message"]["ts"]
|
316
|
+
ts
|
317
|
+
end
|
318
|
+
|
312
319
|
private
|
313
320
|
def extract_text(message)
|
314
321
|
text = message["text"]
|
@@ -323,7 +330,7 @@ module SlackbotFrd
|
|
323
330
|
user = extract_user(message)
|
324
331
|
channel = message["channel"]
|
325
332
|
text = extract_text(message)
|
326
|
-
ts = message
|
333
|
+
ts = extract_ts(message)
|
327
334
|
|
328
335
|
unless user
|
329
336
|
SlackbotFrd::Log.warn("#{self.class}: Chat message doesn't include user! message: #{message}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackbot_frd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|