X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=xmlrtorrent.pl;h=c5ff36b72407eafdac90bba93854c2b55fee4b3d;hb=b6999fc920e65644059cd46ffb3d6502100ee067;hp=53dd4e6219682c55309d910790c8edaa94286d2a;hpb=bf1efb98686afd48f1173185542a3f48797afc04;p=xmlrtorrent.git diff --git a/xmlrtorrent.pl b/xmlrtorrent.pl index 53dd4e6..c5ff36b 100644 --- a/xmlrtorrent.pl +++ b/xmlrtorrent.pl @@ -94,12 +94,15 @@ sub write_irssi { my @text = @_; my $output = $outputstack[0]; - $text[0] = '%%mxmlrtorrent: %%n' . $text[0]; + my $format = '%%mxmlrtorrent: %%n' . shift(@text); + + # escape % in parameters from irssi + s/%/%%/g foreach @text; if (defined($output) and ref($output)) { - $output->print(sprintf(shift(@text), @text), MSGLEVEL_CLIENTCRAP); + $output->print(sprintf($format, @text), MSGLEVEL_CLIENTCRAP); } else { - Irssi::print(sprintf(shift(@text), @text)); + Irssi::print(sprintf($format, @text)); } } @@ -125,7 +128,6 @@ sub check_for_link { my $message = ($parammessage == -1) ? '' : $signal->[$parammessage]; my $nick = ($paramnick == -1)?defined($server)?$server->{'nick'}:'':$signal->[$paramnick]; my $g; - my $m; my $p; my $witem; @@ -134,27 +136,19 @@ sub check_for_link { } else { $witem = Irssi::window_item_find($target); } - + # Look if we should ignore this line if ($message =~ m,(?:\s|^)/nosave(?:\s|$),) { return; } - + push_output($witem); # Look if there is a torrent link in there - $message =~ m,(http://\S*\.(?:torrent|penis)),; - $m = $1; - while (defined($m)) { - write_debug('Torrent-URL: %s', $m); - $torrentlist{$torrentindex++} = {'CHANNEL' => $target, 'NICK' => $nick, 'URL' => $m}; - - # Remove the matched part from the message and try again (there may be - # more!) - $message =~ s/$m//; - - $message =~ m|(http://.*\.torrent)|; - $m = $1; + + while ($message =~ m,(http://\S*\.(?:torrent|penis)),g) { + write_debug('Torrent-URL: %s', $1); + $torrentlist{$torrentindex++} = {'CHANNEL' => $target, 'NICK' => $nick, 'URL' => $1}; } pop_output(); @@ -227,6 +221,7 @@ sub cmd_remote { $_->{'NAME'}, $_->{'BYTES_DONE'}, $_->{'SIZE_BYTES'}, + $_->{'BYTES_DONE'}*100/$_->{'SIZE_BYTES'}, $_->{'UP_RATE'}, $_->{'DOWN_RATE'}); }