]> git.vpit.fr Git - perl/scripts/xchat.git/commitdiff
Sanitize opers.pl
authorVincent Pit <vince@profvince.com>
Sat, 11 Oct 2008 09:23:35 +0000 (11:23 +0200)
committerVincent Pit <vince@profvince.com>
Sat, 11 Oct 2008 09:23:35 +0000 (11:23 +0200)
opers.pl

index 4ff5c788cfb677b51e92bc8c95fdceb24b96ce5a..2500f83441e09f1bce7fb2d87c34efba16550ba5 100755 (executable)
--- a/opers.pl
+++ b/opers.pl
@@ -15,23 +15,26 @@ my ($ph, %opers);
 sub print_op { print $ph "\002$_[0]\002 ($_[1]) \002is an IRC operator\n"; 1 }
 
 hook_server '352', sub {
 sub print_op { print $ph "\002$_[0]\002 ($_[1]) \002is an IRC operator\n"; 1 }
 
 hook_server '352', sub {
- return EAT_NONE unless (rindex $_[0][8], '*') >= 0;
+ return EAT_NONE unless 0 <= rindex $_[0][8], '*';
  my $serv = get_info 'server';
  my $nick = $_[0][7];
  if (!$opers{$serv}{$nick}) {
   $opers{$serv}{$nick} = 1;
   my $host = $_[0][4].'@'.$_[0][5];
   my %chans;
  my $serv = get_info 'server';
  my $nick = $_[0][7];
  if (!$opers{$serv}{$nick}) {
   $opers{$serv}{$nick} = 1;
   my $host = $_[0][4].'@'.$_[0][5];
   my %chans;
-  push @{$chans{$_->{type}}}, $_ for grep { $_->{server} eq $serv }
+  push @{$chans{$_->{type}}}, $_ for grep $_->{server} eq $serv,
                                       get_list 'channels';
   my $oldctxt = get_context;
                                       get_list 'channels';
   my $oldctxt = get_context;
-  my $onachan = grep { $_ } map {
-   set_context($_->{context}) && user_info($nick) && print_op($nick, $host)
+  my $onachan = grep $_, map {
+       set_context $_->{context}
+   and user_info $nick
+   and print_op $nick, $host
   } @{$chans{2}};
   do {
   } @{$chans{2}};
   do {
-   set_context($_->{context}) && print_op($nick, $host)
+       set_context $_->{context}
+   and print_op $nick, $host
   } for ($onachan ? () : @{$chans{1}}),
   } for ($onachan ? () : @{$chans{1}}),
-                         grep { !nickcmp($_->{channel}, $nick) } @{$chans{3}};
+                         grep !nickcmp($_->{channel}, $nick), @{$chans{3}};
   set_context $oldctxt;
  }
  return EAT_NONE;
   set_context $oldctxt;
  }
  return EAT_NONE;
@@ -46,7 +49,7 @@ hook_print 'Disconnected', sub {
 };
 
 hook_server 'QUIT', sub {
 };
 
 hook_server 'QUIT', sub {
- my ($nick) = ($_[0][0] =~ /^:([^!]+)!/);
+ my ($nick) = $_[0][0] =~ /^:([^!]+)!/;
  my $serv = get_info 'server';
  delete $opers{$serv}{$nick};
  return EAT_NONE;
  my $serv = get_info 'server';
  delete $opers{$serv}{$nick};
  return EAT_NONE;
@@ -72,11 +75,14 @@ hook_command 'OPSCAN', sub {
  }
  my ($chan, $isnet) = (get_info('channel'), 0);
  for (get_list 'channels') {
  }
  my ($chan, $isnet) = (get_info('channel'), 0);
  for (get_list 'channels') {
-  if ($_->{type} eq 1 && $_->{channel} eq $chan) { $isnet = 1; last; }
+  if ($_->{type} eq 1 && $_->{channel} eq $chan) {
+   $isnet = 1;
+   last;
+  }
  }
  my ($name, @ops) = ($isnet) ? ('network', keys %{$opers{$serv}})
  }
  my ($name, @ops) = ($isnet) ? ('network', keys %{$opers{$serv}})
-                             : ('channel', map { $_->{nick} }
-                                            grep { $opers{$serv}{$_->{nick}} }
+                             : ('channel', map $_->{nick},
+                                            grep $opers{$serv}{$_->{nick}},
                                              get_list 'users');
  if (@ops) {
   print $ph 'IRC operators on this '.$name." : \002@ops\n";
                                              get_list 'users');
  if (@ops) {
   print $ph 'IRC operators on this '.$name." : \002@ops\n";