]> git.donarmstrong.com Git - infobot.git/blobdiff - src/modules.pl
debugging added.
[infobot.git] / src / modules.pl
index a56f3f3764fd9b2c00a78e748ba813a3a6e5e583..8bb69093f16e6e141332a12563211080cb68cf5e 100644 (file)
@@ -22,7 +22,6 @@ if ($@) {
 ### MODULES.
 %myModules = (
        "countdown"     => "Countdown.pl",
-       "allowDNS"      => "DNS.pl",
        "debian"        => "Debian.pl",
        "debianExtra"   => "DebianExtra.pl",
        "dict"          => "Dict.pl",
@@ -45,6 +44,7 @@ if ($@) {
        "wingate"       => "Wingate.pl",
        "insult"        => "insult.pl",
        "nickometer"    => "nickometer.pl",
+       "babelfish"     => "babel.pl",
 );
 @myModulesLoadNow      = ('topic', 'uptime',);
 @myModulesReloadNot    = ('IRC/Irc.pl','IRC/Schedulers.pl');
@@ -61,8 +61,15 @@ sub loadCoreModules {
        next unless $file =~ /\.pl$/;
        next unless $file =~ /^[A-Z]/;
        my $mod = "$bot_src_dir/$file";
+
        ### TODO: use eval and exit gracefully?
-       require $mod;
+       eval "require \"$mod\"";
+       if ($@) {
+           &ERROR("lCM => $@");
+           &shutdown();
+           exit 1;
+       }
+
        $moduleAge{$mod} = (stat $mod)[9];
        &showProc(" ($file)") if (&IsParam("DEBUG"));
     }
@@ -122,7 +129,12 @@ sub loadFactoidsModules {
        next unless $file =~ /^[A-Z]/;
        my $mod = "$bot_src_dir/Factoids/$file";
        ### TODO: use eval and exit gracefully?
-       require $mod;
+       eval "require \"$mod\"";
+       if ($@) {
+           &WARN("lFM: $@");
+           exit 1;
+       }
+
        $moduleAge{$mod} = (stat $mod)[9];
        &showProc(" ($file)") if (&IsParam("DEBUG"));
     }
@@ -138,6 +150,7 @@ sub loadIRCModules {
            exit 1;
        }
        &showProc(" (Net::IRC)");
+
     } else {
        &status("IRC support DISABLED.");
        return;
@@ -167,11 +180,21 @@ sub loadMyModulesNow {
     &status("Loading MyModules...");
     foreach (@myModulesLoadNow) {
        $total++;
+       if (!defined $_) {
+           &WARN("mMLN: null element.");
+           next;
+       }
+
+       if (!&IsParam($_) and !&IsChanConf($_)) {
+           if (exists $myModules{$_}) {
+               &DEBUG("myModule: $myModules{$_} (1) not loaded.");
+           } else {
+               &DEBUG("myModule: $_ (2) not loaded.");
+           }
 
-       if (!exists $param{$_}) {
-           &DEBUG("myModule: $myModules{$_} not loaded.");
            next;
        }
+
        &loadMyModule($myModules{$_});
        $loaded++;
     }
@@ -306,9 +329,7 @@ sub loadMyModule {
     eval "require \"$modulefile\"";
     if ($@) {
        &ERROR("cannot load my module: $modulebase");
-       if ($bot_pid == $$) {   # parent.
-           &shutdown() if (defined $shm and defined $dbh);
-       } else {                        # child.
+       if ($bot_pid != $$) {   # child.
            &DEBUG("b4 delfork 2");
            &delForked($modulebase);
            exit 1;
@@ -324,19 +345,20 @@ sub loadMyModule {
     }
 }
 
-### this chews 3megs on potato, 300 kB on slink.
-$no_syscall = 0;
-###eval "require 'sys/syscall.ph'";
-#if ($@) {
-#    &WARN("sys/syscall.ph has not been installed//generated. gettimeofday
-#will use time() instead");
-    $no_syscall = 1;
-#}
-#&showProc(" (syscall)");
+$no_timehires = 0;
+eval "use Time::HiRes qw(gettimeofday tv_interval)";
+if ($@) {
+    &WARN("No Time::HiRes?");
+    $no_timehires = 1;
+}
+&showProc(" (Time::HiRes)");
 
 sub AUTOLOAD {
+    return if ($AUTOLOAD =~ /__/);     # internal.
+
     &ERROR("UNKNOWN FUNCTION CALLED: $AUTOLOAD");
     foreach (@_) {
+       next unless (defined $_);
        &status("  => $_");
     }
 }