]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/IrcHooks.pl
fixed up ignore code. discovered by debian@OPN
[infobot.git] / src / IRC / IrcHooks.pl
index 9eec53b043cfa0fa0276b020e810951d36e62ac2..ce436dff6369aa8af92ee24a714db86060e88b3a 100644 (file)
@@ -267,11 +267,7 @@ sub on_dcc_open {
 sub on_dcc_open_chat {
     my(undef, $nick,$sock) = @_;
 
-    &DEBUG("nuh{$nick} => $nuh{$nick}.");
-    if ($nuh{$nick} =~ /^(\S+)(\d+)$/) {
-       my $i = $2;
-       $i++;
-       $nuh{$nick} = $1.$i;
+    if ($nuh{$nick} eq "GETTING-NOW") {
        &DEBUG("getting nuh for $nick failed. FIXME.");
        return;
     }
@@ -422,23 +418,24 @@ sub on_join {
     &status(">>> join/$b_blue$chan$ob $b_cyan$who$ob $b_yellow($ob$user\@$host$b_yellow)$ob$netsplitstr");
 
     $channels{$chan}{''}{$who}++;
-    $nuh{lc $who} = $who."!".$user."\@".$host unless (exists $nuh{lc $who});
-
-    ### on-join ban. (TODO: kick)
-    if (exists $bans{$chan}) {
-       ### TODO: need to do $chan and _default
-       foreach (keys %{ $bans{$chan} }) {
-           s/\*/\\S*/g;
-           next unless /^\Q$nuh\E$/i;
-
-           foreach (keys %{ $channels{$chan}{'b'} }) {
-               &DEBUG(" bans_on_chan($chan) => $_");
-           }
-
-           ### TODO: check $channels{$chan}{'b'} if ban already exists.
-           &ban( "*!*@".&makeHostMask($host), $chan);
-           last;
+    $nuh         = $who."!".$user."\@".$host;
+    $nuh{lc $who} = $nuh unless (exists $nuh{lc $who});
+
+    ### on-join bans.
+    my @bans   = keys %{ $bans{$chan} };
+    push(@bans, keys %{ $bans{"*"} });
+    foreach (@bans) {
+       s/\*/\\S*/g;
+       next unless /^\Q$nuh\E$/i;
+
+       ### TODO: check $channels{$chan}{'b'} if ban already exists.
+       foreach (keys %{ $channels{$chan}{'b'} }) {
+           &DEBUG(" bans_on_chan($chan) => $_");
        }
+
+       ### TODO: kick
+       &ban( "*!*@".&makeHostMask($host), $chan);
+       last;
     }
 
     ### ROOTWARN:
@@ -709,15 +706,20 @@ sub on_quit {
     my $nick = $event->nick();
     my $reason = ($event->args)[0];
 
+    my $count  = 0;
     foreach (keys %channels) {
        # fixes inconsistent chanstats bug #1.
        if (!&IsNickInChan($nick,$_)) {
-           &DEBUG("on_quit: nick $nick was not in chan $_.");
+           $count++;
            next;
        }
        $chanstats{$_}{'SignOff'}++;
     }
 
+    if ($count == scalar keys %channels) {
+       &DEBUG("on_quit: nick $nick was not found in any chan.");
+    }
+
     &DeleteUserInfo($nick, keys %channels);
 
     if (exists $nuh{lc $nick}) {
@@ -759,8 +761,9 @@ sub on_targettoofast {
     my $nick = $event->nick();
     my($me,$chan,$why) = $event->args();
 
+    ### TODO: incomplete.
 ###    .* wait (\d+) second/) {
-       &status("X1 $msg");
+       &status("on_ttf: X1 $msg") if (defined $msg);
        my $sleep = 5;
        &status("going to sleep for $sleep...");
        sleep $sleep;
@@ -1063,9 +1066,11 @@ sub hookMsg {
        $flood{$floodwho}{$message} = time();
     }
 
+    my @ignore;
     if ($msgType =~ /public/i) {                   # public.
        $talkchannel    = $chan;
        &status("<$orig{who}/$chan> $orig{message}");
+       @ignore         = keys %{ $ignore{$chan} };
     } elsif ($msgType =~ /private/i) {            # private.
        &status("[$orig{who}] $orig{message}");
        $talkchannel    = undef;
@@ -1073,6 +1078,7 @@ sub hookMsg {
     } else {
        &DEBUG("unknown msgType => $msgType.");
     }
+    push(@ignore, keys %{ $ignore{"*"} });
 
     if ((!$skipmessage or &IsChanConf("seenStoreAll")) and
        &IsChanConf("seen") and
@@ -1089,15 +1095,13 @@ sub hookMsg {
     return if ($skipmessage);
     return unless (&IsParam("minVolunteerLength") or $addressed);
 
-    local $ignore      = 0;
-    if (exists $ignore{lc $chan}) {
-       foreach (keys %{ $ignore{lc $chan} }) {
-           s/\*/\\S*/g;
+    foreach (@ignore) {
+       s/\*/\\S*/g;
 
-           next unless ($nuh =~ /^\Q$_\E$/i);
-           $ignore++;
-           last;
-       }
+       next unless (eval { $nuh =~ /^$_$/i });
+
+       &status("IGNORE <$who> $message");
+       return;
     }
 
     if (defined $nuh) {