]> git.donarmstrong.com Git - infobot.git/commitdiff
cvs commit borked, continuing
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 31 Jul 2000 14:37:02 +0000 (14:37 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 31 Jul 2000 14:37:02 +0000 (14:37 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@22 c11ca15a-4712-0410-83d8-924469b57eb5

src/IRC/Irc.pl
src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl
src/Modules/Countdown.pl
src/Modules/Factoids.pl
src/Modules/Freshmeat.pl
src/Modules/Kernel.pl
src/Modules/Units.pl
src/Modules/Uptime.pl
src/Modules/Wingate.pl
src/Modules/babel.pl

index 1abd87ee5c96a3db22abe55e05dff40ad25b9d4c..f3775984bca4e72da832a62fdd1835000ffefd7e 100644 (file)
@@ -160,7 +160,7 @@ sub rawout {
 
 sub say {
     my ($msg) = @_;
-    if (!defined $msg or $msg eq "NOREPLY") {
+    if (!defined $msg or $msg eq $noreply) {
        $msg ||= "NULL";
        &DEBUG("say: msg == $msg.");
        return;
@@ -187,7 +187,7 @@ sub msg {
        return;
     }
 
-    if (!defined $msg or $msg eq "NOREPLY") {
+    if (!defined $msg or $msg eq $noreply) {
        $msg ||= "NULL";
        &DEBUG("msg: msg == $msg.");
        return;
index 8fc4c0778b9a822a7ea9203124f5a8b1c3f9ec62..889734b4f81b135259fdcacf758232b14429ca3f 100644 (file)
@@ -96,7 +96,7 @@ sub on_chat {
     if ($message =~ s/^\.//) { # dcc chat commands.
        ### TODO: make use of &Forker(); here?
        &loadMyModule($myModules{'ircdcc'});
-       return 'NOREPLY from userD' if (&userDCC() eq 'NOREPLY');
+       return '$noreply from userD' if (&userDCC() eq $noreply);
        $conn->privmsg($dcc{'CHAT'}{$who}, "Invalid command.");
 
     } else {                   # dcc chat arena.
@@ -112,7 +112,7 @@ sub on_endofmotd {
     my ($self) = @_;
 
     if (&IsParam("wingate")) {
-       my $file = "$infobot_base_dir/$param{'ircUser'}.wingate";
+       my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
        open(IN, $file);
        while (<IN>) {
            chop;
@@ -692,7 +692,7 @@ sub on_version {
     my $nick = $event->nick;
 
     &status(">>> ${b_green}CTCP VERSION$ob request from $b_cyan$nick$ob");
-    $self->ctcp_reply($nick, "VERSION $infobot_version");
+    $self->ctcp_reply($nick, "VERSION $bot_version");
 }
 
 sub on_who {
index d92d9a53f594526c5438970f8c73277974c19dbc..efb28afd934f9873de14b194c60be78d43b2059a 100644 (file)
@@ -41,7 +41,7 @@ sub ScheduleThis {
 }
 
 sub randomQuote {
-    my $line = &getRandomLineFromFile($infobot_misc_dir. "/infobot.randtext");
+    my $line = &getRandomLineFromFile($bot_misc_dir. "/blootbot.randtext");
     if (!defined $line) {
        &ERROR("random Quote: weird error?");
        return;
@@ -106,6 +106,7 @@ sub randomFactoid {
 }
 
 sub logCycle {
+    # check if current size is too large.
     if ( -s $file{log} > $param{'maxLogSize'}) {
        my $date = sprintf("%04d%02d%02d", (localtime)[5,4,3]);
        $file{log} = $param{'logfile'} ."-". $date;
@@ -129,6 +130,45 @@ sub logCycle {
        &status("cycling log file.");
     }
 
+    # check if all the logs exceed size.
+    my $logdir = "$bot_base_dir/log/";
+    if (opendir(LOGS, $logdir)) {
+       my $tsize = 0;
+       my (%age, %size);
+
+       while (defined($_ = readdir LOGS)) {
+           my $logfile = "$logdir/$_";
+
+           next unless ( -f $logfile);
+           my $size = -s $logfile;
+           my $age = (stat $logfile)[9]; ### or 8 ?
+
+           $age{$age}          = $logfile;
+           $size{$logfile}     = $size;
+
+           $tsize              += $size;
+       }
+       closedir LOGS;
+
+       my $delete = 0;
+       while ($tsize > $param{'maxLogSize'}) {
+           &status("LOG: current size > max ($tsize > $param{'maxLogSize'})");
+           my $oldest = (sort {$a <=> $b} keys %age)[0];
+           &status("LOG: unlinking $age{$oldest}.");
+           ### NOT YET.
+           # unlink $age{$oldest};
+           $tsize -= $oldest;
+           $delete++;
+       }
+
+       ### TODO: add how many b,kb,mb removed?
+       if ($delete) {
+           &status("LOG: removed $delete logs.");
+       }
+    } else {
+       &WARN("could not open dir $logdir");
+    }
+
     &ScheduleThis(60, "logCycle") if (@_);
 }
 
@@ -462,8 +502,8 @@ sub wingateCheck {
 sub wingateWriteFile {
     return unless (scalar @wingateCache);
 
-    my $file = "$infobot_base_dir/$param{'ircUser'}.wingate";
-    if ($infobot_pid != $$) {
+    my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
+    if ($bot_pid != $$) {
        &DEBUG("wingateWriteFile: Reorganising!");
 
        open(IN, $file);
index 51cae88efbef3625cfca4dc2f1f7dfd51eec8bdb..0fdbdd3c1c4849b5f63f1c530bddef1af951c4a4 100644 (file)
@@ -11,7 +11,7 @@ use strict;
 
 sub Countdown {
     my ($query) = @_;
-    my $file = "$infobot_base_dir/$param{'ircUser'}.countdown";
+    my $file = "$bot_base_dir/$param{'ircUser'}.countdown";
     my (%date, %desc);
     my $reply;
 
index 4449ef66ba1f6376cdb820eef27e6926a72bea47..525d9002288b9c5af640c63b3fc47bb71bc8369f 100644 (file)
@@ -16,7 +16,7 @@ sub CmdFactInfo {
 
     if ($faqtoid eq "") {
        &help("factinfo");
-       return 'NOREPLY';
+       return $noreply;
     }
 
     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 $noreply;
     }
 
     # created:
@@ -119,11 +119,11 @@ sub CmdFactInfo {
     # factoid was inserted not through the bot.
     if (!scalar @array) {
        &performReply("no extra info on \002$faqtoid\002");
-       return 'NOREPLY';
+       return $noreply;
     }
 
     &performStrictReply("$factinfo{'factoid_key'} -- ". join("; ", @array) .".");
-    return 'NOREPLY';
+    return $noreply;
 }
 
 sub CmdFactStats {
index 2e32602982460a2225428cec1c853c10e8549b62..be96f4950796e7288eb848f39912af59229c6e43 100644 (file)
@@ -32,12 +32,12 @@ sub Freshmeat {
     }
     $renewtable++ if (&main::countKeys("freshmeat") < 10);
 
-    if ($renewtable and $$ == $main::infobot_pid) {
+    if ($renewtable and $$ == $main::blootbot_pid) {
        &main::Forker("freshmeat", sub {
                &downloadIndex();
                &Freshmeat($sstr);
        } );
-       return if ($$ == $main::infobot_pid);
+       return if ($$ == $main::bot_pid);
     }
 
     if (!&showPackage($sstr)) {                # no exact match.
@@ -97,7 +97,7 @@ sub showPackage {
 
 sub downloadIndex {
     my $start_time     = &main::gettimeofday(); # set the start time.
-    my $idx            = "$main::infobot_base_dir/Temp/fm_index.txt";
+    my $idx            = "$main::bot_base_dir/Temp/fm_index.txt";
 
     &main::msg($main::who, "Updating freshmeat index... please wait");
 
@@ -179,7 +179,7 @@ sub downloadIndex {
 }
 
 sub freshmeatAnnounce {
-    my $file = "$main::infobot_base_dir/Temp/fm_recent.txt";
+    my $file = "$main::bot_base_dir/Temp/fm_recent.txt";
     my @old;
 
     if ( -f $file) {
index c9749f9630647d157ca6c8df337287e947362893..9d74a65b496507592bf0df99f8b41de01e731cfe 100644 (file)
@@ -67,7 +67,7 @@ sub Kernel {
 }
 
 sub kernelAnnounce {
-    my $file = "$main::infobot_base_dir/Temp/kernel.txt";
+    my $file = "$main::blootbot_base_dir/Temp/kernel.txt";
     my @now  = &kernelGetInfo();
     my @old;
 
index dd8a8ed0628727f0f78246ed35c0646292b8d1f4..cabfd379421efe1b5ecf45c2e148e49d720b7c67 100644 (file)
@@ -49,7 +49,7 @@ BEGIN {
 ################################################################
 
 { my $defs_read = 0;
-  $defs_read += read_defs("$main::infobot_misc_dir/unittab");
+  $defs_read += read_defs("$main::bot_misc_dir/unittab");
 
   unless ($defs_read) {
     &main::ERROR("Could not read any of the initialization files UNITTAB");
index 1ef9d22cffc6a7c3385efa9c02f3061c8391ee0c..40bdb4009e50e067bbd93bdc6d75e6308146ce6a 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Uptime.pl: Uptime daemon for infobot.
+# Uptime.pl: Uptime daemon.
 #    Author: dms
 #   Version: v0.3 (19991008)
 #   Created: 19990925.
@@ -17,9 +17,9 @@ sub uptimeStr {
   my $uptimenow = &uptimeNow();
 
   if (defined $_[0]) {
-    return "$uptimenow.$$ running $infobot_version, ended ". localtime(time());
+    return "$uptimenow.$$ running $bot_version, ended ". localtime(time());
   } else {
-    return "$uptimenow running $infobot_version";
+    return "$uptimenow running $bot_version";
   }
 }
 
index 0bca79974617df614855240d8d78727bc2d5ba1b..4a7a3637f167b23a55416d7512d27db3be825286 100644 (file)
@@ -12,7 +12,7 @@ use strict;
 my $select = IO::Select->new;
 
 sub Wingates {
-    my $file = "$main::infobot_base_dir/$main::param{'ircUser'}.wingate";
+    my $file = "$main::blootbot_base_dir/$main::param{'ircUser'}.wingate";
     my @hosts;
 
     open(IN, $file);
index ccaefc184285e481d6dec3b082a300ca1ee06a25..01d097d08c8e7d4868274966bbec7af464647d52 100644 (file)
@@ -1,5 +1,4 @@
 # This program is copyright Jonathan Feinberg 1999.
-
 # This program is distributed under the same terms as infobot.
 
 # Jonathan Feinberg