]> git.donarmstrong.com Git - infobot.git/commitdiff
- now prevent ".chanset +blah 10"
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 13 Feb 2001 14:03:53 +0000 (14:03 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 13 Feb 2001 14:03:53 +0000 (14:03 +0000)
- recoded it a bit.

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

blootbot/src/DynaConfig.pl

index 0a83d217a2393e4821340e8ca14b9be2935e9766..398781d55197d23ea324a06ff86a7234951e1697 100644 (file)
@@ -628,38 +628,41 @@ sub chanSet {
 
     my $update = 0;
 
-    if (defined $what and $what =~ s/^\+(\S+)/$1/) {
-       my $was = $chanconf{$chan}{$1};
-       if (defined $was and $was eq "1") {
-           &pSReply("setting $what for $chan already 1.");
-           return;
-       }
+    ### ".chanset +blah"
+    ### ".chanset +blah 10"            -- error.
+    if (defined $what and $what =~ s/^([+-])(\S+)/$2/) {
+       my $state       = ($1 eq "+") ? 1 : 0;
+       my $was         = $chanconf{$chan}{$what};
+
+       if ($state) {                   # add/set.
+           if (defined $was and $was eq "1") {
+               &pSReply("setting $what for $chan already 1.");
+               return;
+           }
 
-       $was    = ($was) ? "; was '$was'" : "";
-       &pSReply("Setting $what for $chan to '1'$was.");
+           $was        = ($was) ? "; was '$was'" : "";
+           $val        = 1;
 
-       $chanconf{$chan}{$what} = 1;
+       } else {                        # delete/unset.
+           if (!defined $was) {
+               &pSReply("setting $what for $chan is not set.");
+               return;
+           }
 
-       $update++;
-    } elsif (defined $what and $what =~ s/^\-(\S+)/$1/) {
-       my $was = $chanconf{$chan}{$1};
-       # hrm...
-       if (!defined $was) {
-           &pSReply("setting $what for $chan is not set.");
-           return;
-       }
+           if ($was eq "0") {
+               &pSReply("setting $what for $chan already 0.");
+               return;
+           }
 
-       if ($was eq "0") {
-           &pSReply("setting $what for $chan already 0.");
-           return;
+           $was        = ($was) ? "; was '$was'" : "";
+           $val        = 0;
        }
 
-       $was    = ($was) ? "; was '$was'" : "";
-       &pSReply("Setting $what for $chan to '0'$was.");
-
-       $chanconf{$chan}{$what} = 0;
-
+       $chanconf{$chan}{$what} = $val;
+       &pSReply("Setting $what for $chan to '$val'$was.");
        $update++;
+
+    ### ".chanset blah testing"
     } elsif (defined $val) {
        my $was = $chanconf{$chan}{$what};
        if (defined $was and $was eq $val) {
@@ -672,7 +675,15 @@ sub chanSet {
        $chanconf{$chan}{$what} = $val;
 
        $update++;
+
+    ### ".chanset"
+    ### ".chanset blah"
     } else {                           # read only.
+       if (!defined $what) {
+           &WARN("chanset/DC: what == undefine.");
+           return;
+       }
+
        if (exists $chanconf{$chan}{$what}) {
            &pSReply("$what for $chan is '$chanconf{$chan}{$what}'");
        } else {
@@ -683,32 +694,6 @@ sub chanSet {
     if ($update) {
        $utime_chanfile = time();
        $ucount_chanfile++;
-       return;
-    }
-
-    ### TODO: move to UserDCC again.
-    if ($cmd eq "chanset" and !defined $what) {
-       &DEBUG("showing channel conf.");
-
-       foreach $chan ($chan, "_default") {
-           &pSReply("chan: $chan");
-           ### TODO: merge 2 or 3 per line.
-           my @items;
-           my $str = "";
-           foreach (sort keys %{ $chanconf{$chan} }) {
-               my $newstr = join(', ', @items);
-               if (length $newstr > 60) {
-                   &pSReply("    $str");
-                   @items = ();
-               }
-               $str = $newstr;
-               push(@items, "$_ => $chanconf{$chan}{$_}");
-           }
-
-           &pSReply("    $str") if (@items);
-       }
-
-       return;
     }
 
     return;