#####
sub readUserFile {
- if (!open IN,"$bot_misc_dir/blootbot.users") {
+ my $f = "$bot_misc_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;
+ my $s2 = -s "$f~";
+
+ if ($s2 > $s1*3) {
+ &DEBUG("rUF: backup file bigger than current file. FIXME");
+ }
+ }
+
+ if (!open IN, $f) {
&ERROR("cannot read userfile.");
&closeLog();
exit 1;
}
sub writeUserFile {
+ if (!scalar keys %users) {
+ &DEBUG("wUF: nothing to write.");
+ return;
+ }
+
if (!open OUT,">$bot_misc_dir/blootbot.users") {
&ERROR("cannot write to userfile.");
return;
#####
sub readChanFile {
- if (!open IN,"$bot_misc_dir/blootbot.chan") {
+ my $f = "$bot_misc_dir/blootbot.chan";
+ if ( -f $f and -f "$f~") {
+ my $s1 = -s $f;
+ my $s2 = -s "$f~";
+
+ if ($s2 > $s1*3) {
+ &DEBUG("rCF: backup file bigger than current file. FIXME");
+ }
+ }
+
+ if (!open IN, $f) {
&ERROR("cannot erad chanfile.");
return;
}
$chanconf{$chan}{$1} = 1;
} elsif (/^[\s\t]+\-(\S+)$/) { # bool, false.
- $chanconf{$chan}{$1} = 0;
+ &DEBUG("deprecated support of negative options.") unless ($cache{negative});
+ # although this is supported in run-time configuration.
+ $cache{negative} = 1;
+# $chanconf{$chan}{$1} = 0;
} elsif (/^[\s\t]+(\S+)[\ss\t]+(.*)$/) {# what = val.
$chanconf{$chan}{$1} = $2;
}
}
+ delete $cache{negative};
+
&status("CHANFILE: Loaded: ".(scalar(keys %chanconf)-1)." chans");
}
sub writeChanFile {
+ if (!scalar keys %chanconf) {
+ &DEBUG("wCF: nothing to write.");
+ return;
+ }
+
if (!open OUT,">$bot_misc_dir/blootbot.chan") {
&ERROR("cannot write chanfile.");
return;
}
}
- &DEBUG("chans => ".scalar(keys %chanconf)." - 1");
foreach (keys %opts) {
+ next unless ($opts{$_} > 1);
&DEBUG(" opts{$_} => $opts{$_}");
}
foreach $user (keys %users) {
next if ($user eq "_default");
- foreach $m (keys %{$users{$user}{HOSTS}}) {
+ foreach $m (keys %{ $users{$user}{HOSTS} }) {
$m =~ s/\?/./g;
$m =~ s/\*/.*?/g;
$m =~ s/([\@\(\)\[\]])/\\$1/g;
return 0 unless ($plain ne "" and $encrypted ne "");
# MD5 // DES. Bobby Billingsley++.
- my $salt = substr($encrypted, 0, 2);
- if ($encrypted =~ /^\$\d\$(\w\w)\$/) {
+ my $salt;
+ if ($encrypted =~ /^(\S{2})/ and length $encrypted == 13) {
$salt = $1;
+ } elsif ($encrypted =~ /^\$\d\$(\w\w)\$/) {
+ $salt = $1;
+ } else {
+ &DEBUG("unknown salt from $encrypted.");
+ return 0;
}
return ($encrypted eq crypt($plain, $salt));
exists $bans{'*'}{$mask});
$bans{$chan}{$mask} = [$expire, time(), 0, $who, $reason];
+ my @chans = ($chan eq "*") ? keys %channels : $chan;
+ my $m = $mask;
+ $m =~ s/\?/\\./g;
+ $m =~ s/\*/\\S*/g;
+ foreach (@chans) {
+ my $chan = $_;
+ foreach (keys %{ $channels{$chan}{''} }) {
+ next unless (exists $nuh{lc $_});
+ next unless ($nuh{lc $_} =~ /^$m$/i);
+ &FIXME("nuh{$_} =~ /$m/");
+ }
+ }
+
if ($exist == 1) {
$utime_userfile = time();
$ucount_userfile++;
$val = 0;
}
- $chanconf{$chan}{$what} = $val;
- &pSReply("Setting $what for $chan to '$val'$was.");
+ if ($val eq "0") {
+ &pSReply("Unsetting $what for $chan$was.");
+ delete $chanconf{$chan}{$what};
+ } else {
+ &pSReply("Setting $what for $chan to '$val'$was.");
+ $chanconf{$chan}{$what} = $val;
+ }
+
$update++;
### ".chanset blah testing"
### TODO: finish off this list.
);
-my @regFlagsUser = ("mno"); # todo...
+my @regFlagsUser = (
+ "m", # master
+ "n", # owner
+ "o", # op
+); # todo...
1;
+
+#####
+# Userflags
+# +r - ability to remove factoids
+# +t - ability to teach factoids
+# +m - ability to modify factoids
+# +n - bot owner
+# +o - authorised user of bot (like +m on eggdrop)
+#####