return unless (&hasFlag("n"));
&status("USER reload $who");
- &msg($who,"reloading...");
+ &pSReply("reloading...");
&reloadAllModules();
- &msg($who,"reloaded.");
+ &pSReply("reloaded.");
return;
}
# +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;
}
my $update = 0;
- if ($what =~ /^\+(\S+)/) {
+ 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 $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 (defined $what and $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 (defined $was and $was eq $val) {
+ &pSReply("setting $1 for $chan already '$val'.");
+ return;
+ }
$was = ($was) ? "; was '$was'" : "";
&pSReply("Setting $what for $chan to '$val'$was.");
$update++;
} elsif (defined $what) {
- &pSReply("$what for $chan is '$chanconf{$chan}{$what}'");
+ if (exists $chanconf{$chan}{$what}) {
+ &pSReply("$what for $chan is '$chanconf{$chan}{$what}'");
+ } else {
+ &pSReply("$what for $chan is not set.'");
+ }
}
if ($update) {
if ($cmd eq "chanset" and !defined $what) {
&DEBUG("showing channel conf.");
- foreach (keys %{ $chanconf{$chan} }) {
- &DEBUG("$chan: $_ => $chanconf{$chan}{$_}");
+ 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}{$_}");
+ }
}
return;
$delete = ($1) ? 1 : 0;
&DEBUG("chan => $chan.");
} else {
- &DEBUG("no chan arg; setting to default.");
+ &VERB("no chan arg; setting to default.",2);
$chan = "_default";
}
if ($args ne "") {
if (&getChanConf($args,$chan)) {
&pSReply("Unsetting channel ($chan) option $args. (was $chanconf{$chan}{$args})");
- undef $chanconf{$chan}{$args};
+ delete $chanconf{$chan}{$args};
} else {
&pSReply("$args does not exist for $chan");
}
my $c;
- &pSReply(" expire, count, who-by, time-added, reason");
+ &pSReply(" mask: expire, time-added, count, who-by, reason");
foreach $c (keys %bans) {
next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
&pSReply(" $c:");
if (ref $val eq "ARRAY") {
my @array = @{ $val };
- &pSReply(" @array");
+ &pSReply(" $_: @array");
} else {
&DEBUG("unknown ban: $val");
}
# chan.
if ($args =~ s/^($mask{chan}|\*)\s*//) {
$chan = $1;
- &DEBUG("chan => $chan");
} else {
$chan = "*";
}
# time.
if ($args =~ s/^(\d+)\s*//) {
$time = $1*60; # ??
- &DEBUG("time => $time");
} else {
$time = 0;
}
# time.
if ($args) {
$comment = $args;
- &DEBUG("comment => $comment");
} else {
$comment = "added by $who";
}
if ( &ignoreAdd($mask, $chan, $time, $comment) > 1) {
- &pSReply("added $mask to ignore list.");
- } else {
&pSReply("warn: $mask already in ignore list; written over anyway. FIXME");
+ } else {
+ &pSReply("added $mask to ignore list.");
}
return;
### TODO: proper (eggdrop-like) formatting.
my $c;
- &pSReply(" expire, count, who, added, comment");
+ &pSReply(" mask: expire, time-added, who, comment");
foreach $c (keys %ignore) {
next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
&pSReply(" $c:");