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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/slack_keep_presence.rb +14 -4
- data/lib/slack_keep_presence/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ce3531d7c5ae86aab7b3f84c86e6e443d9967940f9bd1e9cf36fab0208f10f0
|
4
|
+
data.tar.gz: 5774380e1e33479b4b5b36f3c45ee7455bf5c7c640b07186d894ccd280844342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 036aaa6bc6dc2196ae89381c8780e46b83ff6a43a0f76810f80ab45c5cb8442596af3a7eb4adfcc4a51b04df78725d568319d3430def2bd2fc51dc4fadf810ce
|
7
|
+
data.tar.gz: 36cdb7928998f3b2e03b55b5e4e0e763b5fdb2f56fdeea629b8632f5452f5e7dac5838824df0af4ba5e83e213d69d1dcae742be8b77e4c34a413a2c1b540540c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# slack-keep-presence
|
2
2
|
|
3
|
-
Marks
|
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
|
|
data/lib/slack_keep_presence.rb
CHANGED
@@ -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.
|
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.
|
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.
|
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
|
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.
|
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-
|
11
|
+
date: 2018-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|