aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slacktopic.pl23
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;
}