]> git.donarmstrong.com Git - infobot.git/blobdiff - src/modules.pl
A round of fixes:
[infobot.git] / src / modules.pl
index d06ec19ce7c960a08843a112aed99d998c0bd68f..30c5a40c8d9d2d2113ab89e7d0f159ec9bf4e5c4 100644 (file)
@@ -59,8 +59,6 @@ sub loadCoreModules {
        exit 1;
     }
 
-    &status("Loading CORE modules...");
-
     my @mods;
     while (defined(my $file = readdir DIR)) {
        next unless $file =~ /\.pl$/;
@@ -68,12 +66,11 @@ sub loadCoreModules {
        push(@mods, $file);
     }
     closedir DIR;
-    &DEBUG("mods: ".scalar(@mods)." to be loaded...");
+    &status("Loading ".scalar(@mods)." CORE modules...");
 
     foreach (sort @mods) {
        my $mod = "$bot_src_dir/$_";
 
-       ### TODO: use eval and exit gracefully?
        eval "require \"$mod\"";
        if ($@) {
            &ERROR("lCM => $@");
@@ -196,9 +193,8 @@ sub loadMyModulesNow {
        }
 
        if (!&IsParam($_) and !&IsChanConf($_) and !&getChanConfList($_)) {
-           &DEBUG("_ => $_");
            if (exists $myModules{$_}) {
-               &status("myModule: $myModules{$_} (1) not loaded.");
+               &status("myModule: $myModules{$_} or $_ (1) not loaded.");
            } else {
                &DEBUG("myModule: $_ (2) not loaded.");
            }
@@ -243,25 +239,31 @@ sub reloadModule {
        return;
     }
 
-    my $age = (stat $file)[9];
-    return if ($age == $moduleAge{$file});
-
-    if ($age < $moduleAge{$file}) {
-       &WARN("rM: we're not gonna downgrade the file. use 'touch'.");
-       return;
-    }
-
     if (grep /$mod/, @myModulesReloadNot) {
        &DEBUG("rM: SHOULD NOT RELOAD $mod!!!");
        return;
     }
 
-    my $dc  = &Time2String($age   - $moduleAge{$file});
-    my $ago = &Time2String(time() - $moduleAge{$file});
+    my $age = (stat $file)[9];
+
+    if (!exists $moduleAge{$file}) {
+       &DEBUG("Looks like $file was not loaded; fixing.");
+    } else {
+       return if ($age == $moduleAge{$file});
+
+       if ($age < $moduleAge{$file}) {
+           &WARN("rM: we're not gonna downgrade the file. use 'touch'.");
+           return;
+       }
+
+       my $dc  = &Time2String($age   - $moduleAge{$file});
+       my $ago = &Time2String(time() - $moduleAge{$file});
+
+       &VERB("Module:  delta change: $dc",2);
+       &VERB("Module:           ago: $ago",2);
+    }
 
     &status("Module: Loading $mod...");
-    &VERB("Module:  delta change: $dc",2);
-    &VERB("Module:           ago: $ago",2);
 
     delete $INC{$file};
     eval "require \"$file\"";  # require or use?