From 330af0c290daac1ba1dc2f817a6ed3255600169d Mon Sep 17 00:00:00 2001 From: dms Date: Tue, 22 May 2001 13:38:48 +0000 Subject: [PATCH] - commandstubs: cmd or ident could be null - semi fix. - 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 | 6 +++++- src/IRC/IrcHelpers.pl | 2 +- src/IRC/IrcHooks.pl | 34 +++++++++++++++++++++------------- src/IRC/Schedulers.pl | 24 ++++++++++-------------- src/Modules/Debian.pl | 11 ++++------- src/Modules/News.pl | 3 +-- src/UserExtra.pl | 6 +++++- 7 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index 1a583dd..249449c 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -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) { diff --git a/src/IRC/IrcHelpers.pl b/src/IRC/IrcHelpers.pl index 4c5c956..a157462 100644 --- a/src/IRC/IrcHelpers.pl +++ b/src/IRC/IrcHelpers.pl @@ -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); } diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 05a6fc0..42e8018 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -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(); diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 6032750..f884fe1 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -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($_); } } diff --git a/src/Modules/Debian.pl b/src/Modules/Debian.pl index 2ae82cf..e525e02 100644 --- a/src/Modules/Debian.pl +++ b/src/Modules/Debian.pl @@ -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. diff --git a/src/Modules/News.pl b/src/Modules/News.pl index e9a1ef2..4696982 100644 --- a/src/Modules/News.pl +++ b/src/Modules/News.pl @@ -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"); } } diff --git a/src/UserExtra.pl b/src/UserExtra.pl index c27605b..2467660 100644 --- a/src/UserExtra.pl +++ b/src/UserExtra.pl @@ -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])); -- 2.39.2