X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=services.pl;h=0b7af6d1ddfd04f40abe305e71cf3a90427aeb97;hb=b87fc463b2f4f807fc7860438eed18a00f5c0e12;hp=f04a80efb8132998cb062e3a435ec5988c18273a;hpb=9db5de0ec290fd8b82a9c510e0d627b31e44d9bd;p=perl%2Fscripts%2Fxchat.git diff --git a/services.pl b/services.pl index f04a80e..0b7af6d 100755 --- a/services.pl +++ b/services.pl @@ -7,6 +7,7 @@ use Xchat qw<:all>; use lib get_info 'xchatdir'; use Xchat::XPI; +use Xchat::XPI::Utils qw; our $VERSION = '0.03'; @@ -32,15 +33,14 @@ hook_command 'ID', sub { hook_command 'AID', sub { my $forcepasswd = $_[0][1]; - my $oldctxt = get_context; - my @contexts = get_servers_ctxt; + my @contexts = get_servers_ctxt; + my $guard = save_context; for (@contexts) { - set_context $_; + set_context $_ or next; my $passwd = $forcepasswd || get_info 'nickserv'; next unless $passwd; command 'ID ' . $passwd; } - set_context $oldctxt; return EAT_ALL; }, { help_text => 'AID [password], identify you on all servers' @@ -63,17 +63,16 @@ hook_command 'AGHOST', sub { my $target = $_[0][1] || get_prefs 'irc_nick1'; return EAT_ALL unless $target; my $forcepasswd = $_[0][2]; - my $oldctxt = get_context; - my @contexts = get_servers_ctxt; + my @contexts = get_servers_ctxt; + my $guard = save_context; for (@contexts) { - set_context $_; + set_context $_ or next; my $passwd = $forcepasswd || get_info 'nickserv'; next unless $passwd; if (nickcmp(get_info('nick'), $target)) { command join ' ', 'GHOST', $target, $passwd; } } - set_context $oldctxt; return EAT_ALL; }, { help_text => 'AGHOST [nick] [password], kill usurping clients on all servers'