#####
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;
next;
}
+ if (!defined $nick) {
+ &WARN("invalid line: $_");
+ next;
+ }
+
# nice little hack.
if ($what eq "HOSTS") {
$users{$nick}{$what}{$val} = 1;
return;
}
- if (!open OUT,">$bot_misc_dir/blootbot.users") {
+ if (!open OUT,">$bot_state_dir/blootbot.users") {
&ERROR("cannot write to userfile.");
return;
}
#####
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~";
return;
}
- if (!open OUT,">$bot_misc_dir/blootbot.chan") {
+ if (!open OUT,">$bot_state_dir/blootbot.chan") {
&ERROR("cannot write chanfile.");
return;
}
}
foreach (keys %opts) {
- next unless ($opts{$_} > 1);
+ next unless ($opts{$_} > 2);
&DEBUG(" opts{$_} => $opts{$_}");
}
$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;
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",