X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=opers.pl;h=66c9c0b17974b39253a3c03c8b2e7c0e93eb39b5;hb=338fdb0218fb3526190b88852b71aad90534d2a1;hp=875abc9e63910213abd32ffce06082b96d62a67b;hpb=1a7e1b0385a3fc38a3ae0926d05dd1a14dac17fe;p=perl%2Fscripts%2Fxchat.git diff --git a/opers.pl b/opers.pl index 875abc9..66c9c0b 100755 --- a/opers.pl +++ b/opers.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'; @@ -27,7 +28,7 @@ hook_server '352', sub { push @{$chans{$_->{type}}}, $_ for grep $_->{server} eq $serv, get_list 'channels'; - my $oldctxt = get_context; + my $guard = save_context; my $onachan; for (@{$chans{2}}) { @@ -45,15 +46,13 @@ hook_server '352', sub { print_op $nick, $host; } - set_context $oldctxt; - return EAT_NONE; }; hook_print 'Disconnected', sub { - my %servers = map { $_->{server} => 1 } - grep { $_->{flags} & 9 and not($_->{flags} & 2) } - get_list 'channels'; + my %servers; + $servers{$_->{server}} = 1 for grep +($_->{flags} & 0b1011) == 0b1001, + get_list 'channels'; delete @opers{grep !$servers{$_}, keys %opers};