&status("--- Start of quit.");
$ident ||= "blootbot"; # lame hack.
- &closeDCC();
+ &closeDCC() if (&whatInterface() =~ /IRC/);
&closePID();
&closeStats();
- &seenFlush();
+ &seenFlush() if (&whatInterface() =~ /IRC/);
&quit($param{'quitMsg'}) if (&whatInterface() =~ /IRC/);
&writeUserFile();
&writeChanFile();
&closeDB();
&closeSHM($shm);
&dumpallvars() if (&IsParam("dumpvarsAtExit"));
+ &symdumpAll() if (&IsParam("symdumpAtExit"));
&closeLog();
&closeSQLDebug() if (&IsParam("SQLDebug"));
return $chanconf{"_default"}{$param};
}
+sub getChanConfDefault {
+ my($what, $default, $chan) = @_;
+
+ if (exists $param{$what}) {
+ if (!exists $cache{config}{$what}) {
+ &status("conf: backward-compat: found param{$what} ($param{$what}) instead.");
+ $cache{config}{$what} = 1;
+ }
+
+ return $param{$what};
+ }
+ my $val = &getChanConf($what, $chan);
+ return $val if (defined $val);
+
+ $param{$what} = $default;
+ &status("conf: auto-setting param{$what} = $default");
+ $cache{config}{$what} = 1;
+ return $default;
+}
+
+
#####
# Usage: &findChanConf($param);
# About: Retrieve value for 'param' value from any chan.
sub showProc {
my ($prefix) = $_[0] || "";
- if (!open(IN, "/proc/$$/status")) {
- &ERROR("cannot open '/proc/$$/status'.");
- return;
- }
-
if ($^O eq "linux") {
+ if (!open(IN, "/proc/$$/status")) {
+ &ERROR("cannot open '/proc/$$/status'.");
+ return;
+ }
+
while (<IN>) {
$memusage = $1 if (/^VmSize:\s+(\d+) kB/);
}
} else { # delta < 0.
$delta = -$delta;
# never knew RSS could decrease, probably Size can't?
- $str = "MEM:$prefix decreased by $delta kB. YES YES YES";
+ $str = "MEM:$prefix decreased by $delta kB.";
}
&status($str);
&openLog(); # write, append.
&status("--- Started logging.");
- foreach ("debian") {
- my $dir = "$bot_base_dir/$_/";
- next if ( -d $dir);
- &status("Making dir $_");
- mkdir $dir, 0755;
- }
-
# read.
&loadLang($bot_data_dir. "/blootbot.lang");
&loadIRCServers();
if (! -d $param{tempDir}) {
&status("making $param{tempDir}...");
- system("mkdir $param{tempDir}");
+ mkdir $param{tempDir}, 0755;
}
# static scalar variables.
my ($file) = @_;
if (!open(FILE, $file)) {
- &ERROR("FAILED loadConfig ($file): $!");
+ &ERROR("Failed to read configuration file ($file): $!");
&status("Please read the INSTALL file on how to install and setup this file.");
exit 0;
}