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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45e73d77b1b4391c773714eb6f44b0221ad8dabf
4
- data.tar.gz: b97942197c1b6ac18f0b29a7bbf11bcb1fbdb97a
3
+ metadata.gz: a6af23e91d8c040f4b3c9143a5cf61474005c322
4
+ data.tar.gz: e55ee6a99c6f7e4c1f6ca82a845000e69071e058
5
5
  SHA512:
6
- metadata.gz: 196669e7298354cc24f308c5b95634c169b4cbb655163fd13f99aff566f06e4fe0f8157fe07cb81b72efb8ade73bcf6d5875e5e88c98634c96718fd2823cf3cc
7
- data.tar.gz: f30da17bd38608e2d2b0914cc85d1f8519607a046f77d474eceab2cdc6d72211b33fc784464e46deb10db75ee31b360a2281bac74e70438f76e5cc639f88d3c7
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
- - `SLACK_EXPOSE_CHANNEL_NAME_AS_FROM`: if this set to 1, `message.from` will be channel name instead of id (optional)
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 :SLACK_EXPOSE_CHANNEL_NAME_AS_FROM, "if this set to 1, message.from will be channel name instead of id", optional: true
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 expose_channel_name_as_from?
78
- if @expose_channel_name_as_from.nil?
79
- @expose_channel_name_as_from = ENV['SLACK_EXPOSE_CHANNEL_NAME_AS_FROM'] == '1'
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
- @expose_channel_name_as_from
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
- channel_from = expose_channel_name_as_from? ? "##{channel['name']}" : channel['id']
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: channel_from,
104
+ from: data['channel'],
101
105
  from_name: user['name'],
102
- to: data['channel'],
106
+ to: channel_to,
103
107
  channel: channel,
104
108
  user: user,
105
109
  mention_to: data['mention_to'],
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module SlackRTM
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-slack_rtm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Kusano