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;
return;
}
- if (!defined $msg or $msg eq "NOREPLY") {
+ if (!defined $msg or $msg eq $noreply) {
$msg ||= "NULL";
&DEBUG("msg: msg == $msg.");
return;
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.
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;
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 {
}
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;
}
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;
&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 (@_);
}
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);
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;
if ($faqtoid eq "") {
&help("factinfo");
- return 'NOREPLY';
+ return $noreply;
}
my $i = 0;
# factoid does not exist.
if (scalar @factinfo <= 1) {
&performReply("there's no such factoid as \002$faqtoid\002");
- return 'NOREPLY';
+ return $noreply;
}
# created:
# 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 {
}
$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.
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");
}
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) {
}
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;
################################################################
{ 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");
#
-# Uptime.pl: Uptime daemon for infobot.
+# Uptime.pl: Uptime daemon.
# Author: dms
# Version: v0.3 (19991008)
# Created: 19990925.
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";
}
}
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);
# This program is copyright Jonathan Feinberg 1999.
-
# This program is distributed under the same terms as infobot.
# Jonathan Feinberg