slack-ruby-client 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +10 -8
- data/examples/hi_real_time/Gemfile +1 -1
- data/examples/hi_real_time_async_celluloid/Gemfile +1 -1
- data/lib/slack/real_time/concurrency/celluloid.rb +9 -2
- data/lib/slack/version.rb +1 -1
- metadata +3 -5
- data/examples/hi_real_time_async/Gemfile +0 -5
- data/examples/hi_real_time_async/hi.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e1cd2d1d9cbc3663ae0616b48855f34454e8ad4
|
4
|
+
data.tar.gz: 0e7cc755aa5623005a60d5e2d7d62a8c70596bdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3080aca20cc3a8d3f2d873f9192842806db73f18297e0b41784f5bd3d028d18eabda168331b1f3d883a1699c39f1776adf3a6d5a0881b402408b480f3156c6fd
|
7
|
+
data.tar.gz: a8b263005432280abf2b89f6d2495eb63890024336ea2d9f19e04d2078c0c45704acdbda38cb018b75d5afd651ae226b9dbe6e7189d2e6caf5e26d33ad0a3fba
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
### 0.7.3 (5/14/2016)
|
2
|
+
|
3
|
+
* [#90](https://github.com/dblock/slack-ruby-client/issues/90): Fix: Celluloid concurrency handles server-side connection closing - [@dblock](https://github.com/dblock).
|
4
|
+
|
1
5
|
### 0.7.2 (5/5/2016)
|
2
6
|
|
3
7
|
* [#84](https://github.com/dblock/slack-ruby-client/issues/84): Fix: Celluloid concurrency doesn't parallelize the connection setup - [@dblock](https://github.com/dblock).
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ A Ruby client for the Slack [Web](https://api.slack.com/web) and [RealTime Messa
|
|
18
18
|
|
19
19
|
## Stable Release
|
20
20
|
|
21
|
-
You're reading the documentation for the **
|
21
|
+
You're reading the documentation for the **next** release of slack-ruby-client. Please see the documentation for the [last stable release, v0.7.2](https://github.com/dblock/slack-ruby-client/blob/v0.7.2/README.md) unless you're integrating with HEAD. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
22
22
|
|
23
23
|
## Installation
|
24
24
|
|
@@ -306,18 +306,14 @@ Slack::RealTime.configure do |config|
|
|
306
306
|
end
|
307
307
|
```
|
308
308
|
|
309
|
-
Use `client.start_async` instead of `client.start
|
309
|
+
Use `client.start_async` instead of `client.start!`. A good example of such application is [slack-bot-server](https://github.com/dblock/slack-bot-server).
|
310
310
|
|
311
311
|
```ruby
|
312
312
|
client = Slack::RealTime::Client.new
|
313
313
|
|
314
|
-
|
315
|
-
client.start_async
|
316
|
-
end
|
314
|
+
client.start_async
|
317
315
|
```
|
318
316
|
|
319
|
-
See a fully working example in [examples/hi_real_time_async](examples/hi_real_time_async/hi.rb).
|
320
|
-
|
321
317
|
##### Faye::Websocket with Eventmachine
|
322
318
|
|
323
319
|
Add the following to your Gemfile.
|
@@ -326,14 +322,20 @@ Add the following to your Gemfile.
|
|
326
322
|
gem 'faye-websocket'
|
327
323
|
```
|
328
324
|
|
325
|
+
See a fully working example in [examples/hi_real_time_async_eventmachine](examples/hi_real_time_async_eventmachine/hi.rb).
|
326
|
+
|
329
327
|
##### Celluloid
|
330
328
|
|
331
329
|
Add the following to your Gemfile.
|
332
330
|
|
333
331
|
```
|
334
|
-
gem 'celluloid-io'
|
332
|
+
gem 'celluloid-io', require: ['celluloid/current', 'celluloid/io']
|
335
333
|
```
|
336
334
|
|
335
|
+
See a fully working example in [examples/hi_real_time_async_celluloid](examples/hi_real_time_async_celluloid/hi.rb).
|
336
|
+
|
337
|
+
Require
|
338
|
+
|
337
339
|
### Message Parsing
|
338
340
|
|
339
341
|
All text in Slack uses the same [system of escaping](https://api.slack.com/docs/formatting): chat messages, direct messages, file comments, etc. Use [Slack::Messages::Formatting](lib/slack/messages/formatting.rb) to unescape incoming messages. This comes handy, for example, you want to treat all input to a real time bot as plain text.
|
@@ -30,12 +30,19 @@ module Slack
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def run_loop
|
33
|
+
@closing = false
|
33
34
|
@socket = build_socket
|
34
35
|
@connected = @socket.connect
|
35
36
|
driver.start
|
36
37
|
loop { read } if socket
|
37
|
-
rescue EOFError
|
38
|
-
#
|
38
|
+
rescue EOFError => e
|
39
|
+
logger.debug("#{self.class}##{__method__}") { e }
|
40
|
+
driver.emit(:close, WebSocket::Driver::CloseEvent.new(1001, 'server closed connection')) unless @closing
|
41
|
+
end
|
42
|
+
|
43
|
+
def close
|
44
|
+
@closing = true
|
45
|
+
driver.close
|
39
46
|
end
|
40
47
|
|
41
48
|
def read
|
data/lib/slack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -257,8 +257,6 @@ files:
|
|
257
257
|
- examples/hi_real_time_and_web/Gemfile
|
258
258
|
- examples/hi_real_time_and_web/hi.gif
|
259
259
|
- examples/hi_real_time_and_web/hi.rb
|
260
|
-
- examples/hi_real_time_async/Gemfile
|
261
|
-
- examples/hi_real_time_async/hi.rb
|
262
260
|
- examples/hi_real_time_async_celluloid/Gemfile
|
263
261
|
- examples/hi_real_time_async_celluloid/Procfile
|
264
262
|
- examples/hi_real_time_async_celluloid/hi.rb
|
@@ -440,7 +438,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
440
438
|
version: 1.3.6
|
441
439
|
requirements: []
|
442
440
|
rubyforge_project:
|
443
|
-
rubygems_version: 2.
|
441
|
+
rubygems_version: 2.4.8
|
444
442
|
signing_key:
|
445
443
|
specification_version: 4
|
446
444
|
summary: Slack Web and RealTime API client.
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'slack-ruby-client'
|
2
|
-
|
3
|
-
Slack.configure do |config|
|
4
|
-
config.token = ENV['SLACK_API_TOKEN']
|
5
|
-
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
|
6
|
-
end
|
7
|
-
|
8
|
-
client = Slack::RealTime::Client.new
|
9
|
-
|
10
|
-
client.on :hello do
|
11
|
-
puts "Successfully connected, welcome '#{client.self.name}' to the '#{client.team.name}' team at https://#{client.team.domain}.slack.com."
|
12
|
-
end
|
13
|
-
|
14
|
-
client.on :message do |data|
|
15
|
-
puts data
|
16
|
-
|
17
|
-
client.typing channel: data.channel
|
18
|
-
|
19
|
-
case data.text
|
20
|
-
when 'bot hi' then
|
21
|
-
client.message channel: data.channel, text: "Hi <@#{data.user}>!"
|
22
|
-
when /^bot/ then
|
23
|
-
client.message channel: data.channel, text: "Sorry <@#{data.user}>, what?"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
EM.run do
|
28
|
-
client.start_async
|
29
|
-
end
|