weechat-relay-helper 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/weechat-relay-helper +15 -5
- data/lib/weechat-relay-helper/version.rb +1 -1
- data/lib/weechat-relay-helper/weechat.rb +21 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14b5b2f53fb012a9f1da7447dd9f86a41be77727
|
4
|
+
data.tar.gz: 978be4045d94684ed77200183434767714dc1f3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9c7254f7d631b8d3c576b9742c7139608826983856b8c7d829208ceb37fc50f2ee4d38157df71525780c698080be9b11208ca5ff3a36105b3510d7b905d11ef
|
7
|
+
data.tar.gz: b7095597c40a1306bc9ea8fc863620a14ae71f3c4ee1d59dea9af335109926aea889d632460c2d1cf22f6302ebcbd6958e0cc8e08a317d195ab283b3bb5d6106
|
data/bin/weechat-relay-helper
CHANGED
@@ -8,12 +8,12 @@ opts = RelayHelper::Options.new ARGV
|
|
8
8
|
conn = RelayHelper::Weechat.new opts.host, opts.port, opts.ssl, opts.compression, opts.password
|
9
9
|
|
10
10
|
Thread.new do
|
11
|
-
|
11
|
+
until conn.closed?
|
12
12
|
begin
|
13
|
-
r, _, _ = IO.select [conn.
|
13
|
+
r, _, _ = IO.select [conn.socket]
|
14
14
|
unless r.empty?
|
15
|
-
len = conn.
|
16
|
-
rest = conn.
|
15
|
+
len = conn.read(4)
|
16
|
+
rest = conn.read(len.unpack('L>')[0] - 4)
|
17
17
|
r = RelayHelper::Response.new(len + rest)
|
18
18
|
ap({ id: r.id, data: r.data })
|
19
19
|
end
|
@@ -29,6 +29,16 @@ puts "Go ahead and type your commands."
|
|
29
29
|
puts "Relay reference is located at http://www.weechat.org/files/doc/devel/weechat_relay_protocol.en.html"
|
30
30
|
|
31
31
|
while line = Readline.readline('', true)
|
32
|
-
conn.
|
32
|
+
if conn.closed?
|
33
|
+
puts "The connection is closed, sending that would have no effect. Ignoring."
|
34
|
+
next
|
35
|
+
end
|
36
|
+
if line =~ /^quit/
|
37
|
+
puts "Closing the application."
|
38
|
+
conn.puts line
|
39
|
+
conn.close
|
40
|
+
exit 0
|
41
|
+
end
|
42
|
+
conn.puts line
|
33
43
|
puts "--> #{line}"
|
34
44
|
end
|
@@ -7,5 +7,26 @@ module RelayHelper
|
|
7
7
|
@connection.open
|
8
8
|
@connection.puts "init#{" password=#{password}," if password}compression=#{compression ? 'zlib' : 'off'}"
|
9
9
|
end
|
10
|
+
def close
|
11
|
+
@connection.close
|
12
|
+
end
|
13
|
+
def closed?
|
14
|
+
@connection.closed?
|
15
|
+
end
|
16
|
+
def open
|
17
|
+
@connection.open
|
18
|
+
end
|
19
|
+
def socket
|
20
|
+
@connection.socket
|
21
|
+
end
|
22
|
+
def puts line
|
23
|
+
@connection.puts line
|
24
|
+
end
|
25
|
+
def write bytes
|
26
|
+
@connection.write bytes
|
27
|
+
end
|
28
|
+
def read numbytes
|
29
|
+
@connection.read numbytes
|
30
|
+
end
|
10
31
|
end
|
11
32
|
end
|