#####
sub readUserFile {
- if (!open IN,"$bot_misc_dir/blootbot.users") {
+ my $f = "$bot_misc_dir/blootbot.users";
+
+ 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;
}
}
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;
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;
$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"