+ # chanadd.
+ if ( $message =~ /^(chanset|chanadd)(\s+(.*?))?$/ ) {
+ my $cmd = $1;
+ my $args = $3;
+ my $no_chan = 0;
+
+ if ( !defined $args ) {
+ &help($cmd);
+ return;
+ }
+
+ my @chans;
+ while ( $args =~ s/^($mask{chan})\s*// ) {
+ push( @chans, lc($1) );
+ }
+
+ if ( !scalar @chans ) {
+ push( @chans, '_default' );
+ $no_chan = 1;
+ }
+
+ my ( $what, $val ) = split /[\s\t]+/, $args, 2;
+
+ ### TODO: "cannot set values without +m".
+ return unless ( &hasFlag('n') );
+
+ # READ ONLY.
+ if ( defined $what and $what !~ /^[-+]/ and !defined $val and $no_chan )
+ {
+ &performStrictReply("Showing $what values on all channels...");
+
+ my %vals;
+ foreach ( keys %chanconf ) {
+ my $val;
+ if ( defined $chanconf{$_}{$what} ) {
+ $val = $chanconf{$_}{$what};
+ }
+ else {
+ $val = "NOT-SET";
+ }
+ $vals{$val}{$_} = 1;
+ }
+
+ foreach ( keys %vals ) {
+ &performStrictReply( " $what = $_("
+ . scalar( keys %{ $vals{$_} } ) . "): "
+ . join( ' ', sort keys %{ $vals{$_} } ) );
+ }
+
+ &performStrictReply("End of list.");
+
+ return;
+ }
+
+ ### TODO: move to UserDCC again.
+ if ( $cmd eq 'chanset' and !defined $what ) {
+ &DEBUG("showing channel conf.");
+
+ foreach $chan (@chans) {
+ if ( $chan eq '_default' ) {
+ &performStrictReply('Default channel settings');
+ }
+ else {
+ &performStrictReply("chan: $chan (see _default also)");
+ }
+ my @items;
+ my $str = '';
+ foreach ( sort keys %{ $chanconf{$chan} } ) {
+ my $newstr = join( ', ', @items );
+ ### TODO: make length use channel line limit?
+ if ( length $newstr > 370 ) {
+ &performStrictReply(" $str");
+ @items = ();
+ }
+ $str = $newstr;
+ push( @items, "$_ => $chanconf{$chan}{$_}" );
+ }
+ if (@items) {
+ my $str = join( ', ', @items );
+ &performStrictReply(" $str");
+ }
+ }
+ return;
+ }
+
+ $cache{confvars}{$what} = $val;
+ &rehashConfVars();
+
+ foreach (@chans) {
+ &chanSet( $cmd, $_, $what, $val );
+ }
+
+ return;
+ }