+ if ( $message =~ /^banlist(\s+(.*))?$/ ) {
+ my $arg = $2;
+
+ if ( defined $arg and $arg !~ /^$mask{chan}$/ ) {
+ &performStrictReply("error: chan $chan is invalid.");
+ return;
+ }
+
+ &DEBUG("bans for global or arg => $arg.");
+ foreach ( keys %bans ) { #CHANGE!!!
+ &DEBUG(" $_ => $bans{$_}.");
+ }
+
+ &DEBUG("End of bans.");
+ &performStrictReply("END of bans.");
+
+ return;
+ }
+
+ if ( $message =~ /^save$/ ) {
+ return unless ( &hasFlag('o') );
+
+ &writeUserFile();
+ &writeChanFile();
+ &performStrictReply('saved user and chan files');
+
+ return;
+ }
+
+ ### ALIASES.
+ $message =~ s/^addignore/+ignore/;
+ $message =~ s/^(del|un)ignore/-ignore/;
+
+ # ignore.
+ if ( $message =~ /^(\+|\-)ignore(\s+(.*))?$/i ) {
+ return unless ( &hasFlag('o') );
+ my $state = ( $1 eq "+" ) ? 1 : 0;
+ my $str = $1 . 'ignore';
+ my $args = $3;
+
+ if ( !$args ) {
+ &help($str);
+ return;
+ }
+
+ my ( $mask, $chan, $time, $comment );
+
+ # mask.
+ if ( $args =~ s/^($mask{nuh})\s*// ) {
+ $mask = $1;
+ }
+ else {
+ &ERROR("no NUH mask?");
+ return;
+ }
+
+ if ( !$state ) { # delignore.
+ if ( &ignoreDel($mask) ) {
+ &performStrictReply("ok, deleted ignores for $mask.");
+ }
+ else {
+ &performStrictReply("could not find $mask in ignore list.");
+ }
+ return;
+ }
+
+ ###
+ # addignore.
+ ###
+
+ # chan.
+ if ( $args =~ s/^($mask{chan}|\*)\s*// ) {
+ $chan = $1;
+ }
+ else {
+ $chan = '*';
+ }
+
+ # time.
+ if ( $args =~ s/^(\d+)\s*// ) {
+ $time = $1; # time is in minutes
+ }
+ else {
+ $time = 0;
+ }
+
+ # time.
+ if ($args) {
+ $comment = $args;
+ }
+ else {
+ $comment = "added by $who";
+ }
+
+ if ( &ignoreAdd( $mask, $chan, $time, $comment ) > 1 ) {
+ &performStrictReply(
+ "FIXME: $mask already in ignore list; written over anyway.");
+ }
+ else {
+ &performStrictReply("added $mask to ignore list.");
+ }
+
+ return;
+ }
+
+ if ( $message =~ /^ignore(\s+(.*))?$/ ) {
+ my $arg = $2;
+
+ if ( defined $arg ) {
+ if ( $arg !~ /^$mask{chan}$/ ) {
+ &performStrictReply("error: chan $chan is invalid.");
+ return;
+ }
+
+ if ( !&validChan($arg) ) {
+ &performStrictReply("error: chan $arg is invalid.");
+ return;
+ }
+
+ &performStrictReply("Showing bans for $arg only.");
+ }
+
+ if ( !scalar keys %ignore ) {
+ &performStrictReply("Ignore list is empty.");
+ return;
+ }
+
+ ### TODO: proper (eggdrop-like) formatting.
+ my $c;
+ &performStrictReply(" mask: expire, time-added, who, comment");
+ foreach $c ( keys %ignore ) {
+ next unless ( !defined $arg or $arg =~ /^\Q$c\E$/i );
+ &performStrictReply(" $c:");
+
+ foreach ( keys %{ $ignore{$c} } ) {
+ my $ref = ref $ignore{$c}{$_};
+ if ( $ref eq 'ARRAY' ) {
+ my @array = @{ $ignore{$c}{$_} };
+ &performStrictReply(" $_: @array");
+ }
+ else {
+ &DEBUG("unknown ignore line?");
+ }
+ }
+ }
+ &performStrictReply("END of ignore.");
+
+ return;
+ }
+
+ # useradd/userdel.
+ if ( $message =~ /^(useradd|userdel)(\s+(.*))?$/i ) {
+ my $cmd = $1;
+ my @args = split /\s+/, $3 || '';
+ my $args = $3;
+ my $state = ( $cmd eq "useradd" ) ? 1 : 0;
+
+ if ( !scalar @args ) {
+ &help($cmd);
+ return;
+ }
+
+ if ( $cmd eq 'useradd' ) {
+ if ( scalar @args != 2 ) {
+ &performStrictReply('useradd requires hostmask argument.');
+ return;
+ }
+ }
+ elsif ( scalar @args != 1 ) {
+ &performStrictReply('too many arguments.');
+ return;
+ }
+
+ if ($state) {
+
+ # adduser.
+ if ( scalar @args == 1 ) {
+ $args[1] = &getHostMask( $args[0] );
+ &performStrictReply(
+ "Attemping to guess $args[0]'s hostmask...");
+
+ # crude hack... crappy Net::IRC
+ $conn->schedule(
+ 5,
+ sub {
+
+ # hopefully this is right.
+ my $nick = ( keys %{ $cache{nuhInfo} } )[0];
+ if ( !defined $nick ) {
+ &performStrictReply(
+"couldn't get nuhinfo... adding user without a hostmask."
+ );
+ &userAdd($nick);
+ return;
+ }
+ my $mask = &makeHostMask( $cache{nuhInfo}{$nick}{NUH} );
+
+ if ( &userAdd( $nick, $mask ) ) {
+
+ # success.
+ &performStrictReply(
+ "Added $nick with flags $users{$nick}{FLAGS}");
+ my @hosts = keys %{ $users{$nick}{HOSTS} };
+ &performStrictReply("hosts: @hosts");
+ }
+ }
+ );
+ return;
+ }
+
+ &DEBUG("args => @args");
+ if ( &userAdd(@args) ) { # success.
+ &performStrictReply(
+ "Added $args[0] with flags $users{$args[0]}{FLAGS}");
+ my @hosts = keys %{ $users{ $args[0] }{HOSTS} };
+ &performStrictReply("hosts: @hosts");
+
+ }
+ else { # failure.
+ &performStrictReply("User $args[0] already exists");
+ }
+
+ }
+ else { # deluser.
+
+ if ( &userDel( $args[0] ) ) { # success.
+ &performStrictReply("Deleted $args[0] successfully.");
+
+ }
+ else { # failure.
+ &performStrictReply("User $args[0] does not exist.");
+ }
+
+ }
+ return;
+ }
+
+ if ( $message =~ /^sched$/ ) {
+ my @list;
+ my @run;
+
+ my %time;
+ foreach ( keys %sched ) {
+ next unless ( exists $sched{$_}{TIME} );
+ $time{ $sched{$_}{TIME} - time() }{$_} = 1;
+ push( @list, $_ );
+
+ next unless ( exists $sched{$_}{RUNNING} );
+ push( @run, $_ );
+ }
+
+ my @time;
+ foreach ( sort { $a <=> $b } keys %time ) {
+ my $str = join( ', ', sort keys %{ $time{$_} } );
+ &DEBUG("time => $_, str => $str");
+ push( @time, "$str (" . &Time2String($_) . ")" );
+ }
+
+ &performStrictReply( &formListReply( 0, "Schedulers: ", @time ) );
+ &performStrictReply(
+ &formListReply( 0, "Scheds to run: ", sort @list ) );
+ &performStrictReply(
+ &formListReply(
+ 0, "Scheds running(should not happen?) ",
+ sort @run
+ )
+ );
+
+ return;
+ }
+
+ # quite a cool hack: reply in DCC CHAT.
+ $msgType = 'chat' if ( exists $dcc{'CHAT'}{$who} );
+
+ my $done = 0;
+ $done++ if &parseCmdHook($message);
+ $done++ unless ( &Modules() );
+
+ if ($done) {
+ &DEBUG("running non DCC CHAT command inside DCC CHAT!");
+ return;
+ }
+
+ return 'REPLY';