slacks 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slacks/channel.rb +4 -0
- data/lib/slacks/connection.rb +12 -9
- data/lib/slacks/driver.rb +4 -0
- data/lib/slacks/event.rb +4 -0
- data/lib/slacks/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29bd178310f09e497ba17e74419960644e44cabd
|
4
|
+
data.tar.gz: 74366336ea39592f1cee2f977e32d8d38cb9dc61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 871eeaba13d8348e75f6b95995d496c81d892f6feb1d12f8d40d590d6bd9748d0dd926f439bbcec9c705a32e5346b09133116ec265029e0de609e15def3e687f
|
7
|
+
data.tar.gz: f490281f500512607a9e6d617e5f48e2df9a7f1d63db9dbeadef2e47cb75eb3dc5152fc53b9355a630e7928be6e351661ae5187a272d2c678b384655e94988e7
|
data/lib/slacks/channel.rb
CHANGED
data/lib/slacks/connection.rb
CHANGED
@@ -72,28 +72,29 @@ module Slacks
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
def typing_on(channel)
|
76
|
+
websocket.write MultiJson.dump(type: "typing", channel: to_channel_id(channel))
|
77
|
+
end
|
78
|
+
|
75
79
|
|
76
80
|
|
77
81
|
def listen!(callbacks)
|
78
82
|
response = api("rtm.start")
|
79
|
-
|
80
83
|
unless response["ok"]
|
81
84
|
raise MigrationInProgress if response["error"] == "migration_in_progress"
|
82
85
|
raise ResponseError.new(response, response["error"])
|
83
86
|
end
|
84
|
-
|
85
87
|
store_context!(response)
|
86
88
|
|
89
|
+
@websocket = Slacks::Driver.new
|
90
|
+
websocket.connect_to websocket_url
|
87
91
|
callbacks.connected
|
88
92
|
|
89
|
-
|
90
|
-
client.connect_to websocket_url
|
91
|
-
|
92
|
-
client.on(:error) do |event|
|
93
|
+
websocket.on(:error) do |event|
|
93
94
|
raise ConnectionError.new(event)
|
94
95
|
end
|
95
96
|
|
96
|
-
|
97
|
+
websocket.on(:message) do |data|
|
97
98
|
case data["type"]
|
98
99
|
when EVENT_GROUP_JOINED
|
99
100
|
group = data["channel"]
|
@@ -114,7 +115,7 @@ module Slacks
|
|
114
115
|
end
|
115
116
|
end
|
116
117
|
|
117
|
-
|
118
|
+
websocket.main_loop
|
118
119
|
|
119
120
|
rescue EOFError
|
120
121
|
# Slack hung up on us, we'll ask for a new WebSocket URL and reconnect.
|
@@ -180,7 +181,8 @@ module Slacks
|
|
180
181
|
:group_id_by_name,
|
181
182
|
:channels_by_id,
|
182
183
|
:channel_id_by_name,
|
183
|
-
:websocket_url
|
184
|
+
:websocket_url,
|
185
|
+
:websocket
|
184
186
|
|
185
187
|
|
186
188
|
|
@@ -204,6 +206,7 @@ module Slacks
|
|
204
206
|
|
205
207
|
|
206
208
|
def to_channel_id(name)
|
209
|
+
return name.id if name.is_a?(Slacks::Channel)
|
207
210
|
return name if name =~ /^[DGC]/ # this already looks like a channel id
|
208
211
|
return get_dm_for_username(name) if name.start_with?("@")
|
209
212
|
return to_group_id(name) unless name.start_with?("#")
|
data/lib/slacks/driver.rb
CHANGED
data/lib/slacks/event.rb
CHANGED
data/lib/slacks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slacks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket-driver
|