diff options
author | B. Watson <yalhcru@gmail.com> | 2021-06-09 14:19:24 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2021-06-09 14:19:24 -0400 |
commit | c6e280a592ae7d87268f7fbf4cd49ff1581796fd (patch) | |
tree | 8f4efaf7116ae8cfdac8645d9004346fba1dd385 | |
parent | 3fb498690efe76c9e9413a08ff1b19fc407bee80 (diff) | |
download | misc-scripts-c6e280a592ae7d87268f7fbf4cd49ff1581796fd.tar.gz |
slacktopic.pl: handle multiple IRC connections correctly
-rw-r--r-- | slacktopic.pl | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/slacktopic.pl b/slacktopic.pl index 9fe70b1..0b2e5af 100644 --- a/slacktopic.pl +++ b/slacktopic.pl @@ -57,6 +57,7 @@ use Irssi qw/ channel_find command command_bind + servers signal_add_last timeout_add timeout_add_once @@ -208,17 +209,21 @@ sub init { # undef (false) if none. sub get_channels { my @result; + my $s; + + for(servers()) { + $s = $_, last if($_->{address} =~ $server_regex); + } + + if(!defined($s)) { + errmsg("not connected to any server matching $server_regex"); + return; + } + for(@update_channels) { - my $chan = channel_find($_); + my $chan = $s->channel_find($_); if(!$chan) { - errmsg("not joined to $_"); - next; - } - - my $server = $chan->{server}->{address}; - if($server !~ $server_regex) { - errmsg("channel $_ server is wrong: " . - $chan->{server}->{address}); + errmsg("not joined to $_ on " . $s->{address}); next; } |