bot_mob 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bot_mob/application.rb +7 -7
- data/lib/bot_mob/bot.rb +5 -5
- data/lib/bot_mob/inbound_message.rb +3 -3
- data/lib/bot_mob/version.rb +1 -1
- data/lib/bot_mob/wire.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b4ac52b9e58932d7a1f3b67621cc368ed2dbb25
|
4
|
+
data.tar.gz: ced498a9261d93c8a3ced4baa47cd4152e8d4ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 321de0b69949d7aac245db16b992272313f6f4c699841b8760658839ab4ec0e8e30c53d8dc6ac0206b4a251f5dc1bd4d36ab860fe40cb78fff69ad4c18dd189f
|
7
|
+
data.tar.gz: a1f8864999ec86a775f87a8fb46169da67b86895aa966f36be4c78f0dc280b87ed9224b5db83ace70ce62de7f02b864bc1880b6d4f642880764637e64b7944ee
|
data/lib/bot_mob/application.rb
CHANGED
@@ -18,11 +18,11 @@ module BotMob
|
|
18
18
|
loop { sleep(10) }
|
19
19
|
end
|
20
20
|
|
21
|
-
def add_bot(
|
22
|
-
BotMob.logger.info "Adding bot: #{
|
23
|
-
install = Install.
|
21
|
+
def add_bot(external_id)
|
22
|
+
BotMob.logger.info "Adding bot: #{external_id}"
|
23
|
+
install = Install.find_by_external_id(external_id)
|
24
24
|
if install.nil?
|
25
|
-
BotMob.logger.info "Could not find bot: #{
|
25
|
+
BotMob.logger.info "Could not find bot: #{external_id}"
|
26
26
|
return
|
27
27
|
end
|
28
28
|
|
@@ -30,9 +30,9 @@ module BotMob
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def register(install)
|
33
|
-
bot = bot_class.new(install.
|
34
|
-
@bots[install.
|
35
|
-
@bots[install.
|
33
|
+
bot = bot_class.new(install.external_id, install.token)
|
34
|
+
@bots[install.external_id] ||= bot
|
35
|
+
@bots[install.external_id].refresh
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
data/lib/bot_mob/bot.rb
CHANGED
@@ -4,10 +4,10 @@ module BotMob
|
|
4
4
|
# This is the base for all bots that will connect
|
5
5
|
# to Slack.
|
6
6
|
class Bot
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :external_id, :state
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@
|
9
|
+
def initialize(external_id, token)
|
10
|
+
@external_id = external_id
|
11
11
|
|
12
12
|
if token.nil?
|
13
13
|
@state = :inactive
|
@@ -55,7 +55,7 @@ module BotMob
|
|
55
55
|
when disconnected?
|
56
56
|
reconnect
|
57
57
|
else
|
58
|
-
logger.info "State[#{
|
58
|
+
logger.info "State[#{external_id}] - No Change"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -112,7 +112,7 @@ module BotMob
|
|
112
112
|
logger.info "Successfully connected, '#{client.team.name}' team at https://#{client.team.domain}.slack.com."
|
113
113
|
end
|
114
114
|
|
115
|
-
logger.info "State[#{
|
115
|
+
logger.info "State[#{external_id}] - #{state}"
|
116
116
|
@state = state
|
117
117
|
end
|
118
118
|
|
@@ -5,7 +5,7 @@ module BotMob
|
|
5
5
|
# messages received from Slack's Real Time API
|
6
6
|
class InboundMessage
|
7
7
|
attr_reader :source, :data, :token, :team_id, :team_domain,
|
8
|
-
:channel_id, :channel_name, :
|
8
|
+
:channel_id, :channel_name, :external_id, :user_name,
|
9
9
|
:command, :text, :bot_id, :response_url, :ts
|
10
10
|
|
11
11
|
def initialize(source, data)
|
@@ -33,7 +33,7 @@ module BotMob
|
|
33
33
|
@bot_id = data[:bot_id]
|
34
34
|
@team = data[:team]
|
35
35
|
@ts = data[:ts]
|
36
|
-
@
|
36
|
+
@external_id = data[:user_id]
|
37
37
|
end
|
38
38
|
|
39
39
|
def parse_webhook(data)
|
@@ -42,7 +42,7 @@ module BotMob
|
|
42
42
|
@team_domain = data['team_domain']
|
43
43
|
@channel_id = data['channel_id']
|
44
44
|
@channel_name = data['channel_name']
|
45
|
-
@
|
45
|
+
@external_id = data['user_id']
|
46
46
|
@user_name = data['user_name']
|
47
47
|
@command = data['command']
|
48
48
|
@text = data['text']
|
data/lib/bot_mob/version.rb
CHANGED
data/lib/bot_mob/wire.rb
CHANGED
@@ -12,7 +12,7 @@ module BotMob
|
|
12
12
|
|
13
13
|
def connect(app)
|
14
14
|
queue.subscribe do |_info, _props, body|
|
15
|
-
app.add_bot(JSON.parse(body)['
|
15
|
+
app.add_bot(JSON.parse(body)['external_id'])
|
16
16
|
end
|
17
17
|
rescue Bunny::PreconditionFailed => e
|
18
18
|
BotMob.logger.info "#{e.channel_close.reply_code}, message: #{e.channel_close.reply_text}"
|