slack-keep-presence 0.1.5 → 0.1.6

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
  SHA256:
3
- metadata.gz: 15ec47173264385948daa1bd55ed0f0bfe57773b2181bc02a2e7b9acc1c75bcf
4
- data.tar.gz: c75421ff03cf4b14127a3857a24d9f8b31c9776efc40921f45c241eb5c3063d7
3
+ metadata.gz: 6ce3531d7c5ae86aab7b3f84c86e6e443d9967940f9bd1e9cf36fab0208f10f0
4
+ data.tar.gz: 5774380e1e33479b4b5b36f3c45ee7455bf5c7c640b07186d894ccd280844342
5
5
  SHA512:
6
- metadata.gz: d1236c7f8197141e20c8f237fe6d1dafb28453cd2d08d8be1df0129b261a5132a0b6bc21cdf0cb44999c3b36181ab493a85197aa809b76bff8d18c41a866e173
7
- data.tar.gz: 4e7fc949b163bfc69876226d76b832b646be9331c6c2990fd4881b9c9c51420615ca38199bf3d337fce6a8aa44856877330cf9085921788004631b41d9178744
6
+ metadata.gz: 036aaa6bc6dc2196ae89381c8780e46b83ff6a43a0f76810f80ab45c5cb8442596af3a7eb4adfcc4a51b04df78725d568319d3430def2bd2fc51dc4fadf810ce
7
+ data.tar.gz: 36cdb7928998f3b2e03b55b5e4e0e763b5fdb2f56fdeea629b8632f5452f5e7dac5838824df0af4ba5e83e213d69d1dcae742be8b77e4c34a413a2c1b540540c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack-keep-presence (0.1.5)
4
+ slack-keep-presence (0.1.6)
5
5
  faye-websocket (~> 0.10.6)
6
6
  slack-api (~> 1.6)
7
7
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # slack-keep-presence
2
2
 
3
- Marks your user as active when auto-away kicks in
3
+ Marks a slack user as active when auto-away kicks in. Useful for keeping slack bots online.
4
4
 
5
5
  Inspired by [slack-keep-presence](https://github.com/eskerda/slack-keep-presence). This is basically a ruby port with only the presence functionality retained.
6
6
 
@@ -55,7 +55,7 @@ module SlackKeepPresence
55
55
  @ws = Faye::WebSocket::Client.new(ws_url, nil, ping: 30)
56
56
 
57
57
  ws.on :open do |event|
58
- logger.info('Connected to Slack RealTime API')
58
+ logger.debug('Connected to Slack RealTime API')
59
59
 
60
60
  payload = {
61
61
  type: 'presence_sub',
@@ -76,6 +76,15 @@ module SlackKeepPresence
76
76
  next unless data['user'] == user
77
77
  next unless data['presence'] == 'away'
78
78
 
79
+ # get the status to make sure this isn't manual_away
80
+ away_info = client.users_getPresence(user: user)
81
+ logger.debug(away_info)
82
+
83
+ if away_info['manual_away']
84
+ logger.info('User marked as manual_away, skipping')
85
+ next
86
+ end
87
+
79
88
  logger.info("Presence changed to #{data['presence']}")
80
89
 
81
90
  # Slack's setActive api doesn't seem to be working.
@@ -85,6 +94,7 @@ module SlackKeepPresence
85
94
  # res = client.users_getPresence(user: user)
86
95
  # logger.debug "#{res}"
87
96
 
97
+ logger.info("Marking #{user} as active")
88
98
  ws.close
89
99
  @ws = nil
90
100
  @should_shutdown = true
@@ -95,7 +105,7 @@ module SlackKeepPresence
95
105
  ws.on [:close, :error] do |event|
96
106
  next if should_shutdown
97
107
 
98
- logger.info('Connection to Slack RealTime API terminated, reconnecting')
108
+ logger.debug('Connection to Slack RealTime API terminated, reconnecting')
99
109
  sleep 5
100
110
  start_realtime
101
111
  end
@@ -103,10 +113,10 @@ module SlackKeepPresence
103
113
 
104
114
  def set_active
105
115
  logger.info("Marking #{user} as active")
106
- res = client.users_setActive
116
+ res = client.users_setPresence(presence: 'auto', set_active: true)
107
117
  logger.debug(res)
108
118
 
109
- res = client.users_getPresence(user: user)
119
+ res = client.users_getPresence(user: user, set_active: true)
110
120
  logger.debug(res)
111
121
  end
112
122
  end
@@ -1,3 +1,3 @@
1
1
  module SlackKeepPresence
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-keep-presence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Frye
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-27 00:00:00.000000000 Z
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler