]> git.donarmstrong.com Git - infobot.git/commitdiff
split off chanset from UserDCC to here to do multiple chans
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 6 Feb 2001 12:23:50 +0000 (12:23 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Tue, 6 Feb 2001 12:23:50 +0000 (12:23 +0000)
- look at 1.19->1.20 to see changes

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

src/DynaConfig.pl

index ba4245195c24ae36650201259bf58453f01b264c..0a83d217a2393e4821340e8ca14b9be2935e9766 100644 (file)
@@ -372,7 +372,7 @@ sub verifyUser {
     my ($user,$m);
 
     if ($userHandle = $dcc{'CHATvrfy'}{$who}) {
-       &DEBUG("vUser: cached auth for $who.");
+       &VERB("vUser: cached auth for $who.",2);
        return $userHandle;
     }
 
@@ -604,6 +604,116 @@ sub getUser {
     }
 }
 
+sub chanSet {
+    my($cmd, $chan, $what, $val) = @_;
+
+    if ($cmd eq "+chan") {
+       if (exists $chanconf{$chan}) {
+           &pSReply("chan $chan already exists.");
+           return;
+       }
+       $chanconf{$chan}{_time_added}   = time();
+       $chanconf{$what}{autojoin}      = 1;
+
+       &pSReply("Joining $chan...");
+       &joinchan($chan);
+
+       return;
+    }
+
+    if (!exists $chanconf{$chan}) {
+       &pSReply("no such channel $chan");
+       return;
+    }
+
+    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;
+       }
+
+       $was    = ($was) ? "; was '$was'" : "";
+       &pSReply("Setting $what for $chan to '1'$was.");
+
+       $chanconf{$chan}{$what} = 1;
+
+       $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;
+       }
+
+       $was    = ($was) ? "; was '$was'" : "";
+       &pSReply("Setting $what for $chan to '0'$was.");
+
+       $chanconf{$chan}{$what} = 0;
+
+       $update++;
+    } elsif (defined $val) {
+       my $was = $chanconf{$chan}{$what};
+       if (defined $was and $was eq $val) {
+           &pSReply("setting $what for $chan already '$val'.");
+           return;
+       }
+       $was    = ($was) ? "; was '$was'" : "";
+       &pSReply("Setting $what for $chan to '$val'$was.");
+
+       $chanconf{$chan}{$what} = $val;
+
+       $update++;
+    } else {                           # read only.
+       if (exists $chanconf{$chan}{$what}) {
+           &pSReply("$what for $chan is '$chanconf{$chan}{$what}'");
+       } else {
+           &pSReply("$what for $chan is not set.");
+       }
+    }
+
+    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;
+}
+
 my @regFlagsChan = (
        "autojoin",
        "freshmeat",