]> git.donarmstrong.com Git - infobot.git/blobdiff - src/core.pl
Debian.pl creates the dir elsewhere
[infobot.git] / src / core.pl
index e8975c136a799f11219e10e071d3de9d85c8fbd0..2f7e7f3792912f8ae5a0e603ed1c21c201eb8137 100644 (file)
@@ -100,10 +100,10 @@ sub doExit {
        &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();
@@ -112,6 +112,7 @@ sub doExit {
        &closeDB();
        &closeSHM($shm);
        &dumpallvars()          if (&IsParam("dumpvarsAtExit"));
+       &symdumpAll()           if (&IsParam("symdumpAtExit"));
        &closeLog();
        &closeSQLDebug()        if (&IsParam("SQLDebug"));
 
@@ -302,6 +303,27 @@ sub getChanConf {
     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.
@@ -330,12 +352,12 @@ sub findChanConf {
 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/);
        }
@@ -366,7 +388,7 @@ sub showProc {
        } 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);
@@ -383,13 +405,6 @@ sub setup {
     &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();
@@ -438,7 +453,7 @@ sub setupConfig {
 
     if (! -d $param{tempDir}) {
        &status("making $param{tempDir}...");
-       system("mkdir $param{tempDir}");
+       mkdir $param{tempDir}, 0755;
     }
 
     # static scalar variables.
@@ -510,7 +525,7 @@ sub loadConfig {
     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;
     }