#
# core.pl: Important functions stuff...
-# Author: xk <xk@leguin.openprojects.net>
+# Author: dms
# Version: v0.4 (20000718)
# Created: 20000322
#
# dynamic scalar. MUST BE REDUCED IN SIZE!!!
### TODO: reorder.
use vars qw(
- $answer $correction_plausible $loggingstatus $talkchannel
- $statcount $memusage $user $memusageOld $infobot_version $dbh
- $shm $host $msg $infobot_misc_dir $infobot_pid $infobot_base_dir
- $infobot_src_dir $conn $irc $learnok $nick $ident $no_syscall
+ $answer $correction_plausible $talkchannel
+ $statcount $memusage $user $memusageOld $bot_version $dbh
+ $shm $host $msg $bot_misc_dir $bot_pid $bot_base_dir $noreply
+ $bot_src_dir $conn $irc $learnok $nick $ident $no_syscall
$force_public_reply $addrchar $userHandle $addressedother
$floodwho $chan $msgtime $server $firsttime $wingaterun
);
$SIG{'TERM'} = 'doExit'; # 15.
$SIG{'__WARN__'} = 'doWarn';
+# initialize variables.
$last{buflen} = 0;
$last{say} = "";
$last{msg} = "";
$msgtime = time();
$wingaterun = time();
$firsttime = 1;
-$infobot_version = "blootbot 1.0.0 (20000725) -- $^O";
+
+### CHANGE TO STATIC.
+$bot_version = "blootbot 1.0.0 (20000725) -- $^O";
+$noreply = "NOREPLY";
##########
### misc commands.
sub doExit {
my ($sig) = @_;
- if (!defined $infobot_pid) { # independent.
+ if (!defined $bot_pid) { # independent.
exit 0;
- } elsif ($infobot_pid == $$) { # parent.
+ } elsif ($bot_pid == $$) { # parent.
&status("parent caught SIG$sig (pid $$).") if (defined $sig);
my $type;
&closeSHM($shm);
&dumpallvars() if (&IsParam("dumpvarsAtExit"));
&closeLog();
+ &closeSQLDebug() if (&IsParam("SQLDebug"));
} else { # child.
&status("child caught SIG$sig (pid $$).");
}
if (defined $memusageOld and &IsParam("DEBUG")) {
# it's always going to be increase.
my $delta = $memusage - $memusageOld;
- if ($delta > 500) {
- &status("MEM:$prefix increased by $delta kB. (total: $memusage kB)");
+ my $str;
+ if ($delta == 0) {
+ return;
+ } elsif ($delta > 500) {
+ $str = "MEM:$prefix increased by $delta kB. (total: $memusage kB)";
} elsif ($delta > 0) {
- &status("MEM:$prefix increased by $delta kB.");
- } elsif ($delta < 0) {
+ $str = "MEM:$prefix increased by $delta kB";
+ } else { # delta < 0.
$delta = -$delta;
# never knew RSS could decrease, probably Size can't?
- &status("MEM:$prefix decreased by $delta kB. YES YES YES");
+ $str = "MEM:$prefix decreased by $delta kB. YES YES YES";
}
+
+ &status($str);
+ &DCCBroadcast($str) if (&whatInterface() =~ /IRC/ &&
+ grep(/Irc.pl/, keys %moduleAge));
}
$memusageOld = $memusage;
} else {
&openLog(); # write, append.
# read.
- &loadIgnore($infobot_misc_dir."/infobot.ignore");
- &loadLang($infobot_misc_dir."/infobot.lang");
- &loadIRCServers($infobot_misc_dir."/ircII.servers");
- &loadUsers($infobot_misc_dir."/infobot.users");
+ &loadIgnore($bot_misc_dir. "/blootbot.ignore");
+ &loadLang($bot_misc_dir. "/blootbot.lang");
+ &loadIRCServers($bot_misc_dir. "/ircII.servers");
+ &loadUsers($bot_misc_dir. "/blootbot.users");
$shm = &openSHM();
- &openDB();
+ &openSQLDebug() if (&IsParam("SQLDebug"));
+ &openDB($param{'DBName'}, $param{'SQLUser'}, $param{'SQLPass'});
&status("Setup: ". &countKeys("factoids") ." factoids.");
}
sub setupConfig {
- &loadConfig($infobot_misc_dir."/infobot.config");
+ $param{'VERBOSITY'} = 1;
+ &loadConfig($bot_misc_dir."/blootbot.config");
foreach ("ircNick", "ircUser", "ircName", "DBType") {
next if &IsParam($_);
}
# static scalar variables.
- $file{utm} = "$infobot_base_dir/$param{'ircUser'}.uptime";
- $file{PID} = "$infobot_base_dir/$param{'ircUser'}.pid";
+ $file{utm} = "$bot_base_dir/$param{'ircUser'}.uptime";
+ $file{PID} = "$bot_base_dir/$param{'ircUser'}.pid";
}
sub startup {
sub restart {
my ($sig) = @_;
- if ($$ == $infobot_pid) {
+ if ($$ == $bot_pid) {
&status("$sig called.");
### crappy bug in Net::IRC?
}
&shutdown();
- &loadConfig($infobot_misc_dir."/infobot.config");
- &reloadModules() if (&IsParam("DEBUG"));
+ &loadConfig($bot_misc_dir."/blootbot.config");
+ &reloadAllModules() if (&IsParam("DEBUG"));
&setup();
&status("End of $sig.");
if (!open(FILE, $file)) {
&ERROR("FAILED loadConfig ($file): $!");
- &status("Please make sure the configuration file exists.");
- exit 1;
+ &status("Please copy files/sample.config to files/blootbot.config");
+ &status(" and edit files/blootbot.config, modify to tastes.");
+ exit 0;
}
my $count = 0;