]> git.donarmstrong.com Git - infobot.git/blobdiff - src/core.pl
- added 'unique user count' to chanstats.
[infobot.git] / src / core.pl
index 9a3104cc2ffe0af17f1857bdba4ee3fcb96f2457..f107841e6e09fee2b34e062e9cf27a9a63e1e903 100644 (file)
@@ -30,7 +30,7 @@ use vars qw(@joinchan @ircServers @wingateBad @wingateNow @wingateCache
 use vars qw(%count %netsplit %netsplitservers %flood %dcc %orig
            %nuh %talkWho %seen %floodwarn %param %dbh %ircPort
            %jointime %topic %joinverb %moduleAge %last %time %mask %file
-           %forked %pid %chanconf %channels
+           %forked %chanconf %channels
 );
 
 # Signals.
@@ -85,7 +85,7 @@ sub doExit {
        &quit($param{'quitMsg'}) if (&whatInterface() =~ /IRC/);
        &writeUserFile();
        &writeChanFile();
-       &uptimeWriteFile()      if (&IsParam("uptime"));
+       &uptimeWriteFile()      if (&ChanConfList("uptime"));
        &closeDB();
        &closeSHM($shm);
        &dumpallvars()          if (&IsParam("dumpvarsAtExit"));
@@ -128,16 +128,11 @@ sub IsParam {
 # Return: array of channels
 sub ChanConfList {
     my $param  = $_[0];
-    my %chan   = &getChanConfList($param);
-
     return unless (defined $param);
+    my %chan   = &getChanConfList($param);
 
     ### TODO: -option is included aswell though.
-    if ($chan{_default}) {
-       return keys %channels;
-    } else {
-       return keys %chan;
-    }
+    return keys %chan;
 }
 
 #####
@@ -197,10 +192,11 @@ sub IsChanConf {
        return $chan{_default} || 0;
     }
 
-    &DEBUG("param => $param, msgType => $msgType.");
-    foreach (keys %chan) {
-       &DEBUG("   $_ => $chan{$_}");
-    }
+### debug purposes only.
+#    &DEBUG("param => $param, msgType => $msgType.");
+#    foreach (keys %chan) {
+#      &DEBUG("   $_ => $chan{$_}");
+#    }
 
     return 0;
 }
@@ -220,7 +216,7 @@ sub getChanConf {
     $chan      ||= "_default";
     my @c      = grep /^$chan$/i, keys %chanconf;
 
-    if ($c[0] ne $chan) {
+    if (@c and $c[0] ne $chan) {
        &WARN("c ne chan ($c[0] ne $chan)");
     }
 
@@ -258,8 +254,6 @@ sub showProc {
            }
 
            &status($str);
-           &DCCBroadcast($str) if (&whatInterface() =~ /IRC/ &&
-               grep(/Irc.pl/, keys %moduleAge));
        }
        $memusageOld = $memusage;
     } else {
@@ -305,10 +299,6 @@ sub setup {
 sub setupConfig {
     $param{'VERBOSITY'} = 1;
     &loadConfig($bot_misc_dir."/blootbot.config");
-    if (&IsParam("WIP")) {
-       require "src/Config.pl";
-       &NEWloadConfig();
-    }
 
     foreach ("ircNick", "ircUser", "ircName", "DBType", "tempDir") {
        next if &IsParam($_);
@@ -345,6 +335,7 @@ sub startup {
     $count{'Question'} = 0;
     $count{'Update'}   = 0;
     $count{'Dunno'}    = 0;
+    $count{'Moron'}    = 0;
 }
 
 sub shutdown {
@@ -354,14 +345,14 @@ sub shutdown {
     &closeDB();
     &closeSHM($shm);   # aswell. TODO: use this in &doExit?
     &closeLog();
+    ### is this valid?
+    &writeUserFile();
+    &writeChanFile();
 }
 
 sub restart {
     my ($sig) = @_;
 
-    &DEBUG(" forked => ".scalar(keys %forked) );
-    &DEBUG(" pid    => ".scalar(keys %pid) );
-
     if ($$ == $bot_pid) {
        &status("--- $sig called.");
 
@@ -373,6 +364,7 @@ sub restart {
            return;
        }
 
+       &DCCBroadcast("-HUP called.","m");
        &shutdown();
        &loadConfig($bot_misc_dir."/blootbot.config");
        &reloadAllModules() if (&IsParam("DEBUG"));