Pulse 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/library/pulse.rb +1 -0
- data/library/pulse/client.rb +11 -0
- data/library/pulse/connection.rb +6 -0
- data/library/pulse/dcc.rb +37 -0
- data/library/pulse/handling.rb +6 -1
- metadata +4 -3
data/library/pulse.rb
CHANGED
data/library/pulse/client.rb
CHANGED
@@ -22,6 +22,8 @@ module Pulse
|
|
22
22
|
def connect
|
23
23
|
trap 2 do
|
24
24
|
unload_scripts
|
25
|
+
@connection.close
|
26
|
+
Thread.list.each &:kill
|
25
27
|
transmit :QUIT, "I was interrupted"
|
26
28
|
end
|
27
29
|
@connection.establish
|
@@ -69,6 +71,15 @@ module Pulse
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
74
|
+
def send_file path, recipient
|
75
|
+
Thread.new path, recipient do
|
76
|
+
DCC.new(path).listen do |addr|
|
77
|
+
# FIXME: find the right local ip address and convert it to an integer
|
78
|
+
transmit :PRIVMSG, recipient, "\x01DCC SEND #{File.basename path} 1489377357 #{addr[1]} #{File.size path}\x01"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
72
83
|
private
|
73
84
|
|
74
85
|
def emit name, *args
|
data/library/pulse/connection.rb
CHANGED
@@ -10,6 +10,8 @@ module Pulse
|
|
10
10
|
|
11
11
|
def establish
|
12
12
|
TCPSocket.open @settings.hostname, @settings.port do |socket|
|
13
|
+
@socket = socket
|
14
|
+
|
13
15
|
Thread.start socket, &@queue.method(:process)
|
14
16
|
@delegate.connection_established self
|
15
17
|
|
@@ -21,6 +23,10 @@ module Pulse
|
|
21
23
|
@delegate.connection_terminated self
|
22
24
|
end
|
23
25
|
|
26
|
+
def close
|
27
|
+
@socket.close
|
28
|
+
end
|
29
|
+
|
24
30
|
def transmit name, *arguments
|
25
31
|
Command.new(name, arguments).tap { |this| @queue << this }
|
26
32
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'timeout'
|
4
|
+
|
5
|
+
module Pulse
|
6
|
+
class DCC
|
7
|
+
Duration = 150
|
8
|
+
|
9
|
+
def initialize path
|
10
|
+
@path = path
|
11
|
+
end
|
12
|
+
|
13
|
+
def listen
|
14
|
+
client = nil
|
15
|
+
|
16
|
+
TCPServer.open '0.0.0.0', 0 do |server|
|
17
|
+
yield server.addr if block_given?
|
18
|
+
|
19
|
+
begin
|
20
|
+
timeout(Duration) { client = server.accept }
|
21
|
+
rescue Timeout::Error
|
22
|
+
server.close
|
23
|
+
end
|
24
|
+
|
25
|
+
each_chunk { |chunk| client.write chunk } if client
|
26
|
+
client.close if client
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def each_chunk
|
31
|
+
File.open @path, ?r do |file|
|
32
|
+
yield file.readpartial 1024 until file.eof?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/library/pulse/handling.rb
CHANGED
@@ -54,7 +54,12 @@ module Pulse
|
|
54
54
|
|
55
55
|
(@conversations[command.sender.nickname] ||= Conversation.new user, self).tap do |conversation|
|
56
56
|
user.channel = conversation
|
57
|
-
|
57
|
+
|
58
|
+
if message.starts_with? "\x01DCC"
|
59
|
+
emit :DCC, user, conversation, message.split[1..-1]
|
60
|
+
else
|
61
|
+
emit :conversation, user, conversation, message
|
62
|
+
end
|
58
63
|
end
|
59
64
|
end
|
60
65
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 1.2.
|
8
|
+
- 1
|
9
|
+
version: 1.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Mikkel Kroman
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: executables
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-26 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- library/pulse/user.rb
|
39
39
|
- library/pulse/conversation.rb
|
40
40
|
- library/pulse/channel.rb
|
41
|
+
- library/pulse/dcc.rb
|
41
42
|
- library/pulse/enhancements.rb
|
42
43
|
- library/pulse.rb
|
43
44
|
has_rdoc: true
|