ruboty-slack_rtm 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/ruboty/adapters/slack_rtm.rb +12 -8
- data/lib/ruboty/slack_rtm/version.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: a6af23e91d8c040f4b3c9143a5cf61474005c322
|
4
|
+
data.tar.gz: e55ee6a99c6f7e4c1f6ca82a845000e69071e058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a74459fdc1c6a8bf9dd7275b6c6f0f5514049a9aedf4a8ab5f42dd855016eeb8952dbf02c079841521c973d58704beebaad8c82fd80ce1ac3cc11fb7063a099c
|
7
|
+
data.tar.gz: 0a5ba19b31de2fed0825f21f26751806e5f6f35b1d29094130808bc1f384497a6ea6b0daff25206cf3ede3e30b1b329493fad54bc2e4af7181f4849b8e9996a9
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ gem 'ruboty-slack_rtm'
|
|
13
13
|
## ENV
|
14
14
|
|
15
15
|
- `SLACK_TOKEN`: Account's token. get one on https://api.slack.com/web#basics
|
16
|
-
- `
|
16
|
+
- `SLACK_EXPOSE_CHANNEL_NAME`: if this set to 1, `message.to` will be channel name instead of id (optional)
|
17
17
|
|
18
18
|
This adapter doesn't require a real user account. Using with bot integration's API token is recommended.
|
19
19
|
See: https://api.slack.com/bot-users
|
@@ -7,7 +7,7 @@ module Ruboty
|
|
7
7
|
module Adapters
|
8
8
|
class SlackRTM < Base
|
9
9
|
env :SLACK_TOKEN, "Account's token. get one on https://api.slack.com/web#basics"
|
10
|
-
env :
|
10
|
+
env :SLACK_EXPOSE_CHANNEL_NAME, "if this set to 1, message.to will be channel name instead of id", optional: true
|
11
11
|
|
12
12
|
def run
|
13
13
|
init
|
@@ -74,11 +74,11 @@ module Ruboty
|
|
74
74
|
@realtime ||= ::SlackRTM::Client.new(websocket_url: url)
|
75
75
|
end
|
76
76
|
|
77
|
-
def
|
78
|
-
if @
|
79
|
-
@
|
77
|
+
def expose_channel_name?
|
78
|
+
if @expose_channel_name.nil?
|
79
|
+
@expose_channel_name = ENV['SLACK_EXPOSE_CHANNEL_NAME'] == '1'
|
80
80
|
else
|
81
|
-
@
|
81
|
+
@expose_channel_name
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -93,13 +93,17 @@ module Ruboty
|
|
93
93
|
user = user_info(data['user']) || {}
|
94
94
|
|
95
95
|
channel = channel_info(data['channel'])
|
96
|
-
|
96
|
+
if channel
|
97
|
+
channel_to = expose_channel_name? ? "##{channel['name']}" : channel['id']
|
98
|
+
else # direct message
|
99
|
+
channel_to = data['channel']
|
100
|
+
end
|
97
101
|
|
98
102
|
robot.receive(
|
99
103
|
body: data['text'],
|
100
|
-
from:
|
104
|
+
from: data['channel'],
|
101
105
|
from_name: user['name'],
|
102
|
-
to:
|
106
|
+
to: channel_to,
|
103
107
|
channel: channel,
|
104
108
|
user: user,
|
105
109
|
mention_to: data['mention_to'],
|