keepnick.pl: use /notify not /ison
This commit is contained in:
parent
b8bca885f3
commit
ee68ec916a
@ -11,11 +11,10 @@ my $SCRIPT_VERSION = '1.0';
|
||||
my $SCRIPT_LICENCE = 'Public domain';
|
||||
my $SCRIPT_DESC = 'Keep your primary nickname';
|
||||
|
||||
our (%waiting, %connecting, %noison);
|
||||
our (%waiting, %connecting);
|
||||
|
||||
my %OPTIONS = (
|
||||
default_enable => ['Whether to enable keepnick on servers by default', '0'],
|
||||
check_time => ['Time between ISON checks (reload script to take effect)', '60'],
|
||||
);
|
||||
|
||||
|
||||
@ -51,7 +50,11 @@ sub is_waiting
|
||||
|
||||
|
||||
sub disable
|
||||
{ delete $waiting{lc shift}; }
|
||||
{
|
||||
my $server = shift;
|
||||
weechat::command('', "/notify del $_ $server") for @{$waiting{$server}};
|
||||
delete $waiting{$server};
|
||||
}
|
||||
|
||||
sub enable
|
||||
{
|
||||
@ -76,6 +79,7 @@ sub enable
|
||||
}
|
||||
return () if lc $target[0] eq my_nick($server);
|
||||
|
||||
weechat::command('', "/notify add $_ $server") for @target;
|
||||
$waiting{$server} = \@target;
|
||||
return @target;
|
||||
}
|
||||
@ -108,45 +112,11 @@ sub try_nick
|
||||
else { lc $_ eq $oldnick and do_nick($server, $_) for @confnick; }
|
||||
}
|
||||
|
||||
sub ison_check
|
||||
sub irc_notify
|
||||
{
|
||||
my $iptr = weechat::infolist_get('irc_server', '', '');
|
||||
my (undef, undef, $server, $nick) = (shift, shift, shift =~ /(.*),(.*)/);
|
||||
|
||||
while (weechat::infolist_next($iptr)) {
|
||||
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',
|
||||
signal => $SCRIPT_NAME,
|
||||
timeout => weechat::config_get_plugin('check_time') - 1,
|
||||
});
|
||||
weechat::hook_signal_send('irc_input_send',
|
||||
weechat::WEECHAT_HOOK_SIGNAL_STRING,
|
||||
"$server;;;;/ison ".(join ' ', @{ $waiting{$server} }));
|
||||
}
|
||||
|
||||
weechat::infolist_free($iptr);
|
||||
return weechat::WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
for my $confnick (is_waiting($hashtable{server})) {
|
||||
next if exists $nicks{lc $confnick}; # still taken
|
||||
do_nick($hashtable{server}, $confnick);
|
||||
last;
|
||||
}
|
||||
try_nick($server, $nick);
|
||||
return weechat::WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@ -268,9 +238,7 @@ if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
|
||||
weechat::hook_signal('irc_server_connecting', 'irc_connecting', '');
|
||||
weechat::hook_signal('irc_server_connected', 'irc_connected', '');
|
||||
weechat::hook_signal('irc_server_disconnected', 'irc_disconnect', '');
|
||||
weechat::hook_timer(weechat::config_get_plugin('check_time') * 1000, 0, 0,
|
||||
'ison_check', '');
|
||||
weechat::hook_hsignal("irc_redirection_${SCRIPT_NAME}_ison", 'irc_ison', '');
|
||||
weechat::hook_signal('irc_notify_quit', 'irc_notify', '');
|
||||
|
||||
my $iptr = weechat::infolist_get('irc_server', '', '');
|
||||
enable(weechat::infolist_string($iptr, 'name'))
|
||||
|
Loading…
Reference in New Issue
Block a user