]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Fix build errors
authorIsaac Good <redacted>
Wed, 7 Dec 2016 02:44:35 +0000 (18:44 -0800)
committerIsaac Good <redacted>
Wed, 7 Dec 2016 02:44:35 +0000 (18:44 -0800)
scripts/listsort.pl

index f615cd953ba255b44489b4aa7a4d9d3796ceec1f..deb877028a1273f00e2a4585a0317a6beb71032a 100644 (file)
@@ -1,3 +1,5 @@
+use strict;
+use warnings;
 use Irssi;
 use vars qw/$VERSION %IRSSI/;
 
@@ -15,16 +17,10 @@ $VERSION = '0.1';
 # Bindings. Start of channel list, end of list, list item.
 Irssi::signal_add_last('event 322', \&list_event);
 Irssi::signal_add_last('event 323', \&list_end);
-Irssi::signal_add_last('notifylist event', \&list_start);
 
 # Store the channel list between IRC messages
 my %list;
 
-# When we get a start-list, create an empty list.
-sub list_start {
-    %list = {};
-}
-
 # Store list info in the hash.
 sub list_event {
     my ($server, $data, $server_name) = @_;
@@ -32,9 +28,12 @@ sub list_event {
     my ($nick, $name, $size) = split (/ /, $meta, 3);
     $list{$name}{'size'} = $size;
 
-    $more =~ /^[^[]*\[([^]]*)\][^ ]* *([^ ].*)$/;
-    my $modes = $1;
-    $list{$name}{'desc'} = $2;
+    my $modes = '';
+       $list{$name}{'desc'} = '';
+    if ($more =~ /^[^[]*\[([^]]*)\][^ ]* *([^ ].*)$/) {
+               $modes = $1;
+               $list{$name}{'desc'} = $2;
+       }
 
     $modes =~ s/ +$//;
     $list{$name}{'modes'} = $modes;
@@ -43,12 +42,14 @@ sub list_event {
 # Print out the whole list in sorted order.
 sub list_end {
     for my $name (sort {$list{$a}{'size'} <=> $list{$b}{'size'}} keys %list) {
+               my $mode = $list{$name}{'modes'};
+               $mode = " ($mode)" if ($mode);
         my $msg = sprintf (
-            "%d %s: %s (%s)",
+            "%d %s: %s%s",
             $list{$name}{'size'},
             $name,
             $list{$name}{'desc'},
-            $list{$name}{'modes'}
+            $mode
         );
 
         Irssi::print($msg, MSGLEVEL_CRAP);
git clone https://git.99rst.org/PROJECT