]> git.donarmstrong.com Git - infobot.git/blobdiff - src/DynaConfig.pl
- another round of patches from lear. "we love you, lear!" j/k :o
[infobot.git] / src / DynaConfig.pl
index e1acb4d3e3e46e351a344bf77d3a43751c5b5312..d90f6fafd8f7be28cda8f7ea80a4164bf62ea491 100644 (file)
@@ -13,7 +13,12 @@ if (&IsParam("useStrict")) { use strict; }
 #####
 
 sub readUserFile {
-    my $f = "$bot_misc_dir/blootbot.users";
+    my $f = "$bot_state_dir/blootbot.users";
+
+    if (! -f $f) {
+       &DEBUG("userfile not found; new fresh run detected.");
+       return;
+    }
 
     if ( -f $f and -f "$f~") {
        my $s1 = -s $f;
@@ -57,6 +62,11 @@ sub readUserFile {
                next;
            }
 
+           if (!defined $nick) {
+               &WARN("invalid line: $_");
+               next;
+           }
+
            # nice little hack.
            if ($what eq "HOSTS") {
                $users{$nick}{$what}{$val} = 1;
@@ -112,7 +122,7 @@ sub writeUserFile {
        return;
     }
 
-    if (!open OUT,">$bot_misc_dir/blootbot.users") {
+    if (!open OUT,">$bot_state_dir/blootbot.users") {
        &ERROR("cannot write to userfile.");
        return;
     }
@@ -216,7 +226,7 @@ sub writeUserFile {
 #####
 
 sub readChanFile {
-    my $f = "$bot_misc_dir/blootbot.chan";
+    my $f = "$bot_state_dir/blootbot.chan";
     if ( -f $f and -f "$f~") {
        my $s1 = -s $f;
        my $s2 = -s "$f~";
@@ -287,7 +297,7 @@ sub writeChanFile {
        return;
     }
 
-    if (!open OUT,">$bot_misc_dir/blootbot.chan") {
+    if (!open OUT,">$bot_state_dir/blootbot.chan") {
        &ERROR("cannot write chanfile.");
        return;
     }
@@ -339,7 +349,7 @@ sub writeChanFile {
        }
 
        foreach (keys %opts) {
-           next unless ($opts{$_} > 1);
+           next unless ($opts{$_} > 2);
            &DEBUG("  opts{$_} => $opts{$_}");
        }
 
@@ -547,7 +557,11 @@ sub userAdd {
     $utime_userfile = time();
     $ucount_userfile++;
 
-    $users{$nick}{HOSTS}{$mask} = 1;
+    if (defined $mask and $mask !~ /^\s*$/) {
+       &DEBUG("userAdd: mask => $mask");
+       $users{$nick}{HOSTS}{$mask} = 1;
+    }
+
     $users{$nick}{FLAGS}       ||= $users{_default}{FLAGS};
 
     return 1;
@@ -759,6 +773,35 @@ sub chanSet {
     return;
 }
 
+sub rehashConfVars {
+    # this is an attempt to fix where an option is loaded but the module
+    # has not loaded. it also can be used for other things.
+
+    foreach (keys %{ $cache{confvars} }) {
+       my $i = $cache{confvars}{$_};
+       &DEBUG("rehashConfVars: _ => $_");
+
+       if (/^news$/ and $i) {
+           &loadMyModule("news");
+           delete $cache{confvars}{$_};
+       }
+
+       if (/^uptime$/ and $i) {
+           &loadMyModule("uptime");
+           delete $cache{confvars}{$_};
+       }
+
+       if (/^rootwarn$/i and $i) {
+           &loadMyModule($_);
+           delete $cache{confvars}{$_};
+       }
+    }
+
+    &DEBUG("end of rehashConfVars");
+
+    delete $cache{confvars};
+}
+
 my @regFlagsChan = (
        "autojoin",
        "freshmeat",