]> git.donarmstrong.com Git - infobot.git/commitdiff
fixed '.chanset' code.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 3 Feb 2001 12:51:20 +0000 (12:51 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 3 Feb 2001 12:51:20 +0000 (12:51 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@313 c11ca15a-4712-0410-83d8-924469b57eb5

src/Modules/UserDCC.pl

index 6967881d03f964be5b488d866ac1daf2e81f3bf8..175966b3d3e533ab9b9f630ba200b0b5c1963bb3 100644 (file)
@@ -461,21 +461,21 @@ sub userDCC {
 
     # +chan.
     if ($message =~ /^(chanset|\+chan)(\s+(.*?))?$/) {
-       my $cmd  = $1;
-       my $args = $3;
+       my $cmd         = $1;
+       my $args        = $3;
+       my $no_chan     = 0;
 
        if (!defined $args) {
            &help($cmd);
            return;
        }
 
-       my ($chan);
+       my $chan;
        if ($args =~ s/^($mask{chan})\s*//) {
            $chan       = $1;
-           &DEBUG("chan => $chan.");
        } else {
-           &DEBUG("no chan arg; setting to default.");
            $chan       = "_default";
+           $no_chan    = 1;
        }
 
        my($what,$val) = split /[\s\t]+/, $args, 2;
@@ -500,24 +500,44 @@ sub userDCC {
 
        my $update      = 0;
        ### TODO: $what can be undefined. fix it!
-       if ($what =~ /^\+(\S+)/) {
+       if ($what =~ s/^\+(\S+)/$1/) {
            my $was     = $chanconf{$chan}{$1};
+           if ($was eq "1") {
+               &pSReply("setting $what for $chan already 1.");
+               return;
+           }
+
            $was        = ($was) ? "; was '$was'" : "";
-           &pSReply("Setting $1 for $chan to '1'$was.");
+           &pSReply("Setting $what for $chan to '1'$was.");
 
-           $chanconf{$chan}{$1} = 1;
+           $chanconf{$chan}{$what} = 1;
 
            $update++;
-       } elsif ($what =~ /^\-(\S+)/) {
+       } elsif ($what =~ s/^\-(\S+)/$1/) {
            my $was     = $chanconf{$chan}{$1};
+           # hrm...
+           if (!defined $was) {
+               &pSReply("setting $1 for $chan is not set.");
+               return;
+           }
+
+           if ($was eq "0") {
+               &pSReply("setting $1 for $chan already 0.");
+               return;
+           }
+
            $was        = ($was) ? "; was '$was'" : "";
-           &pSReply("Setting $1 for $chan to '0'$was.");
+           &pSReply("Setting $what for $chan to '0'$was.");
 
-           $chanconf{$chan}{$1} = 0;
+           $chanconf{$chan}{$what} = 0;
 
            $update++;
        } elsif (defined $val) {
            my $was     = $chanconf{$chan}{$what};
+           if ($was eq $val) {
+               &pSReply("setting $1 for $chan already '$val'.");
+               return;
+           }
            $was        = ($was) ? "; was '$was'" : "";
            &pSReply("Setting $what for $chan to '$val'$was.");