]> git.donarmstrong.com Git - infobot.git/commitdiff
- added removal of possible duplicate configuration entries when bot
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 30 Jan 2001 12:46:02 +0000 (12:46 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 30 Jan 2001 12:46:02 +0000 (12:46 +0000)
  exits.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@271 c11ca15a-4712-0410-83d8-924469b57eb5

src/DynaConfig.pl

index 5aa38063c38bcee04ba49f1e09ef4a33af74119b..bfc5dd151200680dda55f8e6572186b345b81ff5 100644 (file)
@@ -125,8 +125,7 @@ sub writeUserFile {
 
        my $count = scalar keys %{ $bans{$chan} };
        if (!$count) {
-           &WARN("bans: chan $chan has no other attributes;
-skipping.");
+           &WARN("bans: chan $chan has no other attributes; skipping.");
            next;
        }
 
@@ -223,6 +222,58 @@ sub writeChanFile {
     my $time           = scalar(localtime);
     print OUT "#v1: blootbot -- $ident -- written $time\n\n";
 
+    if ($flag_quit) {
+
+       ### Process 1: if defined in _default, remove same definition
+       ###             from non-default channels.
+       foreach (keys %{ $chanconf{_default} }) {
+           my $opt     = $_;
+           my $val     = $chanconf{_default}{$opt};
+           my @chans;
+
+           foreach (keys %chanconf) {
+               $chan = $_;
+
+               next if ($chan eq "_default");
+               next unless (exists $chanconf{$chan}{$opt});
+               next unless ($val eq $chanconf{$chan}{$opt});
+               push(@chans,$chan);
+               delete $chanconf{$chan}{$opt};
+           }
+
+           if (scalar @chans) {
+               &DEBUG("Removed config $opt to @chans since it's defiend in '_default'");
+           }
+       }
+
+       ### Process 2: if defined in all chans but _default, set in
+       ###             _default and remove all others.
+       my (%optsval, %opts);
+       foreach (keys %chanconf) {
+           $chan = $_;
+           next if ($chan eq "_default");
+           my $opt;
+
+           foreach (keys %{ $chanconf{$chan} }) {
+               $opt = $_;
+               if (exists $optsval{$opt} and $optsval{$opt} eq $chanconf{$chan}{$opt}) {
+                   $opts{$opt}++;
+                   next;
+               }
+               $optsval{$opt}  = $chanconf{$chan}{$opt};
+               $opts{$opt}     = 1;
+           }
+       }
+
+       &DEBUG("chans => ".scalar(keys %chanconf)." - 1");
+       foreach (keys %opts) {
+           &DEBUG("  opts{$_} => $opts{$_}");
+       }
+
+       ### other optimizations are in UserDCC.pl
+    }
+
+    ### lets do it...
     foreach (sort keys %chanconf) {
        $chan   = $_;