ruboty-slack_rtm 1.6.0 → 2.0.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: 9630308dfdbf7041fdca0a1dc1a5386b051b3417
4
- data.tar.gz: efa4af910759b1c3cf9c34a5717a8726163deffa
3
+ metadata.gz: 93c08b4ce16ca7213ea2ddf212a6aaffb610fc38
4
+ data.tar.gz: 31d5e90d93ea1a8d49926ec9940d8e219a769f9d
5
5
  SHA512:
6
- metadata.gz: 6f0e1420f9f50107be9f46a3bab49b25e526af045a807cf2b6801bd3b5b132e6b1f5d201dd4527a2d7efe4b25aeb398583965eaa5dd11e0da26458ff4a33af6f
7
- data.tar.gz: 8c0cc313e1a2621853d709a0d11c3f4cdfd641c69c788886cf88993d14365c74160ff2dfbd31afea3c6d8cb562ea3ed1fc7a065571f61b6360845e562cd7ed00
6
+ metadata.gz: ae54aff21e430e74a9fb7168664de3c53155084fc3290d8576535b4c6c2c898cc4f8a0470e897d6662c273a8c819c3b239a80d88aaba6eb00eaea203aa4a3cdd
7
+ data.tar.gz: 7c0d6aea7581e8cc26052c583f1a3e6320779ea18cbd7d73bb01afe12d9c9d0f97727c6ba4cd7d507e2860ccebbeec0fb0d65e97e12e3616991ce8f46331ee02
@@ -1,7 +1,6 @@
1
1
  require 'cgi'
2
2
  require 'time'
3
3
  require 'slack'
4
- require 'slack-rtmapi'
5
4
  require 'ruboty/adapters/base'
6
5
 
7
6
  module Ruboty
@@ -68,7 +67,12 @@ module Ruboty
68
67
  end
69
68
 
70
69
  def url
71
- @url ||= ::SlackRTM.get_url(token: ENV['SLACK_TOKEN'])
70
+ @url ||= begin
71
+ response = Net::HTTP.post_form(URI.parse('https://slack.com/api/rtm.start'), token: ENV['SLACK_TOKEN'])
72
+ body = JSON.parse(response.body)
73
+
74
+ URI.parse(body['url'])
75
+ end
72
76
  end
73
77
 
74
78
  def client
@@ -76,7 +80,7 @@ module Ruboty
76
80
  end
77
81
 
78
82
  def realtime
79
- @realtime ||= ::SlackRTM::Client.new(websocket_url: url)
83
+ @realtime ||= ::Ruboty::SlackRTM::Client.new(websocket_url: url)
80
84
  end
81
85
 
82
86
  def expose_channel_name?
@@ -0,0 +1,31 @@
1
+ require 'json'
2
+ require 'websocket-client-simple'
3
+
4
+ module Ruboty
5
+ module SlackRTM
6
+ class Client
7
+ def initialize(websocket_url:)
8
+ @client = WebSocket::Client::Simple.connect(websocket_url.to_s)
9
+ @queue = Queue.new
10
+ end
11
+
12
+ def send(data)
13
+ data[:id] = Time.now.to_i * 10 + rand(10)
14
+ @queue.enq(data.to_json)
15
+ end
16
+
17
+ def on(event, &block)
18
+ @client.on(event) do |message|
19
+ block.call(JSON.parse(message.data))
20
+ end
21
+ end
22
+
23
+ def main_loop
24
+ loop do
25
+ message = @queue.deq
26
+ @client.send(message)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module SlackRTM
3
- VERSION = '1.6.0'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -1,2 +1,3 @@
1
1
  require 'ruboty/slack_rtm/version'
2
+ require 'ruboty/slack_rtm/client'
2
3
  require 'ruboty/adapters/slack_rtm'
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_development_dependency 'bundler', '~> 1.7'
22
- spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'rake', '~> 11.1'
23
23
  spec.add_development_dependency 'rubocop', '>= 0.28.0'
24
24
 
25
25
  spec.add_dependency 'ruboty', '>= 1.1.4'
26
- spec.add_dependency 'slack-api', '~> 1.0.0'
27
- spec.add_dependency 'slack-rtmapi', '~> 1.0.0.rc4'
26
+ spec.add_dependency 'slack-api', '~> 1.2'
27
+ spec.add_dependency 'websocket-client-simple', '~> 0.3.0'
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-slack_rtm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Kusano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2016-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '11.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '11.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.0
75
+ version: '1.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.0
82
+ version: '1.2'
83
83
  - !ruby/object:Gem::Dependency
84
- name: slack-rtmapi
84
+ name: websocket-client-simple
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.0.rc4
89
+ version: 0.3.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.0.rc4
96
+ version: 0.3.0
97
97
  description: Slack real time messaging adapter for Ruboty
98
98
  email:
99
99
  - rosylilly@aduca.org
@@ -109,6 +109,7 @@ files:
109
109
  - Rakefile
110
110
  - lib/ruboty/adapters/slack_rtm.rb
111
111
  - lib/ruboty/slack_rtm.rb
112
+ - lib/ruboty/slack_rtm/client.rb
112
113
  - lib/ruboty/slack_rtm/version.rb
113
114
  - ruboty-slack_rtm.gemspec
114
115
  homepage: https://github.com/rosylilly/ruboty-slack_rtm
@@ -131,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  version: '0'
132
133
  requirements: []
133
134
  rubyforge_project:
134
- rubygems_version: 2.4.5.1
135
+ rubygems_version: 2.5.1
135
136
  signing_key:
136
137
  specification_version: 4
137
138
  summary: Slack real time messaging adapter for Ruboty