]> git.donarmstrong.com Git - infobot.git/commitdiff
- commandstubs: cmd or ident could be null - semi fix.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 22 May 2001 13:38:48 +0000 (13:38 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 22 May 2001 13:38:48 +0000 (13:38 +0000)
- cmdhook for news now uses Identifier
- we did a stupid netsplit check in on_quit - should fix problems.
- yet another hash{} initialization fix for news.
- chagned factoidDeleteDelay to 14 days.
- news: removed more debugging info
- debian: moved more DEBUG to use $debug

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@494 c11ca15a-4712-0410-83d8-924469b57eb5

src/CommandStubs.pl
src/IRC/IrcHelpers.pl
src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl
src/Modules/Debian.pl
src/Modules/News.pl
src/UserExtra.pl

index 1a583dd4399af473c8f20b2ea17b6d44cf9a557b..249449cb1f218e365352ea5a75c5f6fb0a4bfd0b 100644 (file)
@@ -49,9 +49,13 @@ sub parseCmdHook {
     }
 
     foreach (keys %{"hooks_$hashname"}) {
-       # rename to something else!
+       # rename to something else! like $id or $label?
        my $ident = $_;
 
+       if (!defined $cmd or !defined $ident) {
+           &WARN("cstubs: cmd or ident == NULL. ($cmd, $ident)");
+           next;
+       }
        next unless ($cmd =~ /^$ident$/i);
 
        if ($done) {
index 4c5c956f2d35ebb7d5a73564bf06cf8962b17da5..a157462d43a8e71644850e1b4e5c77fbdca897e0 100644 (file)
@@ -46,7 +46,7 @@ sub hookMode {
            # modes w/ target affecting nick => cache it.
            if ($mode =~ /[bov]/) {
                if ($mode eq "o" and $nick eq "ChanServ" and $target =~ /^\Q$ident\E$/i) {
-                   &DEBUG("hookmode: chanserv deopped us! asking");
+                   &VERB("hookmode: chanserv deopped us! asking",2);
                    &chanServCheck($chan);
                }
 
index 05a6fc04ab7b6d81ae41d4059817d4ca741af329..42e80187381ce874e9d8a48a5f4f23611ecc0b3a 100644 (file)
@@ -433,6 +433,7 @@ sub on_join {
     if (exists $netsplit{lc $who}) {
        delete $netsplit{lc $who};
        $netsplit = 1;
+
        if (!scalar keys %netsplit) {
            &DEBUG("on_join: netsplit hash is now empty!");
            undef %netsplitservers;
@@ -464,7 +465,8 @@ sub on_join {
     ### on-join bans.
     my @bans;
     push(@bans, keys %{ $bans{$chan} }) if (exists $bans{$chan});
-    push(@bans, keys %{ $bans{"*"} })  if (exists $bans{"*"});
+    push(@bans, keys %{ $bans{"*"} })   if (exists $bans{"*"});
+
     foreach (@bans) {
        my $ban = $_;
        s/\?/./g;
@@ -512,6 +514,7 @@ sub on_join {
     }
 
     ### ROOTWARN:
+    # what's the +o requirement?
     &rootWarn($who,$user,$host,$chan)
                if (&IsChanConf("rootWarn") &&
                    $user =~ /^r(oo|ew|00)t$/i &&
@@ -574,8 +577,8 @@ sub on_mode {
 
 sub on_modeis {
     my ($self, $event) = @_;
-    my $nick = $event->nick();
     my ($myself, undef,@args) = $event->args();
+    my $nick   = $event->nick();
     $chan      = ($event->args())[1];
 
     &hookMode($nick, @args);
@@ -683,6 +686,7 @@ sub on_notice {
 
        if ($check) {
            &status("nickserv told us to register; doing it.");
+
            if (&IsParam("nickServ_pass")) {
                &status("NickServ: ==> Identifying.");
                &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
@@ -707,6 +711,7 @@ sub on_notice {
        }
     } elsif ($nick =~ /^ChanServ$/i) {         # chanserv.
        &status("ChanServ: <== '$args'.");
+
     } else {
        if ($chan =~ /^$mask{chan}$/) { # channel notice.
            &status("-$nick/$chan- $args");
@@ -740,7 +745,11 @@ sub on_part {
 
     $chanstats{$chan}{'Part'}++;
     &delUserInfo($nick,$chan);
-    &clearChanVars($chan) if ($nick eq $ident);
+    if ($nick eq $ident) {
+       &DEBUG("on_part: ok, I left $chan... clearChanVars...");
+       &clearChanVars($chan);
+    }
+
     if (!&IsNickInAnyChan($nick) and &IsChanConf("seenStats")) {
        delete $userstats{lc $nick};
     }
@@ -841,7 +850,8 @@ sub on_quit {
     if (exists $nuh{lc $nick}) {
        delete $nuh{lc $nick};
     } else {
-       &DEBUG("on_quit: nuh{lc $nick} does not exist! FIXME");
+       # well.. it's good but weird that this has happened - lets just
+       # be quiet about it.
     }
     delete $userstats{lc $nick} if (&IsChanConf("seenStats"));
     delete $chanstats{lc $nick};
@@ -851,17 +861,15 @@ sub on_quit {
        $reason = "NETSPLIT: $1 <=> $2";
 
        # chanlimit code.
-       if (!scalar keys %netsplit) {
-           my @l = &getNickInChans($nick);
-           &DEBUG("on_quit: l => ".scalar(@l) );
+       my @l = &getNickInChans($nick);
+       &DEBUG("on_quit: l => ".scalar(@l) );
 
-           foreach ( &getNickInChans($nick) ) {
-               next unless ( &IsChanConf("chanlimitcheck") );
-               next unless ( exists $channels{$_}{'l'} );
+       foreach $chan ( &getNickInChans($nick) ) {
+           next unless ( &IsChanConf("chanlimitcheck") );
+           next unless ( exists $channels{$_}{'l'} );
 
-               &status("on_quit: netsplit detected on $_; disabling chan limit.");
-               &rawout("MODE $_ -l");
-           }
+           &DEBUG("on_quit: netsplit detected on $_; disabling chan limit.");
+           &rawout("MODE $_ -l");
        }
 
        $netsplit{lc $nick} = time();
index 603275051c3d01647e742fc5df7d2e3957cf6d51..f884fe1ad31a68686c668d2f34f8f803a5340f2a 100644 (file)
@@ -281,8 +281,7 @@ sub newsFlush {
        return if ($_[0] eq "2");       # defer.
     }
 
-    if (&ChanConfList("news")) {
-    } else {
+    if (!&ChanConfList("news")) {
        &DEBUG("newsFlush: news disabled? (chan => $chan)");
        return;
     }
@@ -294,7 +293,10 @@ sub newsFlush {
        my $i           = 0;
        my $total       = scalar(keys %{ $::news{$chan} });
 
-       &DEBUG("newsFlush: chan => $chan (total => $total)");
+       if (!$total) {
+           delete $::news{$chan};
+           next;
+       }
 
        foreach $item (keys %{ $::news{$chan} }) {
            my $t = $::news{$chan}{$item}{Expire};
@@ -360,9 +362,6 @@ sub chanlimitCheck {
        return if ($_[0] eq "2");
     }
 
-    $cache{chanlimitCheck}++;
-    &DEBUG("clC: chanlimitCheck => $cache{chanlimitCheck}");
-
     foreach $chan ( &ChanConfList("chanlimitcheck") ) {
        next unless (&validChan($chan));
 
@@ -464,7 +463,10 @@ sub netsplitCheck {
        delete $netsplit{$_};
     }
 
-    &DEBUG("removed from netsplit list (".scalar(@delete)."): @delete") if (@delete);
+    if (@delete) {
+       my $str = scalar(@delete)."/".scalar(keys %netsplit);
+       &DEBUG("removed from netsplit list ($str): @delete");
+    }
     &DEBUG("nsC: netsplitservers: ".scalar(keys %netsplitservers) );
     &DEBUG("nsC: netsplit: ".scalar(keys %netsplit) );
 
@@ -1046,18 +1048,16 @@ sub factoidCheck {
     }
 
     my @list   = &searchTable("factoids", "factoid_key", "factoid_key", " #DEL#");
-    my $stale  = &getChanConfDefault("factoidDeleteDelay", 30) *60*60*24;
+    my $stale  = &getChanConfDefault("factoidDeleteDelay", 14) *60*60*24;
     if ($stale < 1) {
        # disable it since it's "illegal".
        return;
     }
 
-    &DEBUG("stale => $stale");
     my $time   = time();
 
     foreach (@list) {
        my $age = &getFactInfo($_, "modified_time");    
-       &DEBUG("fC: _ => '$_'; age => $age");
 
        if (!defined $age or $age !~ /^\d+$/) {
            if (scalar @list > 50) {
@@ -1073,8 +1073,6 @@ sub factoidCheck {
            next;
        }
 
-       &DEBUG("del factoid: delta => ".($time - $age) );
-       &DEBUG("del factoid:    stale => $stale");
        next unless ($time - $age > $stale);
 
        my $fix = $_;
@@ -1082,8 +1080,6 @@ sub factoidCheck {
        my $agestr = &Time2String($time - $age);
        &DEBUG("safedel: Removing '$_' for good. [$agestr old]");
 
-       last;
-
        &delFactoid($_);
     }
 }
index 2ae82cf6bfb41f6dc3ad2579be0d0bc1da58dd46..e525e028816a6837cf0ff9842b4ba4dd06b71937 100644 (file)
@@ -315,7 +315,7 @@ sub searchContents {
        &::pSReply( &::formListReply(0, $prefix, @list) );
 
     } else {           # !@list.
-       &::DEBUG("deb: ok, !\@list, searching desc for '$query'.");
+       &::DEBUG("deb: ok, !\@list, searching desc for '$query'.") if ($debug);
        my @list = &searchDesc($query);
 
        if (!scalar @list) {
@@ -439,7 +439,7 @@ sub searchAuthor {
 # Usage: &searchDesc($query);
 sub searchDesc {
     my ($dist, $query) = &getDistroFromStr($_[0]);
-    &::DEBUG("deb: searchDesc: dist => '$dist', query => '$query'.");
+    &::DEBUG("deb: searchDesc: dist => '$dist', query => '$query'.") if ($debug);
     $query =~ s/^\s+|\s+$//g;
 
     # start of search.
@@ -462,7 +462,7 @@ sub searchDesc {
        $files .= " ".$_;
     }
 
-    &::DEBUG("deb(2): good = $good, bad = $bad...");
+    &::DEBUG("deb(2): good = $good, bad = $bad...") if ($debug);
 
     if ($good == 0 and $bad != 0) {
        my %urls = &fixDist($dist, %urlpackages);
@@ -516,7 +516,7 @@ sub generateIncoming {
     my $stale   = 0;
     $stale++ if (&::isStale($pkgfile.".gz", $refresh));
     $stale++ if (&::isStale($idxfile, $refresh));
-    &::DEBUG("deb: gI: stale => '$stale'.");
+    &::DEBUG("deb: gI: stale => '$stale'.") if ($debug);
     return 0 unless ($stale);
 
     ### STATIC URL.
@@ -851,9 +851,6 @@ sub generateIndex {
     foreach (@dists) {
        my $dist = &getDistro($_); # incase the alias is returned, possible?
        my $idx  = "debian/Packages-$dist.idx";
-       &::DEBUG("deb: gI: dist => $dist.");
-       &::DEBUG("deb: gI: idx  => $idx.");
-       &::DEBUG("deb: gI: r    => $refresh.");
 
        # TODO: check if any of the Packages file have been updated then
        #       regenerate it, even if it's not stale.
index e9a1ef29ac6ffaef59a34cfff26a49741de59a19..4696982a3eae772f9aa5e7bdabfb4e7fdcd4873f 100644 (file)
@@ -61,7 +61,7 @@ sub Parse {
        }
 
        $chan   = $chans[0];
-       &::DEBUG("Guessed $::who being on chan $chan",2);
+       &::VERB("Guessed $::who being on chan $chan",2);
        $::chan = $chan;        # hack for IsChanConf().
     }
 
@@ -142,7 +142,6 @@ sub Parse {
        }
 
     } else {
-       &::DEBUG("news: could not parse '$what'");
        &::notice($::who, "unknown command: $what");
     }
 }
index c27605ba57ff2fd6c29d76d605349cd929b17d19..2467660d32be75ed35b5d04cbb6862a0c75f0da8 100644 (file)
@@ -33,7 +33,8 @@ use vars qw(%channels %chanstats %cmdstats);
        Help => 'tell', Identifier => 'allowTelling',
        Cmdstats => 'Tell') );
 &addCmdHook("main", 'news', ('CODEREF' => 'News::Parse', 
-       Module => 'news', 'Cmdstats' => 'News' ) );
+       Module => 'news', 'Cmdstats' => 'News',
+       Identifier => 'news' ) );
 &addCmdHook("main", 'countrystats', ('CODEREF' => 'countryStats', 
 #      Forker => "NULL",
  ) );
@@ -393,6 +394,7 @@ sub DNS {
     if ($dns =~ /(\d+\.\d+\.\d+\.\d+)/) {
        &status("DNS query by IP address: $in");
        $match = $1;
+
        $y = pack('C4', split(/\./, $match));
        $x = (gethostbyaddr($y, &AF_INET));
 
@@ -401,7 +403,9 @@ sub DNS {
        } else {
            $result = "I can't seem to find that address in DNS";
         }
+
     } else {
+
        &status("DNS query by name: $in");
        $x = join('.',unpack('C4',(gethostbyname($in))[4]));