keepnick.pl: detect if ISON timed out / is disabled
This commit is contained in:
parent
0f54bef93a
commit
69da72df8e
@ -11,7 +11,7 @@ my $SCRIPT_VERSION = '1.0';
|
||||
my $SCRIPT_LICENCE = 'Public domain';
|
||||
my $SCRIPT_DESC = 'Keep your primary nickname';
|
||||
|
||||
our (%waiting, %connecting);
|
||||
our (%waiting, %connecting, %noison);
|
||||
|
||||
my %OPTIONS = (
|
||||
default_enable => ['Whether to enable keepnick on servers by default', '0'],
|
||||
@ -116,6 +116,7 @@ sub ison_check
|
||||
next unless weechat::infolist_integer($iptr, 'is_connected');
|
||||
my $server = lc weechat::infolist_string($iptr, 'name');
|
||||
next unless is_waiting($server);
|
||||
next unless exists $noison{$server};
|
||||
weechat::hook_hsignal_send('irc_redirect_command', {
|
||||
server => $server,
|
||||
pattern => 'ison',
|
||||
@ -134,6 +135,10 @@ sub ison_check
|
||||
sub irc_ison
|
||||
{
|
||||
my %hashtable = %{ pop() };
|
||||
unless ($hashtable{output}) {
|
||||
$noison{lc $hashtable{server}} = 1;
|
||||
return weechat::WEECHAT_RC_ERROR;
|
||||
}
|
||||
my %nicks = map { lc $_ => 1 }
|
||||
split / +/, ($hashtable{output} =~ s/^:[^ ]* 303 [^ ]+ :?//r);
|
||||
|
||||
@ -231,7 +236,7 @@ sub cmd_keepnick
|
||||
info($server, "keepnick disabled on this server");
|
||||
}
|
||||
else {
|
||||
my @waiting = enable($server, 0, $command =~ s/ /,/gr);
|
||||
my @waiting = enable($server, 1, $command =~ s/ /,/gr);
|
||||
if (@waiting) { info($server, "now waiting for '".(join "', '", @waiting)."'"); }
|
||||
else { info($server, "you already have your primary nick! doing nothing"); }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user