# list.pl by ArZa : Sort the output of /list command # This program is free software: you can modify/redistribute it under the terms of # GNU General Public License by Free Software Foundation, either version 3 or later # which you can get from . # This program is distributed in the hope that it will be useful, but without any warranty. weechat::register("list", "ArZa ", "0.1", "GPL3", "Sort the output of /list command", "", ""); weechat::hook_signal("*,irc_in_321", "list_start", ""); weechat::hook_modifier("irc_color_decode", "color", ""); weechat::hook_modifier("irc_in_322", "list_chan", ""); weechat::hook_signal("*,irc_in_323", "list_end", ""); our @list; sub list_start { @list=(); } sub color { push(@list, $_[3]); return $_[3]; } sub list_chan { weechat::hook_modifier_exec("irc_color_decode", 1, $_[3]); return ""; } sub list_end { return 1 unless @list; if(@list>500){ weechat::print("", "Too long list :P"); return 1; } my $server=$_[1]; $server=~s/,.*//; foreach my $line (@list) { $line=~s/(\S+) (\S+) (\S+) (\S+) (\S+) :(.*)/$5: $4 $6/; } @list = sort { ($b=~/(\d+)/)[0] <=> ($a=~/(\d+)/)[0] } @list; foreach my $line (@list) { $line=~/(\S+) (\S+) (.*)/; weechat::print(weechat::buffer_search("irc", "server.$server"), weechat::prefix('network').weechat::color('bold')."$1 ".weechat::color('darkgray')."$2".weechat::color('default')." $3"); } }