}
# babel bot: Jonathan Feinberg++
- if (&IsChanConf("babelfish") and $message =~ m{
+ if ($message =~ m{
^\s*
(?:babel(?:fish)?|x|xlate|translate)
\s+
($babel_lang_regex)\w* # which language?
\s*
(.+) # The phrase to be translated
- }xoi) {
+ }xoi) {
+ return unless (&hasParam("babelfish"));
&Forker("babelfish", sub { &babel::babelfish(lc $1, lc $2, $3); } );
return;
}
- if (&IsChanConf("debian")) {
- my $debiancmd = 'conflicts?|depends?|desc|file|info|provides?';
- $debiancmd .= '|recommends?|suggests?|maint|maintainer';
- if ($message =~ /^($debiancmd)(\s+(.*))?$/i) {
- my $package = lc $3;
+ my $debiancmd = 'conflicts?|depends?|desc|file|info|provides?';
+ $debiancmd .= '|recommends?|suggests?|maint|maintainer';
- if (defined $package) {
- &Forker("debian", sub { &Debian::infoPackages($1, $package); } );
- } else {
- &help($1);
- }
+ if ($message =~ /^($debiancmd)(\s+(.*))?$/i) {
+ return unless (&hasParam("debian"));
+ my $package = lc $3;
- return;
+ if (defined $package) {
+ &Forker("debian", sub { &Debian::infoPackages($1, $package); } );
+ } else {
+ &help($1);
}
+
+ return;
}
# google searching. Simon++
- if (&IsChanConf("wwwsearch") and $message =~ /^(?:search\s+)?(\S+)\s+for\s+['"]?(.*?)['"]?\s*\?*$/i) {
+ if ($message =~ /^(?:search\s+)?(\S+)\s+for\s+['"]?(.*?)['"]?\s*\?*$/i) {
return unless (&hasParam("wwwsearch"));
&Forker("wwwsearch", sub { &W3Search::W3Search($1,$2); } );
&seenFlush(); # very evil hack. oh well, better safe than sorry.
- ### TODO: Support &dbGetRowInfo(); like in &FactInfo();
+ ### TODO: Support &dbGetColInfo(); like in &FactInfo();
my $select = "nick,time,channel,host,message";
if ($person eq "random") {
@seen = &randKey("seen", $select);
sub doQuestion {
# my doesn't allow variables to be inherinted, local does.
# following is used in math()...
- local($query) = @_;
- local($reply) = "";
- local $finalQMark = $query =~ s/\?+\s*$//;
- $finalQMark += $query =~ s/\?\s*$//;
- $query =~ s/^\s+|\s+$//g;
+ local($query) = @_;
+ local($reply) = "";
+ local $finalQMark = $query =~ s/\?+\s*$//;
+ $finalQMark += $query =~ s/\?\s*$//;
+ $query =~ s/^\s+|\s+$//g;
if (!defined $query or $query =~ /^\s*$/) {
- &FIXME("doQ: query == NULL (message => $message)");
return '';
}
}
# also checking.
- my $also = ($rhs =~ s/^(\-)?also //i);
- &DEBUG("1=>$1"); # this does not work!
+ my $also = ($rhs =~ s/^-?also //i);
my $also_or = ($also and $rhs =~ s/\s+(or|\|\|)\s+//);
# freshmeat
if (!$exists) {
# nice 'are' hack (or work-around).
if ($mhs =~ /^are$/i and $rhs !~ /<\S+>/) {
- &DEBUG("Update: 'are' hack detected.");
+ &status("Update: 'are' hack detected.");
$mhs = "is";
$rhs = "<REPLY> are ". $rhs;
}
# if ($exists =~ s/\,\s*$/, /) {
if ($exists =~ /\,\s*$/) {
&DEBUG("current has trailing comma, just append as is");
+ &DEBUG("Up: exists => $exists");
+ &DEBUG("Up: rhs => $rhs");
# $rhs =~ s/^\s+//;
# $rhs = $exists." ".$rhs; # keep comma.
}
if ($exists =~ /\.\s*$/) {
&DEBUG("current has trailing period, just append as is with 2 WS");
+ &DEBUG("Up: exists => $exists");
+ &DEBUG("Up: rhs => $rhs");
# $rhs =~ s/^\s+//;
# use ucfirst();?
# $rhs = $exists." ".$rhs; # keep comma.
}
# !scalar @joinchan:
-
if (exists $cache{joinTime}) {
my $delta = time() - $cache{joinTime};
- my $timestr = &Time2String($delta);
+ my $timestr = &Time2String($delta);
my $rate = sprintf("%.1f", $delta / &getJoinChans() );
delete $cache{joinTime};
# modes w/ target affecting nick => cache it.
if ($mode =~ /[bov]/) {
- if ($mode eq "o" and $nick eq "ChanServ" and $target =~ /^\Q$ident$\E/i) {
+ if ($mode eq "o" and $nick eq "ChanServ" and $target =~ /^\Q$ident\E$/i) {
&DEBUG("hookmode: chanserv deopped us! asking");
&chanServCheck($chan);
}
}
### chanlimit check.
- &chanLimitVerify($chan);
+# &chanLimitVerify($chan);
### wingate:
&wingateCheck();
# chanlimit code.
if (&ChanConfList("chanlimitcheck") and !scalar keys %netsplit) {
- &DEBUG("on_quit: netsplit detected; disabling chan limit.");
+ &DEBUG("on_quit: netsplit detected on $chan; disabling chan limit.");
&rawout("MODE $chan -l");
}
return if ($_[0] eq "2");
}
+ &DEBUG("running netsplitCheck...");
+
foreach $s1 (keys %netsplitservers) {
+ &DEBUG("nsC: s1 => $s1");
+
foreach $s2 (keys %{ $netsplitservers{$s1} }) {
+ my $delta = time() - $netsplitservers{$s1}{$s2};
+ &DEBUG("nss{$s1}{$s2} = $delta");
+
if (time() - $netsplitservers{$s1}{$s2} > 3600) {
&status("netsplit between $s1 and $s2 appears to be stale.");
delete $netsplitservers{$s1}{$s2};
if ($param{'DBType'} =~ /^mysql|pg|postgres/i) {
foreach $nick (keys %seencache) {
my $retval = &dbReplace("seen", "nick", $nick, (
- "nick" => $seencache{$nick}{'nick'},
+### "nick" => $seencache{$nick}{'nick'},
"time" => $seencache{$nick}{'time'},
"host" => $seencache{$nick}{'host'},
"channel" => $seencache{$nick}{'chan'},
return if ($_[0] eq "2"); # defer.
}
- &DEBUG("miscCheck2: Doing debian checking...");
-
# debian check.
opendir(DEBIAN, "$bot_base_dir/debian");
foreach ( grep /gz$/, readdir(DEBIAN) ) {
my $defaultdist = "sid";
my $refresh = &::getChanConfDefault("debianRefreshInterval",7)
* 60 * 60 * 24;
+my $debug = 1;
### ... old
#my %dists = (
next unless ($update);
- &::DEBUG("announce == $announce.");
+ &::DEBUG("announce == $announce.") if ($debug);
if ($good + $bad == 0 and !$announce) {
&::status("Debian: Downloading files for '$dist'.");
&::msg($::who, "Updating debian files... please wait.");
}
if (exists $::debian{$url}) {
- &::DEBUG("2: ".(time - $::debian{$url})." <= $refresh");
+ &::DEBUG("2: ".(time - $::debian{$url})." <= $refresh") if ($debug);
next if (time() - $::debian{$url} <= $refresh);
- &::DEBUG("stale for url $url; updating!");
+ &::DEBUG("stale for url $url; updating!") if ($debug);
}
if ($url =~ /^ftp:\/\/(.*?)\/(\S+)\/(\S+)$/) {
}
if (! -f $file) {
- &::DEBUG("deb: down: ftpGet: !file");
+ &::WARN("deb: down: ftpGet: !file");
$bad++;
next;
}
# system("cp debian/Contents-potato-i386-non-US.gz debian/Contents-woody-i386-non-US.gz");
# }
- &::DEBUG("deb: download: good.");
+ &::DEBUG("deb: download: good.") if ($debug);
$good++;
} else {
&::ERROR("Debian: invalid format of url => ($url).");
$pkg =~ s/\,/\037\,\037/g; # underline ','.
push(@list, "(". join(', ',@sublist) .") in $pkg");
}
- &::DEBUG("debian: 0");
# sort the total list from shortest to longest...
@list = sort { length $a <=> length $b } @list;
# show how long it took.
- &::DEBUG("debian: 1");
my $delta_time = &::timedelta($start_time);
- &::DEBUG("debian: 2");
&::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
- &::DEBUG("debian: 3");
my $prefix = "Debian Search of '$query' ";
if (scalar @list) { # @list.
&::pSReply( &::formListReply(0, $prefix, @list) );
+
} else { # !@list.
&::DEBUG("ok, !\@list, searching desc for '$query'.");
my @list = &searchDesc($query);
if (!scalar @list) {
my $prefix = "Debian Package/File/Desc Search of '$query' ";
&::pSReply( &::formListReply(0, $prefix, ) );
+
} elsif (scalar @list == 1) { # list = 1.
&::DEBUG("list == 1; showing package info of '$list[0]'.");
&infoPackages("info", $list[0]);
+
} else { # list > 1.
my $prefix = "Debian Desc Search of '$query' ";
&::pSReply( &::formListReply(0, $prefix, @list) );
if ($good == 0 and $bad != 0) {
my %urls = &fixDist($dist, %urlpackages);
&::DEBUG("deb: download 2.");
+
if (!&DebianDownload($dist, %urls)) {
&::ERROR("Debian(sA): could not download files.");
return;
while (<IN>) {
if (/^Package: (\S+)$/) {
$package = $1;
+
} elsif (/^Maintainer: (.*) \<(\S+)\>$/) {
my($name,$email) = ($1,$2);
if ($package eq "") {
$maint{$name}{$email} = 1;
$pkg{$name}{$package} = 1;
$package = "";
+
} else {
&::WARN("invalid line: '$_'.");
}
# TODO: should we only search email if '@' is used?
if (scalar keys %hash < 15) {
my $name;
+
foreach $name (keys %maint) {
my $email;
+
foreach $email (keys %{ $maint{$name} }) {
next unless ($email =~ /\Q$query\E/i);
next if (exists $hash{$name});
if ($good == 0 and $bad != 0) {
my %urls = &fixDist($dist, %urlpackages);
&::DEBUG("deb: download 2c.");
+
if (!&DebianDownload($dist, %urls)) {
&::ERROR("Debian(sD): could not download files.");
return;
# hrm...
my %urls = &fixDist($dist, %urlpackages);
if ($dist ne "incoming") {
- &::DEBUG("deb: download 3.");
+ &::DEBUG("deb: download 3.") if ($debug);
+
if (!&DebianDownload($dist, %urls)) { # no good download.
&::WARN("Debian(iP): could not download ANY files.");
}
my $olddist = $dist;
$dist = &getDistro($dist);
- &::DEBUG("D: validPackage($package, $dist) called.");
+ &::DEBUG("D: validPackage($package, $dist) called.") if ($debug);
my $error = 0;
while (!open(IN, "debian/Packages-$dist.idx")) {
my $i = 0;
my %factinfo;
my @factinfo = &getFactInfo($faqtoid,"*");
- foreach ( &dbGetRowInfo("factoids") ) {
+ foreach ( &dbGetColInfo("factoids") ) {
$factinfo{$_} = $factinfo[$i] || '';
$i++;
}
&set($2);
} elsif ($what =~ /^(\d+)$/i) {
- &::DEBUG("read shortcut called.");
+ &::VERB("News: read shortcut called.",2);
&read($1);
} elsif ($what =~ /^read(\s+(.*))?$/i) {
if (time() - $::news{$chan}{$_}{Time} > 60*60*24*3) {
&::DEBUG("deleting news{$chan}{$_} because it was too old and had no text info.");
delete $::news{$chan}{$_};
- } else {
- &::WARN("news: news{$chan}{$_}{Text} undef.");
}
next;
if (!$flag) {
return unless ($unread);
- my $reply = "There are unread news in $chan ($unread unread, $total total). /msg $::ident news latest.";
+ my $reply = "There are unread news in $chan ($unread unread, $total total). /msg $::ident news latest";
$reply .= " If you don't want further news notification, /msg $::ident news unnotify" if ($unread == $total);
&::notice($::who, $reply);
$continue++ if ($forked{$name}{PID} == $$);
if ($continue) {
- &DEBUG("hrm.. fork pid == mypid == $$; how did this happen?");
+ &WARN("hrm.. fork pid == mypid == $$; how did this happen?");
+
} elsif ( -d "/proc/$forked{$name}{PID}") {
&status("fork: still running; good. BAIL OUT.");
return 0;
+
} else {
&WARN("Found dead fork; removing and resetting.");
$continue = 1;
if ($continue) {
# NOTHING.
+
} elsif (time() - $time > 900) { # stale fork > 15m.
&status("forked: forked{$name} presumably exited without notifying us.");
+
} else { # fresh fork.
&msg($who, "$name is already running ". &Time2String(time() - $time));
return 0;
$message = $tell_obj;
$done++ unless (&Modules());
- &DEBUG("setting old values of who and msgType.");
+ &VERB("teel: setting old values of who and msgType.",2);
$who = $oldwho;
$msgType = $oldmtype;
}
#####
-# Usage: &dbGetRowInfo();
-sub dbGetRowInfo {
+# Usage: &dbGetColInfo();
+sub dbGetColInfo {
my ($db) = @_;
if (scalar @{ "${db}_format" }) {