- if (!$opers{$serv}{$nick}) {
- $opers{$serv}{$nick} = 1;
- my $host = $_[0][4].'@'.$_[0][5];
- my %chans;
- push @{$chans{$_->{type}}}, $_ for grep $_->{server} eq $serv,
- get_list 'channels';
- my $oldctxt = get_context;
- my $onachan = grep $_, map {
- set_context $_->{context}
- and user_info $nick
- and print_op $nick, $host
- } @{$chans{2}};
- do {
- set_context $_->{context}
- and print_op $nick, $host
- } for ($onachan ? () : @{$chans{1}}),
- grep !nickcmp($_->{channel}, $nick), @{$chans{3}};
- set_context $oldctxt;
+ return EAT_NONE if $opers{$serv}{$nick};
+ $opers{$serv}{$nick} = 1;
+
+ my $host = $_[0][4] . '@' . $_[0][5];
+ my %chans;
+ push @{$chans{$_->{type}}}, $_ for grep $_->{server} eq $serv,
+ get_list 'channels';
+
+ my $oldctxt = get_context;
+
+ my $onachan;
+ for (@{$chans{2}}) {
+ set_context $_->{context} or next;
+ user_info $nick or next;
+ print_op $nick, $host;
+ ++$onachan;
+ }
+
+ my @opchans;
+ @opchans = @{$chans{1}} unless $onachan;
+ push @opchans, grep !nickcmp($_->{channel}, $nick), @{$chans{3}};
+ for (@opchans) {
+ set_context $_->{context} or next;
+ print_op $nick, $host;