]> git.donarmstrong.com Git - infobot.git/commitdiff
- Remaining files that were changed due to removal of $noreply or
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 28 Jan 2001 13:32:22 +0000 (13:32 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 28 Jan 2001 13:32:22 +0000 (13:32 +0000)
  indirectly caused by the change over to dynamic configuration

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

26 files changed:
src/Factoids/Question.pl
src/Factoids/Reply.pl
src/Factoids/Statement.pl
src/Factoids/Update.pl
src/IRC/Irc.pl
src/Misc.pl
src/Modules/Debian.pl
src/Modules/DebianExtra.pl
src/Modules/Dict.pl
src/Modules/Factoids.pl
src/Modules/Freshmeat.pl
src/Modules/Kernel.pl
src/Modules/Quote.pl
src/Modules/Search.pl
src/Modules/Slashdot3.pl
src/Modules/Topic.pl
src/Modules/Units.pl
src/Modules/Uptime.pl
src/Modules/W3Search.pl
src/Modules/Wingate.pl
src/Modules/babel.pl
src/Modules/insult.pl
src/Modules/nickometer.pl
src/Process.pl
src/Shm.pl
src/db_mysql.pl

index 1347ec9c4f6cd47939ac2ccaaf59e202293c1286..1cef70959dc1ad983d8bc14520ee807516e0113e 100644 (file)
@@ -43,7 +43,7 @@ sub doQuestion {
 
     # dangerous; common preambles should be stripped before here
     if ($query =~ /^forget /i or $query =~ /^no, /) {
-       return $noreply if (exists $bots{$nuh});
+       return if (exists $bots{$nuh});
     }
 
     # convert to canonical reference form
@@ -78,14 +78,13 @@ sub doQuestion {
 
     # valid factoid.
     if ($query =~ s/[\!\.]$//) {
-       &DEBUG("Question: Pushing query without trailing symbols.");
        push(@query,$query);
     }
 
     for (my$i=0; $i<scalar(@query); $i++) {
-       $query = $query[$i];
+       $query  = $query[$i];
        $result = &getReply($query);
-       next if ($result eq "");
+       next if (!defined $result or $result eq "");
 
        # 'see also' factoid redirection support.
        if ($result =~ /^see( also)? (.*?)\.?$/) {
@@ -104,7 +103,7 @@ sub doQuestion {
     if (&IsParam("freshmeatForFactoid")) {
        &loadMyModule($myModules{'freshmeat'});
        $result = &Freshmeat::showPackage($query);
-       return $result unless ($result eq $noreply);
+       return $result if (defined $result);
     }
 
     ### TODO: Use &Forker(); move function to Debian.pl
@@ -113,13 +112,14 @@ sub doQuestion {
        $result = &Debian::DebianFind($query);  # ???
        ### TODO: debian module should tell, through shm, that it went
        ###       ok or not.
-###    return $result unless ($result eq $noreply);
+###    return $result if (defined $result);
     }
 
     if ($questionWord ne "" or $finalQMark) {
        # if it has not been explicitly marked as a question
        if ($addressed and $reply eq "") {
-           &status("notfound: <$who> ".join(' :: ', @query));
+           &status("notfound: <$who> ".join(' :: ', @query))
+                                               if ($finalQMark);
 
            return '' unless (&IsParam("friendlyBots"));
 
index 2a2899e8b440b2cc935da8a3ecba0ed3f0b29579..c11938b866b54bd5e89dac03e627d6cc59c817d5 100644 (file)
@@ -149,7 +149,7 @@ sub getReply {
                # fix the person.
            } else {
                if ($reply =~ /^you are / or $reply =~ / you are /) {
-                   return $noreply if ($addressed);
+                   return if ($addressed);
                }
            }
        }
index fe83ab3081972fdf8d53e3cbdbf725a538a22a20..9bfd6231f65f64efcc312afa2d382e848b448bc8 100644 (file)
@@ -11,7 +11,6 @@
 ##
 ##     otherwise return
 ##             - null for confused.
-##             - NOREPLY not to respond.
 ##
 
 if (&IsParam("useStrict")) { use strict; }
@@ -23,7 +22,7 @@ sub doStatement {
     $in =~ s/^no([, ]+)//i;    # 'no, '.
 
     # check if we need to be addressed and if we are
-    return $noreply unless ($learnok);
+    return unless ($learnok);
 
     my($urlType) = "";
 
@@ -43,10 +42,10 @@ sub doStatement {
     # acceptUrl.
     if (&IsParam("acceptUrl")) {
        if ($param{'acceptUrl'} eq 'REQUIRE') {         # require url type.
-           return $noreply if ($urlType eq "");
+           return if ($urlType eq "");
        } elsif ($param{'acceptUrl'} eq 'REJECT') {
            &status("REJECTED URL entry") if (&IsParam("VERBOSITY"));
-           return $noreply unless ($urlType eq "");
+           return unless ($urlType eq "");
        } else {
            # OPTIONAL
        }
@@ -66,7 +65,7 @@ sub doStatement {
 
        # break if either lhs or rhs is NULL.
        if ($lhs eq "" or $rhs eq "") {
-           return $noreply;
+           return;
        }
 
        # lets check if it failed.
@@ -75,10 +74,10 @@ sub doStatement {
                &status("IGNORE statement: <$who> $message");
                &performReply( &getRandom(keys %{$lang{'confused'}}) );
            }
-           return $noreply;
+           return;
        }
 
-       return $noreply if (!$addressed and $lhs =~ /\s+/);
+       return if (!$addressed and $lhs =~ /\s+/);
 
        &status("statement: <$who> $message");
 
@@ -96,14 +95,14 @@ sub doStatement {
            if ($ord > 170 and $ord < 220) {
                &status("statement: illegal character '$_' $ord.");
                &performAddressedReply("i'm not going to learn illegal characters");
-               return $noreply;
+               return;
            }
        }
 
        return &update($lhs, $mhs, $rhs);
     }
 
-    return '';
+    return "CONTINUE";
 }
 
 1;
index 9b5c963fbca446d475b4c77fa7975225f8a54b7c..af6f4c4533d65e35ed2e1acd1b3671158425e705 100644 (file)
@@ -16,19 +16,19 @@ sub update {
     $lhs =~ s/\s+/ /g;
 
     # locked.
-    return $noreply if (&IsLocked($lhs) == 1);
+    return if (&IsLocked($lhs) == 1);
 
     # profanity.
     if (&IsParam("profanityCheck") and &hasProfanity($rhs)) {
        &msg($who, "please, watch your language.");
-       return $noreply;
+       return;
     }
 
     # teaching.
     if (&IsFlag("t") ne "t") {
        &msg($who, "permission denied.");
        &status("alert: $who wanted to teach me.");
-       return $noreply;
+       return;
     }
 
     # invalid verb.
@@ -42,7 +42,7 @@ sub update {
        length($rhs) > $param{'maxDataSize'})
     {
        &performAddressedReply("that's too long");
-       return $noreply;
+       return;
     }
 
     #
@@ -56,14 +56,14 @@ sub update {
        if (&dbGet("freshmeat", "name", $lhs, "name")) {
            &msg($who, "permission denied. (freshmeat)");
            &status("alert: $who wanted to teach me something that freshmeat already has info on.");
-           return $noreply;
+           return;
        }
     }
 
     if (my $exists = &getFactoid($lhs)) {      # factoid exists.
        if ($exists eq $rhs) {
            &performAddressedReply("i already had it that way");
-           return $noreply;
+           return;
        }
 
        if ($also) {                    # 'is also'.
@@ -107,7 +107,7 @@ sub update {
            if (length($rhs) > $param{'maxDataSize'}) {
                if (length($rhs) > length($exists)) {
                    &performAddressedReply("that's too long");
-                   return $noreply;
+                   return;
                } else {
                    &status("Update: new length is still longer than maxDataSize but less than before, we'll let it go.");
                }
@@ -129,7 +129,7 @@ sub update {
 
                if (IsFlag("m") ne "m" and $author !~ /^\Q$who\E\!/i) {
                    &msg($who, "you can't change that factoid.");
-                   return $noreply;
+                   return;
                }
 
                &performAddressedReply("okay");
@@ -151,7 +151,7 @@ sub update {
                    &performStrictReply("...but \002$lhs\002 is already something else...");
                    &status("FAILED update: <$who> \'$lhs\' =$mhs=> \'$rhs\'");
                }
-               return $noreply;
+               return;
            }
        }
     } else {                   # not exists.
index 093420105458f6cffbfe290ccc0f40a7ca30aea5..c12fe42004db92c2a042aac1bdea70cfaef9ed49 100644 (file)
@@ -10,10 +10,11 @@ if (&IsParam("useStrict")) { use strict; }
 # static scalar variables.
 $mask{ip}      = '(\d+)\.(\d+)\.(\d+)\.(\d+)';
 $mask{host}    = '[\d\w\_\-\/]+\.[\.\d\w\_\-\/]+';
-$mask{chan}    = '[\#\&\+]\S*';
+$mask{chan}    = '[\#\&]\S*';
 my $isnick1    = 'a-zA-Z\[\]\{\}\_\`\^\|\\\\';
 my $isnick2    = '0-9\-';
 $mask{nick}    = "[$isnick1]{1}[$isnick1$isnick2]*";
+$mask{nuh}     = '\S*!\S*\@\S*';
 
 sub ircloop {
     my $error  = 0;
@@ -157,7 +158,7 @@ sub rawout {
 
 sub say {
     my ($msg) = @_;
-    if (!defined $msg or $msg eq $noreply) {
+    if (!defined $msg) {
        $msg ||= "NULL";
        &DEBUG("say: msg == $msg.");
        return;
@@ -184,7 +185,7 @@ sub msg {
        return;
     }
 
-    if (!defined $msg or $msg eq $noreply) {
+    if (!defined $msg) {
        $msg ||= "NULL";
        &DEBUG("msg: msg == $msg.");
        return;
@@ -235,7 +236,9 @@ sub notice{
 
 
 sub DCCBroadcast {
-    my ($txt) = @_;
+    my ($txt,$flag) = @_;
+
+    ### FIXME: flag not supported yet.
 
     foreach (keys %{$dcc{'CHAT'}}) {
        $conn->privmsg($dcc{'CHAT'}{$_}, $txt);
@@ -284,6 +287,10 @@ sub performAddressedReply {
     &performReply(@_);
 }
 
+sub pSReply {
+    &performStrictReply(@_);
+}
+
 # Usage: &performStrictReply($reply);
 sub performStrictReply {
     my ($reply) = @_;
@@ -511,6 +518,14 @@ sub GetNickInChans {
     return @array;
 }
 
+# Usage: &GetNicksInChan($chan);
+sub GetNicksInChan {
+    my ($chan) = @_;
+    my @array;
+
+    return keys %{ $channels{$chan}{''} };
+}
+
 sub IsNickInChan {
     my ($nick,$chan) = @_;
 
@@ -584,29 +599,36 @@ sub clearIRCVars {
     &DEBUG("clearIRCVars() called!");
     undef %channels;
     undef %floodjoin;
-    @joinchan = split /[\t\s]+/, $param{'join_channels'};
+
+    @joinchan  = &getJoinChans();
 }
 
-sub makeChanList {
-    my ($str)  = @_;
-    my $inverse        = 0;
+sub getJoinChans {
     my @chans;
+    my @skip;
 
-    if ($str eq "ALL") {
-       return(keys %channels);
-    } elsif ($str =~ s/^ALL but //i) {
-       @chans = keys %channels;
-       foreach (split /[\s\t\,]+/, lc $str) {
-           @chans = grep !/^$_$/, @chans;
+    foreach (keys %chanconf) {
+       my $val = $chanconf{$_}{autojoin};
+       my $skip = 0;
+       if (defined $val) {
+           $skip++ if ($val eq "0");
+       } else {
+           $skip++;
        }
-    } else {
-       foreach (split /[\s\t\,]+/, lc $str) {
-           next unless (&validChan($_));
-           push(@chans, $_);
+
+       if ($skip) {
+           push(@skip, $_);
+           next;
        }
+
+       push(@chans, $_);
     }
 
-    @chans;
+    if (scalar @skip) {
+       &status("channels not auto-joining: @skip");
+    }
+
+    return @chans;
 }
 
 sub closeDCC {
@@ -669,4 +691,10 @@ sub joinfloodCheck {
     &DEBUG("jfC: $delete deleted.") if ($delete);
 }
 
+sub getHostMask {
+    my($n) = @_;
+
+    &FIXME("getHostMask...");
+}
+
 1;
index 236c1f9090b5ede9f925f2ae437ba6614b608ed2..d105bf65209d02ab84f8d4134e231e675a4909b6 100644 (file)
@@ -63,10 +63,10 @@ sub help {
 
     if (exists $help{$topic}) {
        foreach (split /\n/, $help{$topic}) {
-           &msg($who,$_);
+           &performStrictReply($_);
        }
     } else {
-       &msg($who, "no help on $topic.  Use 'help' without arguments.");
+       &pSReply("no help on $topic.  Use 'help' without arguments.");
     }
 
     return '';
@@ -164,7 +164,8 @@ sub Time2String {
     my $time = shift;
     my $retval;
 
-    return("0s")       if ($time !~ /\d+/ or $time <= 0);
+    return("0s")
+               if (!defined $time or $time !~ /\d+/ or $time <= 0);
 
     my $s = int($time) % 60;
     my $m = int($time / 60) % 60;
@@ -239,6 +240,11 @@ sub fixString {
 sub fixPlural {
     my ($str,$int) = @_;
 
+    if (!defined $str) {
+       &WARN("fixPlural: str == NULL.");
+       return;
+    }
+
     if ($str eq "has") {
        $str = "have"   if ($int > 1);
     } elsif ($str eq "is") {
@@ -336,6 +342,11 @@ sub getRandom {
 sub getRandomInt {
     my $str = $_[0];
 
+    if (!defined $str) {
+       &WARN("gRI: str == NULL.");
+       return;
+    }
+
     srand();
 
     if ($str =~ /^(\d+)$/) {
@@ -587,10 +598,12 @@ sub hasProfanity {
     return $profanity;
 }
 
+### rename to hasChanConf() ?
 sub hasParam {
     my ($param) = @_;
 
-    if (&IsParam($param)) {
+    ### TODO: specific reason why it failed.
+    if (&IsChanConf($param)) {
        return 1;
     } else {
        &msg($who, "unfortunately, \002$param\002 is disabled in my configuration") unless ($addrchar);
@@ -606,14 +619,15 @@ sub Forker {
     &VERB("double fork detected; not forking.",2) if ($$ != $bot_pid);
 
     if (&IsParam("forking") and $$ == $bot_pid) {
-       return $noreply unless (&addForked($label));
+       return unless &addForked($label);
 
        $SIG{CHLD} = 'IGNORE';
        $pid = eval { fork() };
-       return $noreply if $pid;        # parent does nothing
+       return if $pid;         # parent does nothing
 
        select(undef, undef, undef, 0.2);
-       &status("fork starting for '$label', PID == $$.");
+#      &status("fork starting for '$label', PID == $$.");
+       &status("--- fork starting for '$label', PID == $$ ---");
        &shmWrite($shm,"SET FORKPID $label $$");
 
        sleep 1;
index afbc9afd21276f29146df4429eeda3b810aa56a1..9eea21a5d9aafedbe6c6df0caec0b74a617cc6a2 100644 (file)
@@ -66,12 +66,12 @@ my %urlpackages = (
 # Usage: &DebianDownload(%hash);
 sub DebianDownload {
     my ($dist, %urls)  = @_;
-    my $refresh = $main::param{'debianRefreshInterval'} * 60 * 60 * 24;
+    my $refresh = $::param{'debianRefreshInterval'} * 60 * 60 * 24;
     my $bad    = 0;
     my $good   = 0;
 
     if (! -d "debian/") {
-       &main::status("Debian: creating debian dir.");
+       &::status("Debian: creating debian dir.");
        mkdir("debian/",0755);
     }
 
@@ -94,17 +94,17 @@ sub DebianDownload {
 
        next unless ($update);
 
-       &main::DEBUG("announce == $announce.");
+       &::DEBUG("announce == $announce.");
        if ($good + $bad == 0 and !$announce) {
-           &main::status("Debian: Downloading files for '$dist'.");
-           &main::msg($main::who, "Updating debian files... please wait.");
+           &::status("Debian: Downloading files for '$dist'.");
+           &::msg($::who, "Updating debian files... please wait.");
            $announce++;
        }
 
-       if (exists $main::debian{$url}) {
-           &main::DEBUG("2: ".(time - $main::debian{$url})." <= $refresh");
-           next if (time() - $main::debian{$url} <= $refresh);
-           &main::DEBUG("stale for url $url; updating!");
+       if (exists $::debian{$url}) {
+           &::DEBUG("2: ".(time - $::debian{$url})." <= $refresh");
+           next if (time() - $::debian{$url} <= $refresh);
+           &::DEBUG("stale for url $url; updating!");
        }
 
        if ($url =~ /^ftp:\/\/(.*?)\/(\S+)\/(\S+)$/) {
@@ -113,34 +113,34 @@ sub DebianDownload {
            # error internally to ftp.
            # hope it doesn't do anything bad.
            if ($file =~ /Contents-woody-i386-non-US/) {
-               &main::DEBUG("Skipping Contents-woody-i386-non-US.");
+               &::DEBUG("Skipping Contents-woody-i386-non-US.");
 #              $file =~ s/woody/potato/;
 #              $path =~ s/woody/potato/;
 ###            next;
            }
 
-           if (!&main::ftpGet($host,$path,$thisfile,$file)) {
-               &main::WARN("deb: down: $file == BAD.");
+           if (!&::ftpGet($host,$path,$thisfile,$file)) {
+               &::WARN("deb: down: $file == BAD.");
                $bad++;
                next;
            }
 
            if (! -f $file) {
-               &main::DEBUG("deb: down: ftpGet: !file");
+               &::DEBUG("deb: down: ftpGet: !file");
                $bad++;
                next;
            }
 
            if ($file =~ /Contents-potato-i386-non-US/) {
-               &main::DEBUG("hack: using potato's non-US contents for woody.");
+               &::DEBUG("hack: using potato's non-US contents for woody.");
                system("cp debian/Contents-potato-i386-non-US.gz debian/Contents-woody-i386-non-US.gz");
            }
 
-           &main::DEBUG("deb: download: good.");
+           &::DEBUG("deb: download: good.");
 ##         $ret{$
            $good++;
        } else {
-           &main::ERROR("Debian: invalid format of url => ($url).");
+           &::ERROR("Debian: invalid format of url => ($url).");
            $bad++;
            next;
        }
@@ -151,7 +151,7 @@ sub DebianDownload {
        return 1;
     } else {
        return -1 unless ($bad);        # no download.
-       &main::DEBUG("DD: !good and bad($bad). :(");
+       &::DEBUG("DD: !good and bad($bad). :(");
        return 0;
     }
 }
@@ -164,7 +164,7 @@ sub DebianDownload {
 # Usage: &searchContents($query);
 sub searchContents {
     my ($dist, $query) = &getDistroFromStr($_[0]);
-    &main::status("Debian: Contents search for '$query' on $dist.");
+    &::status("Debian: Contents search for '$query' on $dist.");
     my $dccsend        = 0;
 
     $dccsend++         if ($query =~ s/^dcc\s+//i);
@@ -174,25 +174,25 @@ sub searchContents {
     $query =~ s/\\([\^\$])/$1/g;       # hrm?
     $query =~ s/^\s+|\s+$//g;
 
-    if (!&main::validExec($query)) {
-       &main::msg($main::who, "search string looks fuzzy.");
+    if (!&::validExec($query)) {
+       &::msg($::who, "search string looks fuzzy.");
        return;
     }
 
     if ($dist eq "incoming") {         # nothing yet.
-       &main::DEBUG("sC: dist = 'incoming'. no contents yet.");
+       &::DEBUG("sC: dist = 'incoming'. no contents yet.");
        return;
     } else {
        my %urls = &fixDist($dist, %urlcontents);
        # download contents file.
-       &main::DEBUG("deb: download 1.");
+       &::DEBUG("deb: download 1.");
        if (!&DebianDownload($dist, %urls)) {
-           &main::WARN("Debian: could not download files.");
+           &::WARN("Debian: could not download files.");
        }
     }
 
     # start of search.
-    my $start_time = &main::timeget();
+    my $start_time = &::timeget();
 
     my $found = 0;
     my %contents;
@@ -200,10 +200,10 @@ sub searchContents {
     my $front = 0;
     ### TODO: search properly if /usr/bin/blah is done.
     if ($query =~ s/\$$//) {
-       &main::DEBUG("search-regex found.");
+       &::DEBUG("search-regex found.");
        $grepRE = "$query\[ \t]";
     } elsif ($query =~ s/^\^//) {
-       &main::DEBUG("front marker regex found.");
+       &::DEBUG("front marker regex found.");
        $front = 1;
        $grepRE = $query;
     } else {
@@ -222,8 +222,8 @@ sub searchContents {
     }
 
     if (!scalar @files) {
-       &main::ERROR("sC: no files?");
-       &main::msg($main::who, "failed.");
+       &::ERROR("sC: no files?");
+       &::msg($::who, "failed.");
        return;
     }
 
@@ -254,19 +254,19 @@ sub searchContents {
 
     ### send results with dcc.
     if ($dccsend) {
-       if (exists $main::dcc{'SEND'}{$main::who}) {
-           &main::msg($main::who, "DCC already active!");
+       if (exists $::dcc{'SEND'}{$::who}) {
+           &::msg($::who, "DCC already active!");
            return;
        }
 
        if (!scalar %contents) {
-           &main::msg($main::who,"search returned no results.");
+           &::msg($::who,"search returned no results.");
            return;
        }
 
-       my $file = "$main::param{tempDir}/$main::who.txt";
+       my $file = "$::param{tempDir}/$::who.txt";
        if (!open(OUT,">$file")) {
-           &main::ERROR("Debian: cannot write file for dcc send.");
+           &::ERROR("Debian: cannot write file for dcc send.");
            return;
        }
 
@@ -278,16 +278,16 @@ sub searchContents {
        }
        close OUT;
 
-       &main::shmWrite($main::shm, "DCC SEND $main::who $file");
+       &::shmWrite($::shm, "DCC SEND $::who $file");
 
        return;
     }
 
-    &main::status("Debian: $found contents results found.");
+    &::status("Debian: $found contents results found.");
 
     my @list;
     foreach $pkg (keys %contents) {
-       my @tmplist = &main::fixFileList(keys %{$contents{$pkg}});
+       my @tmplist = &::fixFileList(keys %{$contents{$pkg}});
        my @sublist = sort { length $a <=> length $b } @tmplist;
 
        pop @sublist while (scalar @sublist > 3);
@@ -299,14 +299,14 @@ sub searchContents {
     @list = sort { length $a <=> length $b } @list;
 
     # show how long it took.
-    my $delta_time = &main::timedelta($start_time);
-    &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
+    my $delta_time = &::timedelta($start_time);
+    &::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
 
     my $prefix = "Debian Search of '$query' ";
     if (scalar @list) {        # @list.
-       &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
+       &::pSReply( &::formListReply(0, $prefix, @list) );
     } else {           # !@list.
-       &main::DEBUG("ok, !\@list, searching desc for '$query'.");
+       &::DEBUG("ok, !\@list, searching desc for '$query'.");
        &searchDesc($query);
     }
 }
@@ -315,12 +315,12 @@ sub searchContents {
 # Usage: &searchAuthor($query);
 sub searchAuthor {
     my ($dist, $query) = &getDistroFromStr($_[0]);
-    &main::DEBUG("searchAuthor: dist => '$dist', query => '$query'.");
+    &::DEBUG("searchAuthor: dist => '$dist', query => '$query'.");
     $query =~ s/^\s+|\s+$//g;
 
     # start of search.
-    my $start_time = &main::timeget();
-    &main::status("Debian: starting author search.");
+    my $start_time = &::timeget();
+    &::status("Debian: starting author search.");
 
     my $files;
     my ($bad,$good) = (0,0);
@@ -338,13 +338,13 @@ sub searchAuthor {
        $files .= " ".$_;
     }
 
-    &main::DEBUG("good = $good, bad = $bad...");
+    &::DEBUG("good = $good, bad = $bad...");
 
     if ($good == 0 and $bad != 0) {
        my %urls = &fixDist($dist, %urlpackages);
-       &main::DEBUG("deb: download 2.");
+       &::DEBUG("deb: download 2.");
        if (!&DebianDownload($dist, %urls)) {
-           &main::ERROR("Debian(sA): could not download files.");
+           &::ERROR("Debian(sA): could not download files.");
            return;
        }
     }
@@ -357,14 +357,14 @@ sub searchAuthor {
        } elsif (/^Maintainer: (.*) \<(\S+)\>$/) {
            my($name,$email) = ($1,$2);
            if ($package eq "") {
-               &main::DEBUG("sA: package == NULL.");
+               &::DEBUG("sA: package == NULL.");
                next;
            }
            $maint{$name}{$email} = 1;
            $pkg{$name}{$package} = 1;
            $package = "";
        } else {
-           &main::WARN("invalid line: '$_'.");
+           &::WARN("invalid line: '$_'.");
        }
     }
     close IN;
@@ -391,33 +391,33 @@ sub searchAuthor {
     my @list = keys %hash;
     if (scalar @list != 1) {
        my $prefix = "Debian Author Search of '$query' ";
-       &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
+       &::pSReply( &::formListReply(0, $prefix, @list) );
        return 1;
     }
 
-    &main::DEBUG("showing all packages by '$list[0]'...");
+    &::DEBUG("showing all packages by '$list[0]'...");
 
     my @pkg = sort keys %{$pkg{$list[0]}};
 
     # show how long it took.
-    my $delta_time = &main::timedelta($start_time);
-    &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
+    my $delta_time = &::timedelta($start_time);
+    &::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
 
     my $email  = join(', ', keys %{$maint{$list[0]}});
     my $prefix = "Debian Packages by $list[0] \002<\002$email\002>\002 ";
-    &main::performStrictReply( &main::formListReply(0, $prefix, @pkg) );
+    &::pSReply( &::formListReply(0, $prefix, @pkg) );
 }
 
 ####
 # Usage: &searchDesc($query);
 sub searchDesc {
     my ($dist, $query) = &getDistroFromStr($_[0]);
-    &main::DEBUG("searchDesc: dist => '$dist', query => '$query'.");
+    &::DEBUG("searchDesc: dist => '$dist', query => '$query'.");
     $query =~ s/^\s+|\s+$//g;
 
     # start of search.
-    my $start_time = &main::timeget();
-    &main::status("Debian: starting desc search.");
+    my $start_time = &::timeget();
+    &::status("Debian: starting desc search.");
 
     my $files;
     my ($bad,$good) = (0,0);
@@ -435,13 +435,13 @@ sub searchDesc {
        $files .= " ".$_;
     }
 
-    &main::DEBUG("good = $good, bad = $bad...");
+    &::DEBUG("good = $good, bad = $bad...");
 
     if ($good == 0 and $bad != 0) {
        my %urls = &fixDist($dist, %urlpackages);
-       &main::DEBUG("deb: download 2c.");
+       &::DEBUG("deb: download 2c.");
        if (!&DebianDownload($dist, %urls)) {
-           &main::ERROR("Debian(sD): could not download files.");
+           &::ERROR("Debian(sD): could not download files.");
            return;
        }
     }
@@ -455,13 +455,13 @@ sub searchDesc {
            my $desc = $1;
            next unless ($desc =~ /\Q$query\E/i);
            if ($package eq "") {
-               &main::WARN("sD: package == NULL?");
+               &::WARN("sD: package == NULL?");
                next;
            }
            $desc{$package} = $desc;
            $package = "";
        } else {
-           &main::WARN("invalid line: '$_'.");
+           &::WARN("invalid line: '$_'.");
        }
     }
     close IN;
@@ -469,41 +469,41 @@ sub searchDesc {
     my @list = keys %desc;
     if (!scalar @list) {
        my $prefix = "Debian Desc Search of '$query' ";
-       &main::performStrictReply( &main::formListReply(0, $prefix, ) );
+       &::pSReply( &::formListReply(0, $prefix, ) );
     } elsif (scalar @list == 1) {      # list = 1.
-       &main::DEBUG("list == 1; showing package info of '$list[0]'.");
+       &::DEBUG("list == 1; showing package info of '$list[0]'.");
        &infoPackages("info", $list[0]);
     } else {                           # list > 1.
        my $prefix = "Debian Desc Search of '$query' ";
-       &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
+       &::pSReply( &::formListReply(0, $prefix, @list) );
     }
 
     # show how long it took.
-    my $delta_time = &main::timedelta($start_time);
-    &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
+    my $delta_time = &::timedelta($start_time);
+    &::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
 }
 
 ####
 # Usage: &generateIncoming();
 sub generateIncoming {
-    my $interval = $main::param{'debianRefreshInterval'};
+    my $interval = $::param{'debianRefreshInterval'};
     my $pkgfile  = "debian/Packages-incoming";
     my $idxfile  = $pkgfile.".idx";
     my $stale   = 0;
-    $stale++ if (&main::isStale($pkgfile.".gz", $interval));
-    $stale++ if (&main::isStale($idxfile, $interval));
-    &main::DEBUG("gI: stale => '$stale'.");
+    $stale++ if (&::isStale($pkgfile.".gz", $interval));
+    $stale++ if (&::isStale($idxfile, $interval));
+    &::DEBUG("gI: stale => '$stale'.");
     return 0 unless ($stale);
 
     ### STATIC URL.
-    my %ftp = &main::ftpList("llug.sep.bnl.gov", "/pub/debian/Incoming/");
+    my %ftp = &::ftpList("llug.sep.bnl.gov", "/pub/debian/Incoming/");
 
     if (!open(PKG,">$pkgfile")) {
-       &main::ERROR("cannot write to pkg $pkgfile.");
+       &::ERROR("cannot write to pkg $pkgfile.");
        return 0;
     }
     if (!open(IDX,">$idxfile")) {
-       &main::ERROR("cannot write to idx $idxfile.");
+       &::ERROR("cannot write to idx $idxfile.");
        return 0;
     }
 
@@ -527,7 +527,7 @@ sub generateIncoming {
 
     system("gzip -9fv $pkgfile");      # lame fix.
 
-    &main::status("Debian: generateIncoming() complete.");
+    &::status("Debian: generateIncoming() complete.");
 }
 
 
@@ -540,7 +540,7 @@ sub getPackageInfo {
     my ($package, $file) = @_;
 
     if (! -f $file) {
-       &main::status("gPI: file $file does not exist?");
+       &::status("gPI: file $file does not exist?");
        return 'NULL';
     }
 
@@ -601,7 +601,7 @@ sub getPackageInfo {
                $pkg{'conflicts'} = $1;
            }
 
-###        &main::DEBUG("=> '$_'.");
+###        &::DEBUG("=> '$_'.");
        }
 
        # blank line.
@@ -622,17 +622,17 @@ sub getPackageInfo {
 # Usage: &infoPackages($query,$package);
 sub infoPackages {
     my ($query,$dist,$package) = ($_[0], &getDistroFromStr($_[1]));
-    my $interval = $main::param{'debianRefreshInterval'} || 7;
+    my $interval = $::param{'debianRefreshInterval'} || 7;
 
-    &main::status("Debian: Searching for package '$package' in '$dist'.");
+    &::status("Debian: Searching for package '$package' in '$dist'.");
 
     # download packages file.
     # hrm...
     my %urls = &fixDist($dist, %urlpackages);
     if ($dist ne "incoming") {
-       &main::DEBUG("deb: download 3.");
+       &::DEBUG("deb: download 3.");
        if (!&DebianDownload($dist, %urls)) {   # no good download.
-           &main::WARN("Debian(iP): could not download ANY files.");
+           &::WARN("Debian(iP): could not download ANY files.");
        }
     }
 
@@ -640,26 +640,26 @@ sub infoPackages {
     my $incoming = 0;
     my @files = &validPackage($package, $dist);
     if (!scalar @files) {
-       &main::status("Debian: no valid package found; checking incoming.");
+       &::status("Debian: no valid package found; checking incoming.");
        @files = &validPackage($package, "incoming");
        if (scalar @files) {
-           &main::status("Debian: cool, it exists in incoming.");
+           &::status("Debian: cool, it exists in incoming.");
            $incoming++;
        } else {
-           &main::msg($main::who, "Package '$package' does not exist.");
+           &::msg($::who, "Package '$package' does not exist.");
            return 0;
        }
     }
 
     if (scalar @files > 1) {
-       &main::WARN("same package in more than one file; random.");
-       &main::DEBUG("THIS SHOULD BE FIXED SOMEHOW!!!");
-       $files[0] = &main::getRandom(@files);
+       &::WARN("same package in more than one file; random.");
+       &::DEBUG("THIS SHOULD BE FIXED SOMEHOW!!!");
+       $files[0] = &::getRandom(@files);
     }
 
     if (! -f $files[0]) {
-       &main::WARN("files[0] ($files[0]) doesn't exist.");
-       &main::msg($main::who, "WARNING: $files[0] does not exist? FIXME");
+       &::WARN("files[0] ($files[0]) doesn't exist.");
+       &::msg($::who, "WARNING: $files[0] does not exist? FIXME");
        return 'NULL';
     }
 
@@ -673,7 +673,7 @@ sub infoPackages {
     ### TODO: use fe, dump to a hash. if only one version of the package
     ###                exists. do as normal otherwise list all versions.
     if (! -f $file) {
-       &main::ERROR("D:iP: file '$file' DOES NOT EXIST!!! should never happen.");
+       &::ERROR("D:iP: file '$file' DOES NOT EXIST!!! should never happen.");
        return 0;
     }
     my %pkg = &getPackageInfo($package, $file);
@@ -689,21 +689,21 @@ sub infoPackages {
            $pkg{'info'} .= ", Installed size: \002$pkg{'installed'}\002 kB";
 
            if ($incoming) {
-               &main::status("iP: info requested and pkg is in incoming, too.");
+               &::status("iP: info requested and pkg is in incoming, too.");
                my %incpkg = &getPackageInfo($query, "debian/Packages-incoming");
 
                if (scalar keys %incpkg) {
                   $pkg{'info'} .= ". Is in incoming ($incpkg{'file'}).";
                } else {
-                   &main::ERROR("iP: pkg $query is in incoming but we couldn't get any info?");
+                   &::ERROR("iP: pkg $query is in incoming but we couldn't get any info?");
                }
            }
        } else {
-           &main::DEBUG("running debianCheck() due to problems (".scalar(keys %pkg).").");
+           &::DEBUG("running debianCheck() due to problems (".scalar(keys %pkg).").");
            &debianCheck();
-           &main::DEBUG("end of debianCheck()");
+           &::DEBUG("end of debianCheck()");
 
-           &main::msg($main::who,"Debian: Package appears to exist but I could not retrieve info about it...");
+           &::msg($::who,"Debian: Package appears to exist but I could not retrieve info about it...");
            return;
        }
     } 
@@ -728,7 +728,7 @@ sub infoPackages {
        }
     }
 
-    &main::performStrictReply("$package: $pkg{$query}");
+    &::pSReply("$package: $pkg{$query}");
 }
 
 # Usage: &infoStats($dist);
@@ -737,15 +737,15 @@ sub infoStats {
     $dist      = &getDistro($dist);
     return unless (defined $dist);
 
-    &main::DEBUG("infoS: dist => '$dist'.");
-    my $interval = $main::param{'debianRefreshInterval'} || 7;
+    &::DEBUG("infoS: dist => '$dist'.");
+    my $interval = $::param{'debianRefreshInterval'} || 7;
 
     # download packages file if needed.
     my %urls = &fixDist($dist, %urlpackages);
-    &main::DEBUG("deb: download 4.");
+    &::DEBUG("deb: download 4.");
     if (!&DebianDownload($dist, %urls)) {
-       &main::WARN("Debian(iS): could not download ANY files.");
-       &main::msg($main::who, "Debian(iS): internal error.");
+       &::WARN("Debian(iS): could not download ANY files.");
+       &::msg($::who, "Debian(iS): internal error.");
        return;
     }
 
@@ -754,16 +754,16 @@ sub infoStats {
     my $file;
     foreach $file (keys %urlpackages) {
        $file =~ s/##DIST/$dist/g;      # won't work for incoming.
-       &main::DEBUG("file => '$file'.");
+       &::DEBUG("file => '$file'.");
        if (exists $stats{$file}{'count'}) {
-           &main::DEBUG("hrm... duplicate open with $file???");
+           &::DEBUG("hrm... duplicate open with $file???");
            next;
        }
 
        open(IN,"zcat $file 2>&1 |");
 
        if (! -e $file) {
-           &main::DEBUG("iS: $file does not exist.");
+           &::DEBUG("iS: $file does not exist.");
            next;
        }
 
@@ -786,14 +786,14 @@ sub infoStats {
                $total{'isize'}         += $1;
            }
 
-###        &main::DEBUG("=> '$_'.");
+###        &::DEBUG("=> '$_'.");
        }
        close IN;
     }
 
     ### TODO: don't count ppl with multiple email addresses.
 
-    &main::performStrictReply(
+    &::pSReply(
        "Debian Distro Stats on $dist... ".
        "\002$total{'count'}\002 packages, ".
        "\002".scalar(keys %{$total{'maint'}})."\002 maintainers, ".
@@ -804,7 +804,7 @@ sub infoStats {
 ### TODO: do individual stats? if so, we need _another_ arg.
 #    foreach $file (keys %stats) {
 #      foreach (keys %{$stats{$file}}) {
-#          &main::DEBUG("  '$file' '$_' '$stats{$file}{$_}'.");
+#          &::DEBUG("  '$file' '$_' '$stats{$file}{$_}'.");
 #      }
 #    }
 
@@ -820,9 +820,9 @@ sub infoStats {
 # Usage: &generateIndex();
 sub generateIndex {
     my (@dists)        = @_;
-    &main::status("Debian: !!! generateIndex() called !!!");
+    &::status("Debian: !!! generateIndex() called !!!");
     if (!scalar @dists or $dists[0] eq '') {
-       &main::ERROR("gI: no dists to generate index.");
+       &::ERROR("gI: no dists to generate index.");
        return 1;
     }
 
@@ -834,24 +834,24 @@ sub generateIndex {
        #       regenerate it, even if it's not stale.
        # TODO: also, regenerate the index if the packages file is newer
        #       than the index.
-       next unless (&main::isStale($idx, $main::param{'debianRefreshInterval'}));
+       next unless (&::isStale($idx, $::param{'debianRefreshInterval'}));
        if (/^incoming$/i) {
-           &main::DEBUG("gIndex: calling generateIncoming()!");
+           &::DEBUG("gIndex: calling generateIncoming()!");
            &generateIncoming();
            next;
        }
 
        if (/^woody$/i) {
-           &main::DEBUG("Copying old index of woody to -old");
+           &::DEBUG("Copying old index of woody to -old");
            system("cp $idx $idx-old");
        }
 
-       &main::DEBUG("gIndeX: calling DebianDownload($dist, ...).");
+       &::DEBUG("gIndeX: calling DebianDownload($dist, ...).");
        &DebianDownload($dist, %urlpackages);
 
-       &main::status("Debian: generating index for '$dist'.");
+       &::status("Debian: generating index for '$dist'.");
        if (!open(OUT,">$idx")) {
-           &main::ERROR("cannot write to $idx.");
+           &::ERROR("cannot write to $idx.");
            return 0;
        }
 
@@ -860,7 +860,7 @@ sub generateIndex {
            $packages =~ s/##DIST/$dist/;
 
            if (! -e $packages) {
-               &main::ERROR("gIndex: '$packages' does not exist?");
+               &::ERROR("gIndex: '$packages' does not exist?");
                next;
            }
 
@@ -885,12 +885,12 @@ sub validPackage {
     my @files;
     my $file;
 
-    &main::DEBUG("D: validPackage($package, $dist) called.");
+    &::DEBUG("D: validPackage($package, $dist) called.");
 
     my $error = 0;
     while (!open(IN, "debian/Packages-$dist.idx")) {
        if ($error) {
-           &main::ERROR("Packages-$dist.idx does not exist (#1).");
+           &::ERROR("Packages-$dist.idx does not exist (#1).");
            return;
        }
 
@@ -913,7 +913,7 @@ sub validPackage {
     }
     close IN;
 
-    &main::DEBUG("vP: scanned $count items in index.");
+    &::DEBUG("vP: scanned $count items in index.");
 
     return @files;
 }
@@ -929,22 +929,22 @@ sub searchPackage {
        $warn++;
     }
 
-    &main::status("Debian: Search package matching '$query' in '$dist'.");
+    &::status("Debian: Search package matching '$query' in '$dist'.");
     unlink $file if ( -z $file);
 
     while (!open(IN, $file)) {
        if ($dist eq "incoming") {
-           &main::DEBUG("sP: dist == incoming; calling gI().");
+           &::DEBUG("sP: dist == incoming; calling gI().");
            &generateIncoming();
        }
 
        if ($error) {
-           &main::ERROR("could not generate index!!!");
+           &::ERROR("could not generate index!!!");
            return;
        }
 
        $error++;
-       &main::DEBUG("should we be doing this?");
+       &::DEBUG("should we be doing this?");
        &generateIndex(($dist));
     }
 
@@ -954,11 +954,11 @@ sub searchPackage {
        if (/^\*(.*)$/) {
            $file = $1;
 
-           if (&main::isStale($file, $main::param{'debianRefreshInterval'})) {
-               &main::DEBUG("STALE $file! regen.");
+           if (&::isStale($file, $::param{'debianRefreshInterval'})) {
+               &::DEBUG("STALE $file! regen.");
                &generateIndex(($dist));
 ###            @files = searchPackage("$query $dist");
-               &main::DEBUG("EVIL HACK HACK HACK.");
+               &::DEBUG("EVIL HACK HACK HACK.");
                last;
            }
 
@@ -972,7 +972,7 @@ sub searchPackage {
     close IN;
 
     if (scalar @files and $warn) {
-       &main::msg($main::who, "searching for package name should be fully lowercase!");
+       &::msg($::who, "searching for package name should be fully lowercase!");
     }
 
     return @files;
@@ -982,13 +982,13 @@ sub getDistro {
     my $dist = $_[0];
 
     if (!defined $dist or $dist eq "") {
-       &main::DEBUG("gD: dist == NULL; dist = defaultdist.");
+       &::DEBUG("gD: dist == NULL; dist = defaultdist.");
        $dist = $defaultdist;
     }
 
     if ($dist =~ /^(slink|hamm|rex|bo)$/i) {
-       &main::DEBUG("Debian: deprecated version ($dist).");
-       &main::msg($main::who, "Debian: deprecated distribution version.");
+       &::DEBUG("Debian: deprecated version ($dist).");
+       &::msg($::who, "Debian: deprecated distribution version.");
        return;
     }
 
@@ -996,7 +996,7 @@ sub getDistro {
        return $dists{$dist};
     } else {
        if (!grep /^\Q$dist\E$/i, %dists) {
-           &main::msg($main::who, "invalid dist '$dist'.");
+           &::msg($::who, "invalid dist '$dist'.");
            return;
        }
 
@@ -1039,13 +1039,13 @@ sub DebianFind {
     my @results = sort &searchPackage($str);
 
     if (!scalar @results) {
-       &main::Forker("debian", sub { &searchContents($str); } );
+       &::Forker("debian", sub { &searchContents($str); } );
     } elsif (scalar @results == 1) {
-       &main::status("searchPackage returned one result; getting info of package instead!");
-       &main::Forker("debian", sub { &infoPackages("info", "$results[0] $dist"); } );
+       &::status("searchPackage returned one result; getting info of package instead!");
+       &::Forker("debian", sub { &infoPackages("info", "$results[0] $dist"); } );
     } else {
        my $prefix = "Debian Package Listing of '$str' ";
-       &main::performStrictReply( &main::formListReply(0, $prefix, @results) );
+       &::pSReply( &::formListReply(0, $prefix, @results) );
     }
 }
 
@@ -1053,13 +1053,13 @@ sub debianCheck {
     my $dir    = "debian/";
     my $error  = 0;
 
-    &main::status("debianCheck() called.");
+    &::status("debianCheck() called.");
 
     ### TODO: remove the following loop (check if dir exists before)
     while (1) {
        last if (opendir(DEBIAN, $dir));
        if ($error) {
-           &main::ERROR("dC: cannot opendir debian.");
+           &::ERROR("dC: cannot opendir debian.");
            return;
        }
        mkdir $dir, 0755;
@@ -1073,11 +1073,11 @@ sub debianCheck {
 
        my $exit = system("gzip -t '$dir/$file'");
        next unless ($exit);
-       &main::DEBUG("hmr... => ".(time() - (stat($file))[8])."'.");
+       &::DEBUG("hmr... => ".(time() - (stat($file))[8])."'.");
        next unless (time() - (stat($file))[8] > 3600);
 
-       &main::DEBUG("dC: exit => '$exit'.");
-       &main::WARN("dC: '$dir/$file' corrupted? deleting!");
+       &::DEBUG("dC: exit => '$exit'.");
+       &::WARN("dC: '$dir/$file' corrupted? deleting!");
        unlink $dir."/".$file;
        $retval++;
     }
index aabaf49c5107dd6a99a958d91655cde730de0148..52733e694fbae83c57f0b5ec84b213d829d45538 100644 (file)
@@ -10,7 +10,7 @@ use strict;
 my $bugs_url = "http://master.debian.org/~wakkerma/bugs";
 
 sub debianBugs {
-    my @results = &main::getURL($bugs_url);
+    my @results = &::getURL($bugs_url);
     my ($date, $rcbugs, $remove);
     my ($bugs_closed, $bugs_opened) = (0,0);
 
@@ -29,14 +29,14 @@ sub debianBugs {
                        "It's good to see " :
                        "Oh no, the bug count is rising -- ";
 
-       &main::performStrictReply(
+       &::performStrictReply(
                "Debian bugs statistics, last updated on $date... ".
                "There are \002$rcbugs\002 release-critical bugs;  $xtxt".
                "\002$bugs_closed\002 bugs closed, opening \002$bugs_opened\002 bugs.  ".
                "About \002$remove\002 packages will be removed."
        );
     } else {
-       &main::msg($main::who, "Couldn't retrieve data for debian bug stats.");
+       &::msg($::who, "Couldn't retrieve data for debian bug stats.");
     }
 }
 
index 1450107ec85ee30bea49af60098eb036d187e2c4..a32d93ee9a276d0b601381c2b32ce233270da86f 100644 (file)
@@ -18,7 +18,7 @@ my $proto     = getprotobyname('tcp');
 
 sub Dict {
     my ($query) = @_;
-###    return unless &main::loadPerlModule("IO::Socket");
+###    return unless &::loadPerlModule("IO::Socket");
     my $socket = new IO::Socket;
     my @results;
 
@@ -58,7 +58,7 @@ sub Dict {
        my $total = scalar @results;
 
        if (defined $num and ($num > $total or $num < 0)) {
-           &msg($main::who, "error: choice in definition is out of range.");
+           &msg($::who, "error: choice in definition is out of range.");
            return;
        }
 
@@ -69,7 +69,7 @@ sub Dict {
            } else {
                # suggested by larne and others.
                my $prefix = "Dictionary '$query' ";
-               $retval = &main::formListReply(1, $prefix, @results);
+               $retval = &::formListReply(1, $prefix, @results);
            }
        } elsif ($total == 1) {
            $retval = "Dictionary '$query' ".$results[0];
@@ -78,14 +78,14 @@ sub Dict {
        }
     }
 
-    &main::performStrictReply($retval);
+    &::performStrictReply($retval);
 }
 
 sub Dict_Wordnet {
     my ($socket, $query) = @_;
     my @results;
 
-    &main::status("Dict: asking Wordnet.");
+    &::status("Dict: asking Wordnet.");
     print $socket "DEFINE wn \"$query\"\n";
 
     my $def            = "";
@@ -104,14 +104,14 @@ sub Dict_Wordnet {
        } elsif (/^\s+(\S+ )?(\d+)?: (.*)/) {   # start of sub def.
            my $text = $3;
            $def =~ s/\s+$//;
-###        &main::DEBUG("def => '$def'.");
+###        &::DEBUG("def => '$def'.");
            push(@results, $def)                if ($def ne "");
            $def = $text;
 
            if (0) {    # old non-fLR format.
                $def = "$query $wordtype: $text" if (defined $text);
                $wordtype = substr($1,0,-1)     if (defined $1);
-###            &main::DEBUG("_ => '$_'.") if (!defined $text);
+###            &::DEBUG("_ => '$_'.") if (!defined $text);
            }
 
        } elsif (/^\s+(.*)/) {
@@ -121,7 +121,7 @@ sub Dict_Wordnet {
        }
     }
 
-    &main::status("Dict: wordnet: found ". scalar(@results) ." defs.");
+    &::status("Dict: wordnet: found ". scalar(@results) ." defs.");
 
     return if (!scalar @results);
 
@@ -132,7 +132,7 @@ sub Dict_Foldoc {
     my ($socket,$query) = @_;
     my @results;
 
-    &main::status("Dict: asking Foldoc.");
+    &::status("Dict: asking Foldoc.");
     print $socket "DEFINE foldoc \"$query\"\n";
 
     my $firsttime = 1;
@@ -165,7 +165,7 @@ sub Dict_Foldoc {
        $string .= $_." ";
     }
 
-    &main::status("Dict: foldoc: found ". scalar(@results) ." defs.");
+    &::status("Dict: foldoc: found ". scalar(@results) ." defs.");
 
     return if (!scalar @results);
     pop @results;      # last def is date of entry.
index abe0b361cf470c92d7901049f1728025482f5f10..74992ee2a6ec4c5178ad0dbca5b236e9078a8d9c 100644 (file)
@@ -16,7 +16,7 @@ sub CmdFactInfo {
 
     if ($faqtoid eq "") {
        &help("factinfo");
-       return $noreply;
+       return;
     }
 
     my $i = 0;
@@ -30,7 +30,7 @@ sub CmdFactInfo {
     # factoid does not exist.
     if (scalar @factinfo <= 1) {
        &performReply("there's no such factoid as \002$faqtoid\002");
-       return $noreply;
+       return;
     }
 
     # fix for problem observed by asuffield.
@@ -41,7 +41,7 @@ sub CmdFactInfo {
            &DEBUG("factinfo{$_} => '$factinfo{$_}'.");
        }
 ###    &delFactoid($faqtoid);
-       return $noreply;
+       return;
     }
 
     # created:
@@ -132,11 +132,11 @@ sub CmdFactInfo {
     # factoid was inserted not through the bot.
     if (!scalar @array) {
        &performReply("no extra info on \002$faqtoid\002");
-       return $noreply;
+       return;
     }
 
     &performStrictReply("$factinfo{'factoid_key'} -- ". join("; ", @array) .".");
-    return $noreply;
+    return;
 }
 
 sub CmdFactStats {
index a09e810c929017c918bb94c8ff3056ed0d6c34fc..e92381b48bcb8fd0d5a3fc4b4f13ede505cd9842 100644 (file)
@@ -20,9 +20,9 @@ my %urls = (
 # Usage: &Freshmeat($string);
 sub Freshmeat {
     my $sstr   = lc($_[0]);
-    my $refresh        = $main::param{'freshmeatRefreshInterval'} * 60 * 60;
+    my $refresh        = $::param{'freshmeatRefreshInterval'} * 60 * 60;
 
-    my $last_refresh = &main::dbGet("freshmeat", "name","_","stable");
+    my $last_refresh = &::dbGet("freshmeat", "name","_","stable");
     my $renewtable   = 0;
 
     if (defined $last_refresh) {
@@ -30,28 +30,28 @@ sub Freshmeat {
     } else {
        $renewtable++;
     }
-    $renewtable++ if (&main::countKeys("freshmeat") < 10);
+    $renewtable++ if (&::countKeys("freshmeat") < 10);
 
-    if ($renewtable and $$ == $main::bot_pid) {
-       &main::Forker("freshmeat", sub {
+    if ($renewtable and $$ == $::bot_pid) {
+       &::Forker("freshmeat", sub {
                &downloadIndex();
                &Freshmeat($sstr);
        } );
        # both parent/fork runs here, in case the following looks weird.
-       return if ($$ == $main::bot_pid);
+       return if ($$ == $::bot_pid);
     }
 
     if (!&showPackage($sstr)) {                # no exact match.
-       my $start_time = &main::timeget();
+       my $start_time = &::timeget();
        my %hash;
 
        # search by key/NAME first.
-       foreach (&main::searchTable("freshmeat", "name","name",$sstr)) {
+       foreach (&::searchTable("freshmeat", "name","name",$sstr)) {
            $hash{$_} = 1 unless exists $hash{$_};
        }
 
        # search by description line.
-       foreach (&main::searchTable("freshmeat", "name","oneliner", $sstr)) {
+       foreach (&::searchTable("freshmeat", "name","oneliner", $sstr)) {
            $hash{$_} = 1 unless exists $hash{$_};
            last if (scalar keys %hash > 15);
        }
@@ -59,27 +59,27 @@ sub Freshmeat {
        my @list = keys %hash;
        # search by value, if we have enough room to do it.
        if (scalar @list == 1) {
-           &main::status("only one match found; showing full info.");
+           &::status("only one match found; showing full info.");
            &showPackage($list[0]);
            return;
        }
 
        # show how long it took.
-       my $delta_time = &main::timedelta($start_time);
-       &main::status(sprintf("freshmeat: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
+       my $delta_time = &::timedelta($start_time);
+       &::status(sprintf("freshmeat: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
 
        for (@list) {
            tr/A-Z/a-z/;
            s/([\,\;]+)/\037$1\037/g;
        }
 
-       &main::performStrictReply( &main::formListReply(1, "Freshmeat ", @list) );
+       &::performStrictReply( &::formListReply(1, "Freshmeat ", @list) );
     }
 }
 
 sub showPackage {
     my ($pkg)  = @_;
-    my @fm     = &main::dbGet("freshmeat", "name",$pkg,"*");
+    my @fm     = &::dbGet("freshmeat", "name",$pkg,"*");
 
     if (scalar @fm) {          #1: perfect match of name.
        my $retval;
@@ -90,41 +90,60 @@ sub showPackage {
        $retval .= "Development: \002$fm[2]\002. ";
        $retval .= $fm[5] || $fm[6];             # fallback to 'download'.
        $retval .= " deb: ".$fm[8] if ($fm[8] ne ""); # 'deb'.
-       &main::performStrictReply($retval);
+       &::performStrictReply($retval);
        return 1;
     } else {
        return 0;
     }
 }
 
+sub randPackage {
+    my @fm     = &::randKey("freshmeat","*");
+
+    if (scalar @fm) {          #1: perfect match of name.
+       my $retval;
+       $retval  = "$fm[0] \002(\002$fm[11]\002)\002, ";
+       $retval .= "section $fm[3], ";
+       $retval .= "is $fm[4]. ";
+       $retval .= "Stable: \002$fm[1]\002, ";
+       $retval .= "Development: \002$fm[2]\002. ";
+       $retval .= $fm[5] || $fm[6];             # fallback to 'download'.
+       $retval .= " deb: ".$fm[8] if ($fm[8] ne ""); # 'deb'.
+
+       return $retval;
+    } else {
+       return;
+    }
+}
+
 sub downloadIndex {
-    my $start_time     = &main::timeget(); # set the start time.
-    my $idx            = "$main::param{tempDir}/fm_index.txt";
+    my $start_time     = &::timeget(); # set the start time.
+    my $idx            = "$::param{tempDir}/fm_index.txt";
 
-    &main::msg($main::who, "Updating freshmeat index... please wait");
+    &::msg($::who, "Updating freshmeat index... please wait");
 
-    if (&main::isStale($idx, 1)) {
-       &main::status("Freshmeat: fetching data.");
+    if (&::isStale($idx, 1)) {
+       &::status("Freshmeat: fetching data.");
        foreach (keys %urls) {
-           my $retval = &main::getURLAsFile($urls{$_}, $idx);
+           my $retval = &::getURLAsFile($urls{$_}, $idx);
            next if ($retval =~ /^(403|500)$/);
 
-           &main::DEBUG("FM: last! retval => '$retval'.");
+           &::DEBUG("FM: last! retval => '$retval'.");
            last;
        }
     } else {
-       &main::status("Freshmeat: local file hack.");
+       &::status("Freshmeat: local file hack.");
     }
 
     if (! -e $idx) {
-       &main::msg($main::who, "the freshmeat butcher is closed.");
+       &::msg($::who, "the freshmeat butcher is closed.");
        return;
     }
 
     if ( -s $idx < 100000) {
-       &main::DEBUG("FM: index too small?");
+       &::DEBUG("FM: index too small?");
        unlink $idx;
-       &main::msg($main::who, "internal error?");
+       &::msg($::who, "internal error?");
        return;
     }
 
@@ -137,11 +156,11 @@ sub downloadIndex {
     }
 
     # delete the table before we redo it.
-    &main::deleteTable("freshmeat");
+    &::deleteTable("freshmeat");
 
     ### lets get on with business.
     # set the last refresh time. fixes multiple spawn bug.
-    &main::dbSet("freshmeat", "name","_","stable",time());
+    &::dbSet("freshmeat", "name","_","stable",time());
 
     my $i = 0;
     while (my $line = <IN>) {
@@ -150,7 +169,7 @@ sub downloadIndex {
        last if ($i == 2);
     }
 
-    &main::dbRaw("LOCK", "LOCK TABLES freshmeat WRITE");
+    &::dbRaw("LOCK", "LOCK TABLES freshmeat WRITE");
     my @data;
     my @done;
     while (my $line = <IN>) {
@@ -161,15 +180,15 @@ sub downloadIndex {
        }
 
        if ($i % 200 == 0 and $i != 0) {
-           &main::DEBUG("FM: unlocking and locking.");
-           &main::dbRaw("UNLOCK", "UNLOCK TABLES");
+           &::DEBUG("FM: unlocking and locking.");
+           &::dbRaw("UNLOCK", "UNLOCK TABLES");
            ### another lame hack to "prevent" errors.
            select(undef, undef, undef, 0.2);
-           &main::dbRaw("LOCK", "LOCK TABLES freshmeat WRITE");
+           &::dbRaw("LOCK", "LOCK TABLES freshmeat WRITE");
        }
 
        if (grep /^\Q$data[0]\E$/, @done) {
-           &main::DEBUG("dupe? $data[0]");
+           &::DEBUG("dupe? $data[0]");
            @data = ();
            next;
        }
@@ -178,23 +197,23 @@ sub downloadIndex {
        pop @data;
        $data[1] ||= "none";
        $data[2] ||= "none";
-       &main::dbSetRow("freshmeat", @data);
+       &::dbSetRow("freshmeat", @data);
        push(@done,$data[0]);
        @data = ();
     }
     close IN;
-    &main::DEBUG("FM: data ".scalar(@data) );
-    &main::dbRaw("UNLOCK", "UNLOCK TABLES");
+    &::DEBUG("FM: data ".scalar(@data) );
+    &::dbRaw("UNLOCK", "UNLOCK TABLES");
 
-    my $delta_time = &main::timedelta($start_time);
-    &main::status(sprintf("Freshmeat: %.02f sec to complete.", $delta_time)) if ($delta_time > 0);
+    my $delta_time = &::timedelta($start_time);
+    &::status(sprintf("Freshmeat: %.02f sec to complete.", $delta_time)) if ($delta_time > 0);
 
-    my $count = &main::countKeys("freshmeat");
-    &main::status("Freshmeat: $count entries loaded.");
+    my $count = &::countKeys("freshmeat");
+    &::status("Freshmeat: $count entries loaded.");
 }
 
 sub freshmeatAnnounce {
-    my $file = "$main::param{tempDir}/fm_recent.txt";
+    my $file = "$::param{tempDir}/fm_recent.txt";
     my @old;
 
     ### if file exists, lets read it.
@@ -207,7 +226,7 @@ sub freshmeatAnnounce {
        close IN;
     }
 
-    my @array = &main::getURL("http://core.freshmeat.net/backend/recentnews.txt");
+    my @array = &::getURL("http://core.freshmeat.net/backend/recentnews.txt");
     my @now;
 
     while (@array) {
@@ -233,28 +252,18 @@ sub freshmeatAnnounce {
     }
 
     if (!scalar @new) {
-       &main::DEBUG("fA: no new items.");
+       &::DEBUG("fA: no new items.");
        return;
     }
 
-    my $chan;
-    my @chans = split(/[\s\t]+/, lc $main::param{'freshmeatAnnounce'});
-    @chans    = keys(%main::channels) unless (scalar @chans);
-
-    my $line = "Freshmeat update: ".join(" \002::\002 ", @new);
-    foreach (@chans) {
-       next unless (&main::validChan($_));
-
-       &main::status("sending freshmeat update to $_.");
-       &main::notice($_, $line);
-    }
-
     ### output new file.
     open(OUT, ">$file");
     foreach (@now) {
        print OUT "$_\n";
     }
     close OUT;
+
+    return "Freshmeat update: ".join(" \002::\002 ", @new);
 }
 
 1;
index d3bff0390400bf0e4d2f64983e9d1811d8754ce4..34cca2fabb1cc4c38a1af87f1fe1686cb54a5d6a 100644 (file)
@@ -18,7 +18,7 @@ my $proto     = getprotobyname('tcp');
 ###local $SIG{ALRM} = sub { die "alarm\n" };
 
 sub kernelGetInfo {
-###    return unless &main::loadPerlModule("IO::Socket");
+###    return unless &::loadPerlModule("IO::Socket");
 
     my $socket    = new IO::Socket;
 
@@ -57,22 +57,22 @@ sub kernelGetInfo {
 sub Kernel {
     my @now = &kernelGetInfo();
     if (!scalar @now) {
-       &main::msg($main::who, "failed.");
+       &::msg($::who, "failed.");
        return;
     }
 
     foreach (@now) {
-       &main::msg($main::who, $_);
+       &::msg($::who, $_);
     }
 }
 
 sub kernelAnnounce {
-    my $file = "$main::param{tempDir}/kernel.txt";
+    my $file = "$::param{tempDir}/kernel.txt";
     my @now  = &kernelGetInfo();
     my @old;
 
     if (!scalar @now) {
-       &main::DEBUG("kA: failure to retrieve.");
+       &::DEBUG("kA: failure to retrieve.");
        return;
     }
 
@@ -100,33 +100,23 @@ sub kernelAnnounce {
     }
 
     if (scalar @now != scalar @old) {
-       &main::DEBUG("kA: scalar mismatch; removing and exiting.");
+       &::DEBUG("kA: scalar mismatch; removing and exiting.");
        unlink $file;
        return;
     }
 
     if (!scalar @new) {
-       &main::DEBUG("kA: no new kernels.");
+       &::DEBUG("kA: no new kernels.");
        return;
     }
 
-    my $chan;
-    my @chans = split(/[\s\t]+/, lc $main::param{'kernelAnnounce'});
-    @chans    = keys(%main::channels) unless (scalar @chans);
-    foreach $chan (@chans) {
-       next unless (&main::validChan($chan));
-
-       &main::status("sending kernel update to $chan.");
-       foreach (@new) {
-            &main::notice($chan, "Kernel: $_");
-       }
-    }
-
     open(OUT, ">$file");
     foreach (@now) {
        print OUT "$_\n";
     }
     close OUT;
+
+    return @new;
 }
 
 1;
index e72fd919e33c471c86aa10696c7ef2c5a3699ec5..5f809237b55865fb0d8faff3239d290bd6195f7b 100644 (file)
@@ -12,10 +12,10 @@ use strict;
 
 sub Quote {
     my $stock = shift;
-    my @results = &main::getURL("http://quote.yahoo.com/q?s=$stock&d=v1");
+    my @results = &::getURL("http://quote.yahoo.com/q?s=$stock&d=v1");
 
     if (!scalar @results) {
-       &main::msg($main::who, "i could not get a stock quote :(");
+       &::msg($::who, "i could not get a stock quote :(");
     }
 
     my $flathtml = join(" ", @results);
@@ -35,7 +35,7 @@ sub Quote {
        $reply = "i couldn't get the quote for $stock. sorry. :(";
     }
 
-    &main::performStrictReply($reply);
+    &::performStrictReply($reply);
 }
 
 1;
index 0c0e3f32874c02d7127b72c41df07c40fedd5044..d842ae1727e5146c28f8120b931f698644bbc66d 100644 (file)
@@ -11,23 +11,23 @@ use strict;
 # Search(keys||vals, str);
 sub Search {
     my ($type, $str) = @_;
-    my $start_time = &main::timeget();
+    my $start_time = &::timeget();
     my @list;
 
     $type =~ s/s$//;   # nice work-around.
 
     if ($type eq "value") {    # search by value.
-       @list = &main::searchTable("factoids", "factoid_key", "factoid_value", $str);
+       @list = &::searchTable("factoids", "factoid_key", "factoid_value", $str);
     } else {                   # search by key.
-       @list = &main::searchTable("factoids", "factoid_key", "factoid_key", $str);
+       @list = &::searchTable("factoids", "factoid_key", "factoid_key", $str);
     }
 
-    my $delta_time = sprintf("%.02f", &main::timedelta($start_time) );
-    &main::status("search: took $delta_time sec for query.") if ($delta_time > 0);
+    my $delta_time = sprintf("%.02f", &::timedelta($start_time) );
+    &::status("search: took $delta_time sec for query.") if ($delta_time > 0);
 
     my $prefix = "Factoid search of '\002$str\002' by $type ";
 
-    &main::performStrictReply( &main::formListReply(1, $prefix, @list) );
+    &::performStrictReply( &::formListReply(1, $prefix, @list) );
 }
 
 1;
index 90fb56e473a3665d4839531845bad6ffc90b54eb..b3c406f5ada84efdd2c482ed09809a63bbbe173f 100644 (file)
@@ -33,24 +33,24 @@ sub slashdotParse {
 }
 
 sub Slashdot {
-    my @results = &main::getURL("http://www.slashdot.org/slashdot.xml");
+    my @results = &::getURL("http://www.slashdot.org/slashdot.xml");
     my $retval  = "i could not get the headlines.";
 
     if (scalar @results) {
        my $prefix      = "Slashdot Headlines ";
        my @list        = &slashdotParse(@results);
-       $retval         = &main::formListReply(0, $prefix, @list);
+       $retval         = &::formListReply(0, $prefix, @list);
     }
 
-    &main::performStrictReply($retval);
+    &::performStrictReply($retval);
 }
 
 sub slashdotAnnounce {
-    my $file = "$main::param{tempDir}/slashdot.xml";
+    my $file = "$::param{tempDir}/slashdot.xml";
 
-    my @Cxml = &main::getURL("http://www.slashdot.org/slashdot.xml");
+    my @Cxml = &::getURL("http://www.slashdot.org/slashdot.xml");
     if (!scalar @Cxml) {
-       &main::DEBUG("sdA: failure (Cxml == NULL).");
+       &::DEBUG("sdA: failure (Cxml == NULL).");
        return;
     }
 
@@ -82,12 +82,12 @@ sub slashdotAnnounce {
     }
 
     if (scalar @new == 0) {
-       &main::status("Slashdot: no new headlines.");
+       &::status("Slashdot: no new headlines.");
        return;
     }
 
     if (scalar @new == scalar @Chl) {
-       &main::DEBUG("sdA: scalar(new) == scalar(Chl). bad?");
+       &::DEBUG("sdA: scalar(new) == scalar(Chl). bad?");
     }
 
     open(OUT,">$file");
@@ -99,13 +99,13 @@ sub slashdotAnnounce {
     my $line   = "Slashdot: News for nerds, stuff that matters -- ".
                        join(" \002::\002 ", @new);
 
-    my @chans = split(/[\s\t]+/, lc $main::param{'slashdotAnnounce'});
-    @chans    = keys(%main::channels) unless (scalar @chans);
+    my @chans = split(/[\s\t]+/, lc $::param{'slashdotAnnounce'});
+    @chans    = keys(%::channels) unless (scalar @chans);
     foreach (@chans) {
-       next unless (&main::validChan($_));
+       next unless (&::validChan($_));
 
-       &main::status("sending slashdot update to $_.");
-       &main::notice($_, $line);
+       &::status("sending slashdot update to $_.");
+       &::notice($_, $line);
     }
     sleep 1;   # just in case?
 }
index 6cd8a143863ad79bbafa4c5397eec4143a8451b6..c28ad877325c7ea990b56af8820aab9b8c8bb96d 100644 (file)
@@ -176,13 +176,13 @@ sub Topic {
     ### CMD: ADD:
     if ($args eq "") {
        &help("topic add");
-       return $noreply;
+       return;
     }
 
     # heh, joeyh. 19990819. -xk
     if ($who =~ /\|\|/) {
        &msg($who, "error: you have an invalid nick, loser!");
-       return $noreply;
+       return;
     }
 
     my @prev = &topicDecipher($chan);
@@ -200,12 +200,12 @@ sub Topic {
 
     if ($topiccount == 0) {
        &msg($who, "No topic set.");
-       return $noreply;
+       return;
     }
 
     if ($args eq "") {
        &help("topic del");
-       return $noreply;
+       return;
     }
 
     $args =  ",".$args.",";
@@ -217,7 +217,7 @@ sub Topic {
 
     if ($args !~ /[\,\-\d]/) {
        &msg($who, "error: Invalid argument ($args).");
-       return $noreply;
+       return;
     }
 
     foreach (split ",", $args) {
@@ -234,7 +234,7 @@ sub Topic {
            push(@delete, $1);
        } else {
            &msg($who, "error: Invalid sub-argument ($_).");
-           return $noreply;
+           return;
        }
 
        $topic{$chan}{'What'} = "Deleted ".join("/",@delete);
@@ -242,7 +242,7 @@ sub Topic {
        foreach (@delete) {
          if ($_ > $topiccount || $_ < 1) {
            &msg($who, "error: argument out of range. (max: $topiccount)");
-           return $noreply;
+           return;
          }
          # skip if already deleted.
          # only checked if x-y range is given.
@@ -268,7 +268,7 @@ sub Topic {
     my @topics = &topicDecipher($chan);
     if (!scalar @topics) {
        &msg($who, "No topics for \002$chan\002.");
-       return $noreply;
+       return;
     }
 
     &msg($who, "Topics for \002$chan\002:");
@@ -289,7 +289,7 @@ sub Topic {
 
     if ($args eq "") {
        &help("topic mod");
-       return $noreply;
+       return;
     }
 
     # a warning message instead of halting. we kind of trust the user now.
@@ -301,24 +301,25 @@ sub Topic {
 
     # SAR patch. mu++
     if ($args =~ m|^\s*s([/,#])(.+?)\1(.*?)\1([a-z]*);?\s*$|) {
-       my ($delim, $op, $np, $flags) = ($1,quotemeta $2,$3,$4);
+       my ($delim, $op, $np, $flags) = ($1,$2,$3,$4);
 
        if ($flags !~ /^(g)?$/) {
          &msg($who, "error: Invalid flags to regex.");
-         return $noreply;
+         return;
        }
 
        my $topic = $topic{$chan}{'Current'};
 
-       if (($flags eq "g" and $topic =~ s/$op/$np/g) ||
-           ($flags eq ""  and $topic =~ s/$op/$np/)) {
+       ### TODO: use m### to make code safe!
+       if (($flags eq "g" and $topic =~ s/\Q$op\E/$np/g) ||
+           ($flags eq ""  and $topic =~ s/\Q$op\E/$np/)) {
 
          $_ = "Modifying topic with sar s/$op/$np/.";
          &topicNew($chan, $topic, $_, $topicUpdate);
        } else {
          &msg($who, "warning: regex not found in topic.");
        }
-       return $noreply;
+       return;
     }
 
     &msg($who, "error: Invalid regex. Try s/1/2/, s#3#4#...");
@@ -328,7 +329,7 @@ sub Topic {
 
     if ($args eq "") {
        &help("topic mv");
-       return $noreply;
+       return;
     }
 
     if ($args =~ /^(first|last|\d+)\s+(before|after|swap)\s+(first|last|\d+)$/i) {
@@ -339,7 +340,7 @@ sub Topic {
 
        if ($topiccount == 1) {
          &msg($who, "error: impossible to move the only subtopic, dumbass.");
-         return $noreply;
+         return;
        }
 
        # Is there an easier way to do this?
@@ -350,12 +351,12 @@ sub Topic {
 
        if ($from > $topiccount || $to > $topiccount || $from < 1 || $to < 1) {
          &msg($who, "error: <from> or <to> is out of range.");
-         return $noreply;
+         return;
        }
 
        if ($from == $to) {
          &msg($who, "error: <from> and <to> are the same.");
-         return $noreply;
+         return;
        }
 
        $topic{$chan}{'What'} = "Move $from to $to";
@@ -367,7 +368,7 @@ sub Topic {
 
          $_ = "Swapped #\002$from\002 with #\002$to\002.";
          &topicNew($chan, &topicCipher(@subtopics), $_, $topicUpdate);
-         return $noreply;
+         return;
        }
 
        # action != swap:
@@ -396,7 +397,7 @@ sub Topic {
        $_ = "Moved #\002$from\002 $action #\002$to\002.";
        &topicNew($chan, &topicCipher(@subtopics), $_, $topicUpdate);
 
-       return $noreply;
+       return;
     }
 
     &msg($who, "Invalid arguments.");
@@ -419,7 +420,7 @@ sub Topic {
     ### CMD: HISTORY:
     if (!scalar @{$topic{$chan}{'History'}}) {
        &msg($who, "Sorry, no topics in history list.");
-       return $noreply;
+       return;
     }
 
     &msg($who, "History of topics on \002$chan\002:");
@@ -436,7 +437,7 @@ sub Topic {
     ### CMD: RESTORE:
     if ($args eq "") {
        &help("topic restore");
-       return $noreply;
+       return;
     }
 
     $topic{$chan}{'What'} = "Restore topic $args";
@@ -445,7 +446,7 @@ sub Topic {
     if ($args =~ /^last$/i) {
        if (${$topic{$chan}{'History'}}[0] eq $topic{$chan}{'Current'}) {
            &msg($who,"error: cannot restore last topic because it's mine.");
-           return $noreply;
+           return;
        }
        $args = 1;
     }
@@ -453,13 +454,13 @@ sub Topic {
     if ($args =~ /\d+/) {
        if ($args > $#{$topic{$chan}{'History'}} || $args < 1) {
            &msg($who, "error: argument is out of range.");
-           return $noreply;
+           return;
        }
 
        $_ = "Changing topic according to request.";
        &topicNew($chan, ${$topic{$chan}{'History'}}[$args-1], $_, $topicUpdate);
 
-       return $noreply;
+       return;
     }
 
     &msg($who, "error: argument is not positive integer.");
@@ -488,13 +489,13 @@ sub Topic {
     if ($cmd ne "" and $cmd !~ /^help/i) {
        &msg($who, "Invalid command [$cmd].");
        &msg($who, "Try 'help topic'.");
-       return $noreply;
+       return;
     }
 
     &help("topic");
   }
 
-  return $noreply;
+  return;
 }
 
 1;
index cabfd379421efe1b5ecf45c2e148e49d720b7c67..e51e61252a085969c87776fa29c619ad5aff3608 100644 (file)
@@ -49,10 +49,10 @@ BEGIN {
 ################################################################
 
 { my $defs_read = 0;
-  $defs_read += read_defs("$main::bot_misc_dir/unittab");
+  $defs_read += read_defs("$::bot_misc_dir/unittab");
 
   unless ($defs_read) {
-    &main::ERROR("Could not read any of the initialization files UNITTAB");
+    &::ERROR("Could not read any of the initialization files UNITTAB");
     return;
   }
 }
@@ -77,22 +77,22 @@ sub convertUnits {
   trim($from);
   if ($from =~ s/^\s*\#\s*//) {
     if (definition_line($from)) {
-      &main::DEBUG("Defined.");
+      &::DEBUG("Defined.");
     } else {
-      &main::DEBUG("Error: $PARSE_ERROR.");
+      &::DEBUG("Error: $PARSE_ERROR.");
     }
-    &main::DEBUG("FAILURE 1.");
+    &::DEBUG("FAILURE 1.");
     return;
   }
   unless ($from =~ /\S/) {
-    &main::DEBUG("FAILURE 2");
+    &::DEBUG("FAILURE 2");
     return;
   }
 
   my $hu = parse_unit($from);
   if (is_Zero($hu)) {
-    &main::DEBUG($PARSE_ERROR);
-    &main::msg($main::who, $PARSE_ERROR);
+    &::DEBUG($PARSE_ERROR);
+    &::msg($::who, $PARSE_ERROR);
     return;
   }
 
@@ -102,23 +102,23 @@ sub convertUnits {
   redo unless $to =~ /\S/;
   $wu = parse_unit($to);
   if (is_Zero($wu)) {
-    &main::DEBUG($PARSE_ERROR);
+    &::DEBUG($PARSE_ERROR);
   }
 
   my $quot = unit_divide($hu, $wu);
   if (is_dimensionless($quot)) {
     my $q = $quot->{_};
     if ($q == 0) {
-       &main::performStrictReply("$to is an invalid unit?");
+       &::performStrictReply("$to is an invalid unit?");
        return;
     }
     # yet another powers hack.
     $from =~ s/(\D+)(\d)/$1\^$2/g;
     $to   =~ s/(\D+)(\d)/$1\^$2/g;
 
-    &main::performStrictReply(sprintf("$from is approximately \002%.6g\002 $to", $q));
+    &::performStrictReply(sprintf("$from is approximately \002%.6g\002 $to", $q));
   } else {
-    &main::performStrictReply("$from cannot be correctly converted to $to.");
+    &::performStrictReply("$from cannot be correctly converted to $to.");
 
 #    print 
 #      "conformability (Not the same dimension)\n",
@@ -214,7 +214,7 @@ sub unit_multiply {
 sub unit_divide {
   my ($a, $b) = @_;
   if ($b->{_} == 0) {
-    &main::DEBUG("Division by zero error");
+    &::DEBUG("Division by zero error");
     return;
   }
   my $r = {%$a};
@@ -491,13 +491,13 @@ sub parse_unit {
       # Now look for `goto' actions
       my $goto = $actions[$STATE]{$result_type};
       unless ($goto && $goto->[0] eq 'goto') {
-       &main::ERROR("No post-reduction goto in state $STATE for $result_type.");
+       &::ERROR("No post-reduction goto in state $STATE for $result_type.");
        return;
       }
       print STDERR "goto $goto->[1]\n" if $DEBUG_p;
       $STATE = $goto->[1];
     } else {
-      &main::ERROR("Bad primary $primary");
+      &::ERROR("Bad primary $primary");
       return;
     }
   }
index c1897f7fd328be6a96d604aeb76178d32a7e2790..5f8b55f6c98ba1d3eebc6cdf90eeda13db0d450d 100644 (file)
@@ -49,6 +49,7 @@ sub uptimeGetInfo {
 
   # fixed up bad implementation :)
   # should be no problems, even if uptime or pid is duplicated.
+  ## WARN: run away forks may get through here, have to fix.
   foreach $uptime (sort {$b <=> $a} keys %uptime) {
     foreach $pid (keys %{$uptime{$uptime}}) {
        next if (exists $done{$pid});
@@ -68,7 +69,7 @@ sub uptimeWriteFile {
   my $file = $file{utm};
 
   if ($$ != $bot_pid) {
-    &WARN("uptime: forked process doing weird things! FIXME");
+    &FIXME("uptime: forked process doing weird things!");
     exit 0;
   }
 
index 31cccd7f40c3db6fa5efc30f5afd6adaf70d099d..8f216b808aee93796022f0aac91b8b7c25eb5da3 100644 (file)
@@ -16,17 +16,17 @@ sub W3Search {
     my ($where, $what, $type) = @_;
     my $retval = "$where can't find \002$what\002";
 
-    return unless &main::loadPerlModule("WWW::Search");
+    return unless &::loadPerlModule("WWW::Search");
 
     if (defined $type) {
-       &main::DEBUG("W3S: type => $type");
+       &::DEBUG("W3S: type => $type");
     }
 
     my @matches = grep { lc($_) eq lc($where) ? $_ : undef } @W3Search_engines;
     if (@matches) {
        $where = shift @matches;
     } else {
-       &main::msg($main::who, "i don't know how to check '$where'");
+       &::msg($::who, "i don't know how to check '$where'");
     }
 
     my $Search = new WWW::Search($where);
@@ -37,7 +37,7 @@ sub W3Search {
 #              search_parse_debug => 2,
 #      }
     );
-    $Search->http_proxy($main::param{'httpProxy'}) if (&main::IsParam("httpProxy"));
+    $Search->http_proxy($::param{'httpProxy'}) if (&::IsParam("httpProxy"));
     my $max = $Search->maximum_to_retrieve(10);        # DOES NOT WORK.
 
     my (%results, $count, $r);
@@ -51,7 +51,7 @@ sub W3Search {
            next if (exists $results{$hostname});
            $results{$hostname} = $url;
        } else {
-           &main::DEBUG("W3S: url isn't good? ($url).");
+           &::DEBUG("W3S: url isn't good? ($url).");
        }
 
        last if ++$count >= $maxshow;
@@ -62,7 +62,7 @@ sub W3Search {
                join(' or ', map { $results{$_} } sort keys %results);
     }
 
-    &main::performStrictReply($retval);
+    &::performStrictReply($retval);
 }
 
 1;
index 4a7a3637f167b23a55416d7512d27db3be825286..53aaf267f9a3ca4db835149b8b6de078325e133c 100644 (file)
@@ -12,7 +12,7 @@ use strict;
 my $select = IO::Select->new;
 
 sub Wingates {
-    my $file = "$main::blootbot_base_dir/$main::param{'ircUser'}.wingate";
+    my $file = "$::blootbot_base_dir/$::param{'ircUser'}.wingate";
     my @hosts;
 
     open(IN, $file);
@@ -26,7 +26,7 @@ sub Wingates {
     foreach (@_) {
        next if (grep /^$_$/, @hosts);
 
-       &main::DEBUG("W: _ => '$_'.");
+       &::DEBUG("W: _ => '$_'.");
        &Wingate($_);
     }
 }
@@ -42,7 +42,7 @@ sub Wingate {
     );
 
     if (!defined $sock) {
-       &main::status("Wingate: connection refused to $host");
+       &::status("Wingate: connection refused to $host");
        return;
     }
 
@@ -55,7 +55,7 @@ sub Wingate {
        my $buf;
        my $len = 0;
        if (!defined($len = sysread($luser, $buf, 512))) {
-           &main::status("Wingate: connection lost to $luser/$host.");
+           &::status("Wingate: connection lost to $luser/$host.");
            $select->remove($luser);
            close($luser);
            next;
@@ -70,20 +70,20 @@ sub Wingate {
        $wingate++ if ($buf =~ /^Too many connected users - try again later$/);
 
        if ($wingate) {
-           &main::status("Wingate: RUNNING ON $host BY $main::who.");
+           &::status("Wingate: RUNNING ON $host BY $::who.");
 
-           if (&main::IsParam("wingateBan")) {
-               &main::ban("*!*\@$host", "");
+           if (&::IsParam("wingateBan")) {
+               &::ban("*!*\@$host", "");
            }
 
-           if (&main::IsParam("wingateKick")) {
-               &main::kick($main::who, "", $main::param{'wingateKick'});
+           if (&::IsParam("wingateKick")) {
+               &::kick($::who, "", $::param{'wingateKick'});
            }
 
-           push(@main::wingateBad, "$host\*");
-           &main::wingateWriteFile();
+           push(@::wingateBad, "$host\*");
+           &::wingateWriteFile();
        } else {
-###        &main::DEBUG("no wingate.");
+###        &::DEBUG("no wingate.");
        }
 
        ### TODO: close telnet connection correctly!
index 01d097d08c8e7d4868274966bbec7af464647d52..a75a19a2a1b0970c82c05a6ccef99ca91f7d28be 100644 (file)
@@ -50,10 +50,10 @@ sub babelfish {
     my $toenglish = "${lang}_en";
 
     if ($direction eq 'to') {
-       &main::performStrictReply( translate($phrase, $tolang, $req, $ua) );
+       &::performStrictReply( translate($phrase, $tolang, $req, $ua) );
        return;
     } elsif ($direction eq 'from') {
-       &main::performStrictReply( translate($phrase, $toenglish, $req, $ua) );
+       &::performStrictReply( translate($phrase, $toenglish, $req, $ua) );
        return;
     }
 
@@ -68,7 +68,7 @@ sub babelfish {
        $last_english = $phrase = translate($phrase, $toenglish, $req, $ua);
     }
 
-    &main::performStrictReply($last_english);
+    &::performStrictReply($last_english);
 }
 
 sub translate {
index 1dbb89a6daca68aa0ffd62160a78a585fc53dd35..662542d57de6c63fd75bbc1dcbe5cbc926e7e0e9 100644 (file)
@@ -15,9 +15,9 @@ sub Insult {
     $t->Net::Telnet::open(Host => "insulthost.colorado.edu", Port => "1695");
     my $line = $t->Net::Telnet::getline(Timeout => 4);
 
-    $line = "No luck, $main::who" unless (defined $line);
+    $line = "No luck, $::who" unless (defined $line);
 
-    if ($insultwho ne $main::who) { 
+    if ($insultwho ne $::who) { 
        $line =~ s/^\s*You are/$insultwho is/i;
     }
 
index 6a0e40024bfb00f707aeaaae02752df0a51856a3..567c8706ff929e40d970d158a957c8d038538d3f 100644 (file)
@@ -15,7 +15,7 @@ my $score     = 0;
 my $verbose    = 0;
 
 sub nickometer ($) {
-  return unless &loadPerlModule("Getopt::Std");
+#  return unless &loadPerlModule("Getopt::Std");
   return unless &loadPerlModule("Math::Trig");
 
   local $_ = shift;
index 1d444718ffe890ef8f1d5b38a4cc7a14d2bd3162..3fd7aa9c34791278efe511da3f1f479860ebd06f 100644 (file)
@@ -99,8 +99,12 @@ sub process {
 
     # User Processing, for all users.
     if ($addressed) {
-       return '$noreply from pCH'   if &parseCmdHook("main",$message);
-       return '$noreply from userC' if &userCommands() eq $noreply;
+       my $retval;
+       return 'returned from pCH'   if &parseCmdHook("main",$message);
+
+       $retval = &userCommands();
+       return unless (defined $retval);
+       return if ($retval eq $noreply);
     }
 
     ###
@@ -215,8 +219,8 @@ sub process {
        }
 
        my $er = &Modules();
-       if ($er =~ /\S/) {
-           &performStrictReply($er) if ($er ne $noreply);
+       if (!defined $er or $er ne $noreply) {
+           &performStrictReply($er);
            return 'SOMETHING 1';
        }
 
@@ -420,7 +424,7 @@ sub FactoidStuff {
                my $author = &getFactInfo($from, "created_by");
                if (&IsFlag("m") and $author =~ /^\Q$who\E\!/i) {
                    &msg($who, "It's not yours to modify.");
-                   return $noreply;
+                   return;
                }
 
                if ($_ = &getFactoid($to)) {
@@ -511,13 +515,14 @@ sub FactoidStuff {
     }
 
     my $result = &doQuestion($message);
-
-    return 'result is $noreply' if ($result eq $noreply);
+    if (!defined $result or $result eq $noreply) {
+       return 'result from doQ undef.';
+    }
 
     if (defined $result and $result ne "") {           # question.
        &status("question: <$who> $message");
        $count{'Question'}++;
-    } elsif (&IsParam("perlMath") and $addressed) {    # perl math.
+    } elsif (&IsChanConf("perlMath") > 0 and $addressed) { # perl math.
        &loadMyModule("perlMath");
        my $newresult = &perlMath();
 
@@ -537,7 +542,7 @@ sub FactoidStuff {
        }
 
        # do the statement.
-       if ($_ = &doStatement($message)) {
+       if (defined &doStatement($message)) {
            return;
        }
 
index 5fca753d55cd01fef11fb5118ba5fea36bfea503..0f6f338ad9a25439dd9fb0ae2be046bb77d330b9 100644 (file)
@@ -82,6 +82,8 @@ sub addForked {
        return 0;
     }
 
+    &DEBUG("forked => ".scalar(keys %forked) );
+
     foreach (keys %forked) {
        my $time = time() - $forked{$_}{Time};
        next unless ($time > $forker_timeout);
@@ -92,7 +94,7 @@ sub addForked {
     }
 
     my $count = 0;
-    while (scalar keys %forked > 2) {  # 2 or more == fail.
+    while (scalar keys %forked > 1) {  # 2 or more == fail.
        sleep 1;
 
        if ($count > 3) {       # 3 seconds.
index 545abf1cb3bd49370d5ea0e8cc59f167363c0516..4a9d2687dbda31fcbca4812e0acf4f8c0966edc0 100644 (file)
@@ -25,10 +25,7 @@ sub openDB {
 }
 
 sub closeDB {
-    if (!$dbh) {
-       &WARN("closeDB: connection already closed?");
-       return 0;
-    }
+    return 0 unless ($dbh);
 
     &status("Closed MySQL connection to $param{'SQLHost'}.");
     $dbh->disconnect();
@@ -362,7 +359,7 @@ sub delFactoid {
     my ($faqtoid) = @_;
 
     &dbDel("factoids", "factoid_key",$faqtoid);
-    &status("DELETED $faqtoid");
+    &status("DELETED '$faqtoid'");
 
     return 1;
 }