2 # UserDCC.pl: User Commands, DCC CHAT.
4 # Version: v0.2 (20010119)
5 # Created: 20000707 (from UserExtra.pl)
8 if (&IsParam("useStrict")) { use strict; }
16 if ($message =~ /^(exit|quit)$/i) {
17 # do ircII clients support remote close? if so, cool!
18 &status("userDCC: quit called. FIXME");
20 &status("userDCC: after dcc_close!");
26 if ($message =~ /^who$/) {
27 my $count = scalar(keys %{ $dcc{'CHAT'} });
28 my $dccCHAT = $message;
30 &pSReply("Start of who ($count users).");
31 foreach (keys %{ $dcc{'CHAT'} }) {
34 &pSReply("End of who.");
39 ### for those users with enough flags.
41 if ($message =~ /^tellme(\s+(.*))?$/i) {
43 if ($args =~ /^\s*$/) {
48 my $result = &doQuestion($args);
55 if ($message =~ /^4op(\s+($mask{chan}))?$/i) {
56 return unless (&hasFlag("o"));
65 if (!$channels{$chan}{'o'}{$ident}) {
66 &msg($who, "i don't have ops on $chan to do that.");
70 # on non-4mode(<4) servers, this may be exploited.
71 if ($channels{$chan}{'o'}{$who}) {
72 rawout("MODE $chan -o+o-o+o". (" $who" x 4));
74 rawout("MODE $chan +o-o+o-o". (" $who" x 4));
81 if ($message =~ /^backlog(\s+(.*))?$/i) {
82 return unless (&hasFlag("o"));
83 return unless (&hasParam("backlog"));
85 my $max = $param{'backlog'};
90 } elsif ($num !~ /^\d+/) {
91 &msg($who, "error: argument is not positive integer.");
93 } elsif ($num > $max or $num < 0) {
94 &msg($who, "error: argument is out of range (max $max).");
98 &msg($who, "Start of backlog...");
100 sleep 1 if ($_ % 4 == 0 and $_ != 0);
101 $conn->privmsg($who, "[".($_+1)."]: $backlog[$max-$num+$_]");
103 &msg($who, "End of backlog.");
109 if ($message =~ /^dumpvars$/i) {
110 return unless (&hasFlag("o"));
111 return unless (&IsParam("dumpvars"));
113 &status("Dumping all variables...");
120 if ($message =~ /^kick(\s+(\S+)(\s+(\S+))?)?/) {
121 return unless (&hasFlag("o"));
122 my ($nick,$chan) = (lc $2,lc $4);
129 if (&validChan($chan) == 0) {
130 &msg($who,"error: invalid channel \002$chan\002");
134 if (&IsNickInChan($nick,$chan) == 0) {
135 &msg($who,"$nick is not in $chan.");
145 if ($message =~ /^mode(\s+(.*))?$/) {
146 return unless (&hasFlag("n"));
147 my ($chan,$mode) = split /\s+/,$2,2;
154 if (&validChan($chan) == 0) {
155 &msg($who,"error: invalid channel \002$chan\002");
159 if (!$channels{$chan}{o}{$ident}) {
160 &msg($who,"error: don't have ops on \002$chan\002");
170 if ($message =~ /^part(\s+(\S+))?$/i) {
171 return unless (&hasFlag("o"));
174 if ($jchan !~ /^$mask{chan}$/) {
175 &msg($who, "error, invalid chan.");
180 if (!&validChan($jchan)) {
181 &msg($who, "error, I'm not on that chan.");
185 &msg($jchan, "Leaving. (courtesy of $who).");
190 # lobotomy. sometimes we want the bot to be _QUIET_.
191 if ($message =~ /^(lobotomy|bequiet)$/i) {
192 return unless (&hasFlag("o"));
195 &performReply("i'm already lobotomized");
197 &performReply("i have been lobotomized");
205 if ($message =~ /^(unlobotomy|benoisy)$/i) {
206 return unless (&hasFlag("o"));
209 &performReply("i have been unlobotomized, woohoo");
211 delete $cache{lobotomy};
212 # undef $cache{lobotomy}; # ??
214 &performReply("i'm not lobotomized");
221 if ($message =~ /^op(\s+(.*))?$/i) {
222 return unless (&hasFlag("o"));
227 if ($opee =~ /^(\S+)\s+(\S+)$/) {
230 if (!&validChan($2)) {
231 &msg($who,"error: invalid chan ($2).");
235 &msg($who,"error: invalid params.");
239 @chans = keys %channels;
245 next unless (&IsNickInChan($opee,$_));
247 if ($channels{$_}{'o'}{$opee}) {
248 &pSReply("op: $opee already has ops on $_");
253 &pSReply("opping $opee on $_");
258 &pSReply("op: opped on all possible channels.");
260 &DEBUG("op: found => '$found'.");
261 &DEBUG("op: op => '$op'.");
268 if ($message =~ /^deop(\s+(.*))?$/i) {
269 return unless (&hasFlag("o"));
274 if ($opee =~ /^(\S+)\s+(\S+)$/) {
277 if (!&validChan($2)) {
278 &msg($who,"error: invalid chan ($2).");
282 &msg($who,"error: invalid params.");
286 @chans = keys %channels;
292 next unless (&IsNickInChan($opee,$_));
294 if (!exists $channels{$_}{'o'}{$opee}) {
295 &status("deop: $opee already has no ops on $_");
300 &status("deopping $opee on $_ at ${who}'s request");
305 &status("deop: deopped on all possible channels.");
307 &DEBUG("deop: found => '$found'.");
308 &DEBUG("deop: op => '$op'.");
315 if ($message =~ s/^say\s+(\S+)\s+(.*)//) {
316 return unless (&hasFlag("o"));
317 my ($chan,$msg) = (lc $1, $2);
318 &DEBUG("chan => '$1', msg => '$msg'.");
320 if (&validChan($chan)) {
323 &msg($who,"i'm not on \002$1\002, sorry.");
329 if ($message =~ /^die$/) {
330 return unless (&hasFlag("n"));
334 &status("Dying by $who\'s request");
338 # global factoid substitution.
339 if ($message =~ m|^s([/,#])(.+?)\1(.*?)\1;?\s*$|) {
340 my ($delim,$op,$np) = ($1, $2, $3);
341 return unless (&hasFlag("n"));
342 ### TODO: support flags to do full-on global.
345 if ($np =~ /$delim/) {
346 &performReply("looks like you used the delimiter too many times. You may want to use a different delimiter, like ':' or '#'.");
350 ### TODO: fix up $op to support mysql/pgsql/dbm(perl)
351 ### TODO: => add db/sql specific function to fix this.
352 my @list = &searchTable("factoids", "factoid_key",
353 "factoid_value", $op);
356 &performReply("Expression didn't match anything.");
360 if (scalar @list > 100) {
361 &performReply("regex found more than 100 matches... not doing.");
365 &status("gsubst: going to alter ".scalar(@list)." factoids.");
366 &performReply("going to alter ".scalar(@list)." factoids.");
372 next if (&IsLocked($faqtoid) == 1);
373 my $result = &getFactoid($faqtoid);
375 &DEBUG("was($faqtoid) => '$was'.");
378 # we could support global local (once off).
379 if ($result =~ s/\Q$op/$np/gi) {
380 if (length $result > $param{'maxDataSize'}) {
381 &performReply("that's too long (or was long)");
384 &setFactInfo($faqtoid, "factoid_value", $result);
385 &status("update: '$faqtoid' =is=> '$result'; was '$was'");
387 &WARN("subst: that's weird... thought we found the string ($op) in '$faqtoid'.");
393 &ERROR("Some warnings/errors?");
396 &performReply("Ok... did s/$op/$np/ for ".
397 (scalar(@list) - $error)." factoids");
403 if ($message =~ /^jump(\s+(\S+))?$/i) {
404 return unless (&hasFlag("n"));
412 if ($2 =~ /^(\S+)(:(\d+))?$/) {
416 &msg($who,"invalid format.");
420 &status("jumping servers... $server...");
421 &rawout("QUIT :jumping to $server");
423 if (&irc($server,$port) == 0) {
429 if ($message =~ /^reload$/i) {
430 return unless (&hasFlag("n"));
432 &status("USER reload $who");
433 &pSReply("reloading...");
435 &pSReply("reloaded.");
441 if ($message =~ /^reset$/i) {
442 return unless (&hasFlag("n"));
444 &msg($who,"resetting...");
446 foreach ( keys %channels, keys %chanconf ) {
447 next if (grep /^\Q$_\E$/i, @done);
457 &status("USER reset $who");
458 &msg($who,"resetted");
464 if ($message =~ /^rehash$/) {
465 return unless (&hasFlag("n"));
467 &msg($who,"rehashing...");
469 &status("USER rehash $who");
470 &msg($who,"rehashed");
476 ##### USER//CHAN SPECIFIC CONFIGURATION COMMANDS
479 if ($message =~ /^chaninfo(\s+(.*))?$/) {
480 my @args = split /[\s\t]+/, $2; # hrm.
482 if (scalar @args != 1) {
487 if (!exists $chanconf{$args[0]}) {
488 &pSReply("no such channel $args[0]");
492 &pSReply("showing channel conf.");
493 foreach (sort keys %{ $chanconf{$args[0]} }) {
494 &pSReply("$chan: $_ => $chanconf{$args[0]}{$_}");
496 &pSReply("End of chaninfo.");
502 if ($message =~ /^(chanset|\+chan)(\s+(.*?))?$/) {
507 if (!defined $args) {
513 while ($args =~ s/^($mask{chan})\s*//) {
517 if (!scalar @chans) {
518 push(@chans, "_default");
522 my($what,$val) = split /[\s\t]+/, $args, 2;
524 ### TODO: "cannot set values without +m".
525 return unless (&hasFlag("n"));
528 if (defined $what and $what !~ /^[-+]/ and !defined $val and $no_chan) {
529 &pSReply("Showing $what values on all channels...");
532 foreach (keys %chanconf) {
533 my $val = $chanconf{$_}{$what} || "NOT-SET";
537 foreach (keys %vals) {
538 &pSReply(" $what = $_: ".join(' ', keys %{ $vals{$_} } ) );
541 &pSReply("End of list.");
546 ### TODO: move to UserDCC again.
547 if ($cmd eq "chanset" and !defined $what) {
548 &DEBUG("showing channel conf.");
550 foreach $chan ($chan, "_default") {
551 &pSReply("chan: $chan");
552 ### TODO: merge 2 or 3 per line.
555 foreach (sort keys %{ $chanconf{$chan} }) {
556 my $newstr = join(', ', @items);
557 if (length $newstr > 60) {
562 push(@items, "$_ => $chanconf{$chan}{$_}");
564 &pSReply(" $str") if (@items);
569 $cache{confvars}{$what} = $val;
573 &chanSet($cmd, $_, $what, $val);
579 if ($message =~ /^(chanunset|\-chan)(\s+(.*))?$/) {
580 return unless (&hasFlag("n"));
584 if (!defined $args) {
591 if ($args =~ s/^(\-)?($mask{chan})\s*//) {
593 $delete = ($1) ? 1 : 0;
594 &DEBUG("chan => $chan.");
596 &VERB("no chan arg; setting to default.",2);
601 if (!exists $chanconf{$chan}) {
602 &pSReply("no such channel $chan");
608 if (!&getChanConf($args,$chan)) {
609 &pSReply("$args does not exist for $chan");
613 my @chans = &ChanConfList($args);
614 &DEBUG("scalar chans => ".scalar(@chans) );
615 if (scalar @chans == 1 and $chans[0] eq "_default" and !$no_chan) {
616 &psReply("ok, $args was set only for _default; unsetting for _defaul but setting for other chans.");
618 my $val = $chanconf{$_}{_default};
619 foreach (keys %chanconf) {
620 $chanconf{$_}{$args} = $val;
622 delete $chanconf{_default}{$args};
623 $cache{confvars}{$args} = 0;
629 if ($no_chan and !exists($chanconf{_default}{$args})) {
630 &pSReply("ok, $args for _default does not exist, removing from all chans.");
632 foreach (keys %chanconf) {
633 next unless (exists $chanconf{$_}{$args});
634 &DEBUG("delete chanconf{$_}{$args};");
635 delete $chanconf{$_}{$args};
637 $cache{confvars}{$args} = 0;
643 &pSReply("Unsetting channel ($chan) option $args. (was $chanconf{$chan}{$args})");
644 delete $chanconf{$chan}{$args};
650 &pSReply("Deleting channel $chan for sure!");
651 $utime_chanfile = time();
655 &pSReply("Leaving $chan...");
657 delete $chanconf{$chan};
659 &pSReply("Prefix channel with '-' to delete for sure.");
665 if ($message =~ /^newpass(\s+(.*))?$/) {
666 my(@args) = split /[\s\t]+/, $2 || '';
668 if (scalar @args != 1) {
673 my $u = &getUser($who);
674 my $crypt = &mkcrypt($args[0]);
676 &pSReply("Set your passwd to '$crypt'");
677 $users{$u}{PASS} = $crypt;
679 $utime_userfile = time();
685 if ($message =~ /^chpass(\s+(.*))?$/) {
686 my(@args) = split /[\s\t]+/, $2 || '';
693 if (!&IsUser($args[0])) {
694 &pSReply("user $args[0] is not valid.");
698 my $u = &getUser($args[0]);
700 &pSReply("Internal error, u = NULL.");
704 if (scalar @args == 1) { # del pass.
705 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
706 &pSReply("cannot remove passwd of others.");
710 if (!exists $users{$u}{PASS}) {
711 &pSReply("$u does not have pass set anyway.");
715 &pSReply("Deleted pass from $u.");
717 $utime_userfile = time();
720 delete $users{$u}{PASS};
725 my $crypt = &mkcrypt($args[1]);
726 &pSReply("Set $u's passwd to '$crypt'");
727 $users{$u}{PASS} = $crypt;
729 $utime_userfile = time();
735 if ($message =~ /^chattr(\s+(.*))?$/) {
736 my(@args) = split /[\s\t]+/, $2 || '';
744 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
745 $user = &getUser($args[0]);
748 $user = &getUser($who);
749 &DEBUG("user $who... nope.") unless (defined $user);
750 $user = &getUser($verifyUser);
754 if (!defined $user) {
755 &pSReply("user does not exist.");
759 my $flags = $users{$user}{FLAGS};
760 if (!defined $chflag) {
761 &pSReply("Flags for $user: $flags");
765 &DEBUG("who => $who");
766 &DEBUG("verifyUser => $verifyUser");
767 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
768 &pSReply("cannto change attributes of others.");
774 foreach (split //, $chflag) {
775 if ($_ eq "+") { $state = 1; next; }
776 if ($_ eq "-") { $state = 0; next; }
778 if (!defined $state) {
779 &pSReply("no initial + or - was found in attr.");
784 next if ($flags =~ /\Q$_\E/);
787 if (&IsParam("owner")
788 and $param{owner} =~ /^\Q$user\E$/i
789 and $flags =~ /[nmo]/
791 &pSReply("not removing flag $_ for $user.");
794 next unless ($flags =~ s/\Q$_\E//);
801 $utime_userfile = time();
803 &pSReply("Current flags: $flags");
804 $users{$user}{FLAGS} = $flags;
806 &pSReply("No flags changed: $flags");
812 if ($message =~ /^chnick(\s+(.*))?$/) {
813 my(@args) = split /[\s\t]+/, $2 || '';
815 if ($who eq "_default") {
816 &WARN("$who or verifyuser tried to run chnick.");
820 if (!scalar @args or scalar @args > 2) {
825 if (scalar @args == 1) { # 1
826 $user = &getUser($who);
827 &DEBUG("nope, not $who.") unless (defined $user);
828 $user ||= &getUser($verifyUser);
831 $user = &getUser($args[0]);
835 if (!defined $user) {
836 &pSReply("user $who or $args[0] does not exist.");
840 if ($user =~ /^\Q$chnick\E$/i) {
841 &pSReply("user == chnick. why should I do that?");
845 if (&getUser($chnick)) {
846 &pSReply("user $chnick is already used!");
850 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
851 &pSReply("cannto change nick of others.");
852 return "REPLY" if ($who eq "_default");
856 foreach (keys %{ $users{$user} }) {
857 $users{$chnick}{$_} = $users{$user}{$_};
858 delete $users{$user}{$_};
860 undef $users{$user}; # ???
862 $utime_userfile = time();
865 &pSReply("Changed '$user' to '$chnick' successfully.");
870 if ($message =~ /^([-+])host(\s+(.*))?$/) {
872 my(@args) = split /[\s\t]+/, $3 || '';
873 my $state = ($1 eq "+") ? 1 : 0;
880 if ($who eq "_default") {
881 &WARN("$who or verifyuser tried to run $cmd.");
886 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
887 return unless (&hasFlag("n"));
888 $user = &getUser($args[0]);
891 # who or verifyUser. FIXME!!!
892 $user = &getUser($who);
896 if (!defined $user) {
897 &pSReply("user $user does not exist.");
901 if (!defined $mask) {
903 &pSReply("Hostmasks for $user: $users{$user}{HOSTS}");
908 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
909 &pSReply("cannto change masks of others.");
913 if ($mask !~ /^$mask{nuh}$/) {
914 &pSReply("error: mask ($mask) is not a real hostmask.");
918 my $count = scalar keys %{ $users{$user}{HOSTS} };
921 if (exists $users{$user}{HOSTS}{$mask}) {
922 &pSReply("mask $mask already exists.");
926 ### TODO: override support.
927 $users{$user}{HOSTS}{$mask} = 1;
929 &pSReply("Added $mask to list of masks.");
933 if (!exists $users{$user}{HOSTS}{$mask}) {
934 &pSReply("mask $mask does not exist.");
938 ### TODO: wildcard support. ?
939 delete $users{$user}{HOSTS}{$mask};
941 if (scalar keys %{ $users{$user}{HOSTS} } != $count) {
942 &pSReply("Removed $mask from list of masks.");
944 &pSReply("error: could not find $mask in list of masks.");
949 $utime_userfile = time();
955 if ($message =~ /^([-+])ban(\s+(.*))?$/) {
958 my(@args) = split /[\s\t]+/, $3 || '';
959 my $state = ($1 eq "+") ? 1 : 0;
966 my($mask,$chan,$time,$reason);
968 if ($flatarg =~ s/^($mask{nuh})\s*//) {
971 &DEBUG("arg does not contain nuh mask?");
974 if ($flatarg =~ s/^($mask{chan})\s*//) {
977 $chan = "*"; # _default instead?
980 if ($state == 0) { # delete.
981 my @c = &banDel($mask);
988 &pSReply("Removed $mask from chans: @c");
990 &pSReply("$mask was not found in ban list.");
1001 if ($flatarg =~ s/^(\d+)\s*//) {
1003 &DEBUG("time = $time.");
1005 &pSReply("error: time cannot be negatime?");
1012 if ($flatarg =~ s/^(.*)$//) { # need length?
1016 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
1017 &pSReply("cannto change masks of others.");
1021 if ($mask !~ /^$mask{nuh}$/) {
1022 &pSReply("error: mask ($mask) is not a real hostmask.");
1026 if ( &banAdd($mask,$chan,$time,$reason) == 2) {
1027 &pSReply("ban already exists; overwriting.");
1029 &pSReply("Added $mask for $chan (time => $time, reason => $reason)");
1034 if ($message =~ /^whois(\s+(.*))?$/) {
1037 if (!defined $arg) {
1042 my $user = &getUser($arg);
1043 if (!defined $user) {
1044 &pSReply("whois: user $user does not exist.");
1048 ### TODO: better (eggdrop-like) output.
1049 &pSReply("user: $user");
1050 foreach (keys %{ $users{$user} }) {
1051 my $ref = ref $users{$user}{$_};
1053 if ($ref eq "HASH") {
1055 ### DOES NOT WORK???
1056 foreach (keys %{ $users{$user}{$type} }) {
1057 &pSReply(" $type => $_");
1062 &pSReply(" $_ => $users{$user}{$_}");
1064 &pSReply("End of USER whois.");
1069 if ($message =~ /^bans(\s+(.*))?$/) {
1073 if ($arg ne "_default" and !&validChan($arg) ) {
1074 &pSReply("error: chan $chan is invalid.");
1079 if (!scalar keys %bans) {
1080 &pSReply("Ban list is empty.");
1085 &pSReply(" mask: expire, time-added, count, who-by, reason");
1086 foreach $c (keys %bans) {
1087 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1090 foreach (keys %{ $bans{$c} }) {
1091 my $val = $bans{$c}{$_};
1093 if (ref $val eq "ARRAY") {
1094 my @array = @{ $val };
1095 &pSReply(" $_: @array");
1097 &DEBUG("unknown ban: $val");
1101 &pSReply("END of bans.");
1106 if ($message =~ /^banlist(\s+(.*))?$/) {
1109 if (defined $arg and $arg !~ /^$mask_chan$/) {
1110 &pSReply("error: chan $chan is invalid.");
1114 &DEBUG("bans for global or arg => $arg.");
1115 foreach (keys %bans) { #CHANGE!!!
1116 &DEBUG(" $_ => $bans{$_}.");
1119 &DEBUG("End of bans.");
1120 &pSReply("END of bans.");
1125 if ($message =~ /^save$/) {
1126 return unless (&hasFlag("o"));
1130 &News::writeNews() if (&ChanConfList("news"));
1136 $message =~ s/^addignore/+ignore/;
1137 $message =~ s/^(del|un)ignore/-ignore/;
1140 if ($message =~ /^(\+|\-)ignore(\s+(.*))?$/i) {
1141 return unless (&hasFlag("o"));
1142 my $state = ($1 eq "+") ? 1 : 0;
1143 my $str = $1."ignore";
1151 my($mask,$chan,$time,$comment);
1154 if ($args =~ s/^($mask{nuh})\s*//) {
1157 &ERROR("no NUH mask?");
1161 if (!$state) { # delignore.
1162 if ( &ignoreDel($mask) ) {
1163 &pSReply("ok, deleted X ignores.");
1165 &pSReply("could not find $mask in ignore list.");
1175 if ($args =~ s/^($mask{chan}|\*)\s*//) {
1182 if ($args =~ s/^(\d+)\s*//) {
1192 $comment = "added by $who";
1195 if ( &ignoreAdd($mask, $chan, $time, $comment) > 1) {
1196 &pSReply("warn: $mask already in ignore list; written over anyway. FIXME");
1198 &pSReply("added $mask to ignore list.");
1204 if ($message =~ /^ignore(\s+(.*))?$/) {
1208 if ($arg !~ /^$mask{chan}$/) {
1209 &pSReply("error: chan $chan is invalid.");
1213 if (!&validChan($arg)) {
1214 &pSReply("error: chan $arg is invalid.");
1218 &pSReply("Showing bans for $arg only.");
1221 if (!scalar keys %ignore) {
1222 &pSReply("Ignore list is empty.");
1226 ### TODO: proper (eggdrop-like) formatting.
1228 &pSReply(" mask: expire, time-added, who, comment");
1229 foreach $c (keys %ignore) {
1230 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1233 foreach (keys %{ $ignore{$c} }) {
1234 my $ref = ref $ignore{$c}{$_};
1235 if ($ref eq "ARRAY") {
1236 my @array = @{ $ignore{$c}{$_} };
1237 &pSReply(" $_: @array");
1239 &DEBUG("unknown ignore line?");
1243 &pSReply("END of ignore.");
1249 if ($message =~ /^(\+|\-|add|del)user(\s+(.*))?$/i) {
1251 my $strstr = $1."user";
1252 my @args = split /\s+/, $3 || '';
1254 my $state = ($str =~ /^(\+|add)$/) ? 1 : 0;
1256 if (!scalar @args) {
1262 if (scalar @args != 2) {
1263 &pSReply(".+host requires hostmask argument.");
1266 } elsif (scalar @args != 1) {
1267 &pSReply("too many arguments.");
1271 if ($state) { # adduser.
1272 if (scalar @args == 1) {
1273 $args[1] = &getHostMask($args[0]);
1274 &pSReply("Attemping to guess $args[0]'s hostmask...");
1276 # crude hack... crappy Net::IRC
1277 $conn->schedule(5, sub {
1278 # hopefully this is right.
1279 my $nick = (keys %{ $cache{nuhInfo} })[0];
1280 if (!defined $nick) {
1281 &pSReply("couldn't get nuhinfo... adding user without a hostmask.");
1286 my $mask = &makeHostMask( $cache{nuhInfo}{$nick}{NUH} );
1288 if ( &userAdd($nick, $mask) ) { # success.
1289 &pSReply("Added $nick with flags $users{$nick}{FLAGS}");
1290 my @hosts = keys %{ $users{$nick}{HOSTS} };
1291 &pSReply("hosts: @hosts");
1297 &DEBUG("args => @args");
1298 if ( &userAdd(@args) ) { # success.
1299 &pSReply("Added $args[0] with flags $users{$args[0]}{FLAGS}");
1300 my @hosts = keys %{ $users{$args[0]}{HOSTS} };
1301 &pSReply("hosts: @hosts");
1304 &pSReply("User $args[0] already exists");
1309 if ( &userDel($args[0]) ) { # success.
1310 &pSReply("Deleted $args[0] successfully.");
1313 &pSReply("User $args[0] does not exist.");
1320 if ($message =~ /^sched$/) {
1325 foreach (keys %sched) {
1326 next unless (exists $sched{$_}{TIME});
1327 $time{ $sched{$_}{TIME}-time() }{$_} = 1;
1330 next unless (exists $sched{$_}{RUNNING});
1335 foreach (sort { $a <=> $b } keys %time) {
1336 my $str = join(", ", sort keys %{ $time{$_} });
1337 &DEBUG("time => $_, str => $str");
1338 push(@time, "$str (".&Time2String($_).")");
1341 &pSReply( &formListReply(0, "Schedulers: ", @time ) );
1342 &pSReply( &formListReply(0, "Scheds to run: ", sort @list ) );
1343 &pSReply( &formListReply(0, "Scheds running(should not happen?) ", sort @run ) );
1348 # quite a cool hack: reply in DCC CHAT.
1352 $done++ if &parseCmdHook("main", $message);
1353 $done++ if &parseCmdHook("extra", $message);
1354 $done++ unless (&Modules());
1357 &DEBUG("running non DCC CHAT command inside DCC CHAT!");