public
Description: Direct Connect bot written in Ruby
Clone URL: git://github.com/kballard/dcbot.git
Search Repo:
Fix :get callbacks for ADCGet and UGetBlock

Also stop using an ivar where a regular variable suffices
kballard (author)
Fri Feb 22 17:13:18 -0800 2008
commit  d002f35e4c7d61e04f150f698dc090f053c4d6bd
tree    1f194c7427eb593f37d9792a144bf30fa2d48075
parent  0bf8305af7f0ddbf8767abb29976c8e5791bd8b7
...
137
138
139
140
 
141
142
143
...
137
138
139
 
140
141
142
143
0
@@ -137,7 +137,7 @@ def setupConnection(host, port, nickname, sockopts, sleep)
0
     end
0
     c.registerCallback :peer_get do |socket,peer,filename|
0
       peer_id = "#{peer.host}:#{peer.port}"
0
- peer_id < " (#{peer.remote_nick})" if peer.remote_nick
0
+ peer_id << " (#{peer.remote_nick})" if peer.remote_nick
0
       puts "* Peer #{peer_id} requested: #{filename}"
0
     end
0
   end
...
438
439
440
441
 
442
443
444
 
 
445
446
447
...
477
478
479
 
480
481
482
...
502
503
504
 
505
506
507
...
438
439
440
 
441
442
 
 
443
444
445
446
447
...
477
478
479
480
481
482
483
...
503
504
505
506
507
508
509
0
@@ -438,10 +438,10 @@ EOF
0
   def cmd_Get(line)
0
     if line =~ /^([^$]+)\$(\d+)$/ then
0
       @state = :data
0
- @filename = $1
0
+ filename = $1
0
       offset = $2.to_i - 1 # it's 1-based
0
- call_callback :get, @filename
0
- @fileio = get_file_io(@filename)
0
+ call_callback :get, filename
0
+ @fileio = get_file_io(filename)
0
       if @fileio then
0
         @fileio.pos = offset
0
         send_command "FileLength", @fileio.size - @fileio.pos
0
@@ -477,6 +477,7 @@ EOF
0
       flags = ($5 || "").split(" ")
0
       if flags.empty? then
0
         if type == "file" then
0
+ call_callback :get, identifier
0
           fileio = get_file_io(identifier)
0
           if fileio then
0
             fileio.pos = startpos
0
@@ -502,6 +503,7 @@ EOF
0
       startpos = $1.to_i
0
       length = $2.to_i
0
       filename = $3
0
+ call_callback :get, filename
0
       fileio = get_file_io(filename)
0
       if fileio then
0
         fileio.pos = startpos

Comments

    No one has commented yet.