- 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;
-
- ### ".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'" : "";
- $val = 1;
-
- } else { # delete/unset.
- 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'" : "";
- $val = 0;
- }
-
- if ($val eq "0") {
- &pSReply("Unsetting $what for $chan$was.");
- delete $chanconf{$chan}{$what};
- } else {
- &pSReply("Setting $what for $chan to '$val'$was.");
- $chanconf{$chan}{$what} = $val;
- }
-
- $update++;
-
- ### ".chanset blah testing"
- } 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++;
-
- ### ".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 {
- &pSReply("$what for $chan is not set.");
- }
+ my ( $cmd, $chan, $what, $val ) = @_;
+
+ if ( $cmd eq 'chanadd' ) {
+ if ( exists $chanconf{$chan} ) {
+ &performStrictReply("chan $chan already exists.");
+ return;
+ }
+ $chanconf{$chan}{_time_added} = time();
+ $chanconf{$chan}{autojoin} = $conn->nick();
+
+ &performStrictReply("Joining $chan...");
+ &joinchan($chan);
+
+ return;
+ }
+
+ if ( !exists $chanconf{$chan} ) {
+ &performStrictReply("no such channel $chan");
+ return;
+ }
+
+ my $update = 0;
+
+ if ( defined $what and $what =~ s/^([+-])(\S+)/$2/ ) {
+ ### '.chanset +blah'
+ ### '.chanset +blah 10' -- error.
+
+ my $set = ( $1 eq '+' ) ? 1 : 0;
+ my $was = $chanconf{$chan}{$what};
+
+ if ($set) { # add/set.
+ if ( defined $was and $was eq '1' ) {
+ &performStrictReply("setting $what for $chan already 1.");
+ return;
+ }
+
+ $val = 1;
+
+ }
+ else { # delete/unset.
+ if ( !defined $was ) {
+ &performStrictReply("setting $what for $chan is not set.");
+ return;
+ }
+
+ $val = 0;
+ }
+
+ # alter for cosmetic (print out) reasons only.
+ $was = ( defined $was ) ? "; was '$was'" : '';
+
+ if ( $val eq '0' ) {
+ &performStrictReply("Unsetting $what for $chan$was.");
+ delete $chanconf{$chan}{$what};
+ delete $cache{ircTextCounters} if $what eq 'ircTextCounters';
+ }
+ else {
+ &performStrictReply("Setting $what for $chan to '$val'$was.");
+ $chanconf{$chan}{$what} = $val;
+ delete $cache{ircTextCounters} if $what eq 'ircTextCounters';
+ }
+
+ $update++;
+
+ }
+ elsif ( defined $val ) {
+ ### '.chanset blah testing'
+
+ my $was = $chanconf{$chan}{$what};
+ if ( defined $was and $was eq $val ) {
+ &performStrictReply("setting $what for $chan already '$val'.");
+ return;
+ }
+ $was = ($was) ? "; was '$was'" : '';
+ &performStrictReply("Setting $what for $chan to '$val'$was.");
+
+ $chanconf{$chan}{$what} = $val;
+ delete $cache{ircTextCounters} if $what eq 'ircTextCounters';
+
+ $update++;
+
+ }
+ else { # read only.
+ ### '.chanset'
+ ### '.chanset blah'
+
+ if ( !defined $what ) {
+ &WARN('chanset/DC: what == undefine.');
+ return;
+ }
+
+ if ( exists $chanconf{$chan}{$what} ) {
+ &performStrictReply("$what for $chan is '$chanconf{$chan}{$what}'");
+ }
+ else {
+ &performStrictReply("$what for $chan is not set.");
+ }