fix some messages
[xmlrtorrent.git] / xmlrtorrent.pl
index 3514100..460d9b3 100644 (file)
@@ -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));
     }
 
 }
@@ -218,6 +221,7 @@ sub cmd_remote {
                            $_->{'NAME'},
                            $_->{'BYTES_DONE'},
                            $_->{'SIZE_BYTES'},
+                           $_->{'BYTES_DONE'}*100/$_->{'SIZE_BYTES'},
                            $_->{'UP_RATE'},
                            $_->{'DOWN_RATE'});
             }
@@ -259,7 +263,7 @@ sub cmd_set {
             return;
         }
     }
-    write_irssi(undef, 'No such module');
+    write_irssi('No such module');
 }
 
 sub cmd_show {
@@ -424,7 +428,7 @@ sub init_xmlrtorrent {
             $talker = $p;
         }
     }
-    write_debug(undef, 'Selected %s as talker', $talker->{'NAME'});
+    write_debug('Selected %s as talker', $talker->{'NAME'});
     $conf->{'videosite'}->{'talker'} = $talker->{'NAME'};