From 66ce4d619091f642e37908c3b0ff56f1dda5ef5a Mon Sep 17 00:00:00 2001 From: dms Date: Wed, 12 Dec 2001 14:51:58 +0000 Subject: [PATCH] - updates to DEBUG/WARN/ERROR or the result of looking at them git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@531 c11ca15a-4712-0410-83d8-924469b57eb5 --- src/CommandStubs.pl | 6 +++--- src/DynaConfig.pl | 2 +- src/Factoids/Update.pl | 2 +- src/IRC/Irc.pl | 2 +- src/IRC/IrcHooks.pl | 12 ++++++++++-- src/IRC/Schedulers.pl | 12 ++++++------ src/Modules/Debian.pl | 8 ++++---- src/Modules/News.pl | 17 ++++++++++------- src/Modules/Topic.pl | 4 ++-- src/UserExtra.pl | 15 +++++++++++++-- src/modules.pl | 2 +- 11 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/CommandStubs.pl b/src/CommandStubs.pl index 96713d6..e3586e0 100644 --- a/src/CommandStubs.pl +++ b/src/CommandStubs.pl @@ -73,7 +73,7 @@ sub parseCmdHook { } if ($hash{NoArgs} and $flatarg) { - &DEBUG("cmd $ident does not take args; skipping."); + &DEBUG("cmd $ident does not take args ('$flatarg'); skipping."); next; } @@ -317,7 +317,7 @@ sub Modules { } } my $topstr = ""; - &DEBUG("tp => $tp"); + &DEBUG("*stats: tp => $tp"); if (scalar @top) { $topstr = ". Top ".scalar(@top).": ".join(', ', @top); } @@ -881,7 +881,7 @@ sub textstats_main { } my $topstr = ""; - &DEBUG("tp => $tp"); + &DEBUG("*stats: tp => $tp"); if (scalar @top) { $topstr = ". Top ".scalar(@top).": ".join(', ', @top); } diff --git a/src/DynaConfig.pl b/src/DynaConfig.pl index d90f6fa..b76e757 100644 --- a/src/DynaConfig.pl +++ b/src/DynaConfig.pl @@ -63,7 +63,7 @@ sub readUserFile { } if (!defined $nick) { - &WARN("invalid line: $_"); + &WARN("DynaConfig: invalid line: $_"); next; } diff --git a/src/Factoids/Update.pl b/src/Factoids/Update.pl index 3030bef..d0b57d1 100644 --- a/src/Factoids/Update.pl +++ b/src/Factoids/Update.pl @@ -138,7 +138,7 @@ sub update { if ($also) { # 'is also'. if ($exists =~ /^ see /i) { - &DEBUG("todo: append to linked factoid."); + &DEBUG("Update.pl: todo: append to linked factoid."); } if ($also_or) { # 'is also ||'. diff --git a/src/IRC/Irc.pl b/src/IRC/Irc.pl index 46bb68a..e8a3a92 100644 --- a/src/IRC/Irc.pl +++ b/src/IRC/Irc.pl @@ -654,7 +654,7 @@ sub joinNextChan { my $rate = sprintf("%.1f", $delta / @c); delete $cache{joinTime}; - &DEBUG("time taken to join all chans: $timestr; rate: $rate sec/join"); + &status("time taken to join all chans: $timestr; rate: $rate sec/join"); } # chanserv check: global channels, in case we missed one. diff --git a/src/IRC/IrcHooks.pl b/src/IRC/IrcHooks.pl index 9c0dcdc..2d03d0c 100644 --- a/src/IRC/IrcHooks.pl +++ b/src/IRC/IrcHooks.pl @@ -616,6 +616,7 @@ sub on_msg { $uh = $event->userhost(); $nuh = $nick."!".$uh; $msgtime = time(); + $h = $host; if ($nick eq $ident) { # hopefully ourselves. if ($msg eq "TEST") { @@ -795,8 +796,14 @@ sub on_ping { sub on_ping_reply { my ($self, $event) = @_; - my $nick = $event->nick; - my $lag = time() - ($event->args)[1]; + my $nick = $event->nick; + my $t = ($event->args)[1]; + if (!defined $t) { + &WARN("on_ping_reply: t == undefined."); + return; + } + + my $lag = time() - $t; &status(">>> ${b_green}CTCP PING$ob reply from $b_cyan$nick$ob: $lag sec."); } @@ -812,6 +819,7 @@ sub on_public { $msgType = "public"; # todo: move this out of hookMsg to here? ($user,$host) = split(/\@/, $uh); + $h = $host; # rare case should this happen - catch it just in case. if ($bot_pid != $$) { diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 66ab136..b2dd6f9 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -440,7 +440,7 @@ sub netsplitCheck { } $cache{'netsplitCache'}++; - &DEBUG("running netsplitCheck... $cache{netsplitCache}"); +# &DEBUG("running netsplitCheck... $cache{netsplitCache}"); if (!scalar %netsplit and scalar %netsplitservers) { &DEBUG("nsC: !hash netsplit but hash netsplitservers <- removing!"); @@ -493,7 +493,7 @@ sub netsplitCheck { if ($delete) { my $j = scalar(keys %netsplit); - &DEBUG("nsC: removed from netsplit list: (before: $count; after: $j)"); + &status("nsC: removed from netsplit list: (before: $count; after: $j)"); } if (!scalar %netsplit and scalar %netsplitservers) { @@ -642,7 +642,7 @@ sub leakCheck { $count += scalar(keys %{ $flood{$blah1}{$blah2} }); } } - &DEBUG("leak: hash flood has $count total keys.",2); + &VERB("leak: hash flood has $count total keys.",2); # floodjoin. $count = 0; @@ -651,11 +651,11 @@ sub leakCheck { $count += scalar(keys %{ $floodjoin{$blah1}{$blah2} }); } } - &DEBUG("leak: hash floodjoin has $count total keys.",2); + &VERB("leak: hash floodjoin has $count total keys.",2); # floodwarn. $count = scalar(keys %floodwarn); - &DEBUG("leak: hash floodwarn has $count total keys.",2); + &VERB("leak: hash floodwarn has $count total keys.",2); my $chan; foreach $chan (grep /[A-Z]/, keys %channels) { @@ -670,7 +670,7 @@ sub leakCheck { # chanstats $count = scalar(keys %chanstats); - &DEBUG("leak: hash chanstats has $count total keys.",2); + &VERB("leak: hash chanstats has $count total keys.",2); # nuh. my $delete = 0; diff --git a/src/Modules/Debian.pl b/src/Modules/Debian.pl index 27f5589..0538c9d 100644 --- a/src/Modules/Debian.pl +++ b/src/Modules/Debian.pl @@ -390,7 +390,7 @@ sub searchAuthor { $package = ""; } else { - &::WARN("invalid line: '$_'."); + &::WARN("debian: invalid line: '$_' (1)."); } } close IN; @@ -497,7 +497,7 @@ sub searchDesc { $desc{$package} = $desc; $package = ""; } else { - &::WARN("invalid line: '$_'."); + &::WARN("debian: invalid line: '$_'. (2)"); } } close IN; @@ -870,7 +870,7 @@ sub generateIndex { system("cp $idx $idx-old"); } - &::DEBUG("deb: gIndex: calling DebianDownload($dist, ...)."); + &::DEBUG("deb: gIndex: calling DebianDownload($dist, ...).") if ($debug); &DebianDownload($dist, &fixDist($dist, %urlpackages) ); &::status("Debian: generating index for '$dist'."); @@ -1129,7 +1129,7 @@ sub checkEval { } sub searchDescFE { - &::DEBUG("deb: FE called for searchDesc"); +# &::DEBUG("deb: FE called for searchDesc"); my ($query) = @_; my @list = &searchDesc($query); diff --git a/src/Modules/News.pl b/src/Modules/News.pl index 2942f85..c9a8fdd 100644 --- a/src/Modules/News.pl +++ b/src/Modules/News.pl @@ -396,8 +396,8 @@ sub list { &::msg($who, "|= Last updated $timestr ago."); &::msg($who, " \037Num\037 \037Item ".(" "x40)." \037"); - &DEBUG("list: expire = $expire"); - &::DEBUG("list: eno = $eno"); +# &::DEBUG("news: list: expire = $expire"); +# &::DEBUG("news: list: eno = $eno"); my $i = 1; foreach ( &getNewsAll() ) { @@ -570,12 +570,15 @@ sub set { my($args) = @_; my($item, $what, $value); + if (!defined $args) { + &::DEBUG("news: set: args == NULL."); + return; + } + $item = $1 if ($args =~ s/^(\S+)\s*//); $what = $1 if ($args =~ s/^(\S+)\s*//); $value = $args; - &::DEBUG("news: set called."); - if ($item eq "") { &::help("news set"); return; @@ -672,7 +675,7 @@ sub set { } my $auth = 0; - &::DEBUG("news: who => '$who'"); +# &::DEBUG("news: who => '$who'"); my $author = $::news{$chan}{$news}{Author}; $auth++ if ($::who eq $author); $auth++ if (&::IsFlag("o")); @@ -916,7 +919,7 @@ sub getNewsItem { } if (@items) { - &::DEBUG("news: gNI: part_string->full_string: $what->$items[0]"); +# &::DEBUG("news: gNI: part_string->full_string: $what->$items[0]"); return $items[0]; } else { &::DEBUG("news: gNI: No match for '$what'"); @@ -924,7 +927,7 @@ sub getNewsItem { } } - &::ERROR("getNewsItem: Should not happen (what = $what)"); + &::ERROR("news: gNI: should not happen (what = $what)"); return; } diff --git a/src/Modules/Topic.pl b/src/Modules/Topic.pl index 60e5c3b..c0d9d95 100644 --- a/src/Modules/Topic.pl +++ b/src/Modules/Topic.pl @@ -55,7 +55,7 @@ sub topicDecipher { # Usage: &topicCipher(@topics); sub topicCipher { if (!@_) { - &DEBUG("topicCipher: topic is NULL."); + &WARN("topicCipher: topic is NULL for $chan."); return; } @@ -390,7 +390,7 @@ sub Topic { undef @subtopics; # lets reuse this array. foreach (@newtopics) { - next if ($_ eq ""); + next if (!defined $_ or $_ eq ""); push(@subtopics, $_); } diff --git a/src/UserExtra.pl b/src/UserExtra.pl index 4912479..23b2873 100644 --- a/src/UserExtra.pl +++ b/src/UserExtra.pl @@ -161,7 +161,7 @@ sub chaninfo { } # todo: show top 3 with percentages? - my($count) = (sort { $a <=> $b } keys %new)[0]; + my($count) = (sort { $new{$a} <=> $new{$b} } keys %new)[0]; if ($count) { $reply .= ". \002$count\002 has said the most with a total of \002$new{$count}\002 messages"; } @@ -263,6 +263,9 @@ sub ispell { } elsif (/^\+/) { &DEBUG("spell: '+' found => '$_'."); last; + } elsif (/^# (.*?) 0$/) { + # none found. + last; } else { &DEBUG("spell: unknown: '$_'."); } @@ -393,6 +396,11 @@ sub DNS { my $pid; $dns =~ s/^\s+|\s+$//g; + if (!defined $dns or $dns =~ /^\s*$/ or $dns =~ / /) { + &help("dns"); + return; + } + if ($dns =~ /(\d+\.\d+\.\d+\.\d+)/) { $match = $1; &status("DNS query by IP address: $match"); @@ -803,7 +811,10 @@ sub userCommands { " ORDER BY counter DESC", 1); foreach (keys %hash) { - &DEBUG("cmdstats: hash{$_} => $hash{$_}"); + my $i = $_; + foreach (keys %{ $hash{$i} }) { + &DEBUG("cmdstats: $hash{$i}{$_} = $_"); + } } &DEBUG("end of cmdstats."); diff --git a/src/modules.pl b/src/modules.pl index 224db3a..43d623e 100644 --- a/src/modules.pl +++ b/src/modules.pl @@ -362,7 +362,7 @@ if ($@) { &showProc(" (Time::HiRes)"); sub AUTOLOAD { - if (defined $::AUTOLOAD) { + if (!defined $AUTOLOAD and defined $::AUTOLOAD) { &DEBUG("AUTOLOAD: hrm.. ::AUTOLOAD defined!"); } return unless (defined $AUTOLOAD); -- 2.39.2