2 # UserDCC.pl: User Commands, DCC CHAT.
4 # Version: v0.2 (20010119)
5 # Created: 20000707 (from UserExtra.pl)
10 use vars qw(%users %ignore %sched %bans %mask %cache %channels %param
12 use vars qw($who $chan $message $msgType $user $chnick $conn $ident
13 $verifyUser $ucount_userfile $utime_userfile $lobotomized
14 $utime_chanfile $ucount_chanfile);
15 use vars qw(@backlog);
23 if ($message =~ /^(exit|quit)$/i) {
24 # do ircII clients support remote close? if so, cool!
25 &status("userDCC: quit called. FIXME");
27 &status("userDCC: after dcc_close!");
33 if ($message =~ /^who$/) {
34 my $count = scalar(keys %{ $dcc{'CHAT'} });
35 my $dccCHAT = $message;
37 &pSReply("Start of who ($count users).");
38 foreach (keys %{ $dcc{'CHAT'} }) {
41 &pSReply("End of who.");
46 ### for those users with enough flags.
48 if ($message =~ /^tellme(\s+(.*))?$/i) {
50 if ($args =~ /^\s*$/) {
55 my $result = &doQuestion($args);
62 if ($message =~ /^4op(\s+($mask{chan}))?$/i) {
63 return unless (&hasFlag("o"));
72 if (!$channels{$chan}{'o'}{$ident}) {
73 &msg($who, "i don't have ops on $chan to do that.");
77 # on non-4mode(<4) servers, this may be exploited.
78 if ($channels{$chan}{'o'}{$who}) {
79 rawout("MODE $chan -o+o-o+o". (" $who" x 4));
81 rawout("MODE $chan +o-o+o-o". (" $who" x 4));
88 if ($message =~ /^backlog(\s+(.*))?$/i) {
89 return unless (&hasFlag("o"));
90 return unless (&hasParam("backlog"));
92 my $max = $param{'backlog'};
97 } elsif ($num !~ /^\d+/) {
98 &msg($who, "error: argument is not positive integer.");
100 } elsif ($num > $max or $num < 0) {
101 &msg($who, "error: argument is out of range (max $max).");
105 &msg($who, "Start of backlog...");
107 sleep 1 if ($_ % 4 == 0 and $_ != 0);
108 $conn->privmsg($who, "[".($_+1)."]: $backlog[$max-$num+$_]");
110 &msg($who, "End of backlog.");
116 if ($message =~ /^dumpvars$/i) {
117 return unless (&hasFlag("o"));
118 return unless (&IsParam("dumpvars"));
120 &status("Dumping all variables...");
127 if ($message =~ /^symdump$/i) {
128 return unless (&hasFlag("o"));
129 return unless (&IsParam("symdump"));
131 &status("Dumping all variables...");
138 if ($message =~ /^kick(\s+(\S+)(\s+(\S+))?)?/) {
139 return unless (&hasFlag("o"));
140 my ($nick,$chan) = (lc $2,lc $4);
147 if (&validChan($chan) == 0) {
148 &msg($who,"error: invalid channel \002$chan\002");
152 if (&IsNickInChan($nick,$chan) == 0) {
153 &msg($who,"$nick is not in $chan.");
163 if ($message =~ /^mode(\s+(.*))?$/) {
164 return unless (&hasFlag("n"));
165 my ($chan,$mode) = split /\s+/,$2,2;
172 if (&validChan($chan) == 0) {
173 &msg($who,"error: invalid channel \002$chan\002");
177 if (!$channels{$chan}{o}{$ident}) {
178 &msg($who,"error: don't have ops on \002$chan\002");
188 if ($message =~ /^part(\s+(\S+))?$/i) {
189 return unless (&hasFlag("o"));
192 if ($jchan !~ /^$mask{chan}$/) {
193 &msg($who, "error, invalid chan.");
198 if (!&validChan($jchan)) {
199 &msg($who, "error, I'm not on that chan.");
203 &msg($jchan, "Leaving. (courtesy of $who).");
208 # lobotomy. sometimes we want the bot to be _QUIET_.
209 if ($message =~ /^(lobotomy|bequiet)$/i) {
210 return unless (&hasFlag("o"));
213 &performReply("i'm already lobotomized");
215 &performReply("i have been lobotomized");
223 if ($message =~ /^(unlobotomy|benoisy)$/i) {
224 return unless (&hasFlag("o"));
227 &performReply("i have been unlobotomized, woohoo");
229 delete $cache{lobotomy};
230 # undef $cache{lobotomy}; # ??
232 &performReply("i'm not lobotomized");
239 if ($message =~ /^op(\s+(.*))?$/i) {
240 return unless (&hasFlag("o"));
245 if ($opee =~ /^(\S+)\s+(\S+)$/) {
248 if (!&validChan($2)) {
249 &msg($who,"error: invalid chan ($2).");
253 &msg($who,"error: invalid params.");
257 @chans = keys %channels;
263 next unless (&IsNickInChan($opee,$_));
265 if ($channels{$_}{'o'}{$opee}) {
266 &pSReply("op: $opee already has ops on $_");
271 &pSReply("opping $opee on $_");
276 &pSReply("op: opped on all possible channels.");
278 &DEBUG("op: found => '$found'.");
279 &DEBUG("op: op => '$op'.");
286 if ($message =~ /^deop(\s+(.*))?$/i) {
287 return unless (&hasFlag("o"));
292 if ($opee =~ /^(\S+)\s+(\S+)$/) {
295 if (!&validChan($2)) {
296 &msg($who,"error: invalid chan ($2).");
300 &msg($who,"error: invalid params.");
304 @chans = keys %channels;
310 next unless (&IsNickInChan($opee,$_));
312 if (!exists $channels{$_}{'o'}{$opee}) {
313 &status("deop: $opee already has no ops on $_");
318 &status("deopping $opee on $_ at ${who}'s request");
323 &status("deop: deopped on all possible channels.");
325 &DEBUG("deop: found => '$found'.");
326 &DEBUG("deop: op => '$op'.");
333 if ($message =~ s/^say\s+(\S+)\s+(.*)//) {
334 return unless (&hasFlag("o"));
335 my ($chan,$msg) = (lc $1, $2);
336 &DEBUG("chan => '$1', msg => '$msg'.");
338 if (&validChan($chan)) {
341 &msg($who,"i'm not on \002$1\002, sorry.");
347 if ($message =~ /^die$/) {
348 return unless (&hasFlag("n"));
352 &status("Dying by $who\'s request");
356 # global factoid substitution.
357 if ($message =~ m|^s([/,#])(.+?)\1(.*?)\1;?\s*$|) {
358 my ($delim,$op,$np) = ($1, $2, $3);
359 return unless (&hasFlag("n"));
360 ### TODO: support flags to do full-on global.
363 if ($np =~ /$delim/) {
364 &performReply("looks like you used the delimiter too many times. You may want to use a different delimiter, like ':' or '#'.");
368 ### TODO: fix up $op to support mysql/sqlite/pgsql/dbm(perl)
369 ### TODO: => add db/sql specific function to fix this.
370 my @list = &searchTable("factoids", "factoid_key",
371 "factoid_value", $op);
374 &performReply("Expression didn't match anything.");
378 if (scalar @list > 100) {
379 &performReply("regex found more than 100 matches... not doing.");
383 &status("gsubst: going to alter ".scalar(@list)." factoids.");
384 &performReply("going to alter ".scalar(@list)." factoids.");
390 next if (&IsLocked($faqtoid) == 1);
391 my $result = &getFactoid($faqtoid);
393 &DEBUG("was($faqtoid) => '$was'.");
396 # we could support global local (once off).
397 if ($result =~ s/\Q$op/$np/gi) {
398 if (length $result > $param{'maxDataSize'}) {
399 &performReply("that's too long (or was long)");
402 &setFactInfo($faqtoid, "factoid_value", $result);
403 &status("update: '$faqtoid' =is=> '$result'; was '$was'");
405 &WARN("subst: that's weird... thought we found the string ($op) in '$faqtoid'.");
411 &ERROR("Some warnings/errors?");
414 &performReply("Ok... did s/$op/$np/ for ".
415 (scalar(@list) - $error)." factoids");
421 if ($message =~ /^jump(\s+(\S+))?$/i) {
422 return unless (&hasFlag("n"));
430 if ($2 =~ /^(\S+)(:(\d+))?$/) {
434 &msg($who,"invalid format.");
438 &status("jumping servers... $server...");
439 $conn->quit("jumping to $server");
441 if (&irc($server,$port) == 0) {
447 if ($message =~ /^reload$/i) {
448 return unless (&hasFlag("n"));
450 &status("USER reload $who");
451 &pSReply("reloading...");
453 &pSReply("reloaded.");
459 if ($message =~ /^reset$/i) {
460 return unless (&hasFlag("n"));
462 &msg($who,"resetting...");
464 foreach ( keys %channels, keys %chanconf ) {
466 next if (grep /^\Q$c\E$/i, @done);
473 &DEBUG("before clearircvars");
475 &DEBUG("before joinnextchan");
477 &DEBUG("after joinnextchan");
479 &status("USER reset $who");
480 &msg($who,"resetted");
486 if ($message =~ /^rehash$/) {
487 return unless (&hasFlag("n"));
489 &msg($who,"rehashing...");
491 &status("USER rehash $who");
492 &msg($who,"rehashed");
498 ##### USER//CHAN SPECIFIC CONFIGURATION COMMANDS
501 if ($message =~ /^chaninfo(\s+(.*))?$/) {
502 my @args = split /[\s\t]+/, $2; # hrm.
504 if (scalar @args != 1) {
509 if (!exists $chanconf{$args[0]}) {
510 &pSReply("no such channel $args[0]");
514 &pSReply("showing channel conf.");
515 foreach (sort keys %{ $chanconf{$args[0]} }) {
516 &pSReply("$chan: $_ => $chanconf{$args[0]}{$_}");
518 &pSReply("End of chaninfo.");
524 if ($message =~ /^(chanset|\+chan)(\s+(.*?))?$/) {
529 if (!defined $args) {
535 while ($args =~ s/^($mask{chan})\s*//) {
539 if (!scalar @chans) {
540 push(@chans, "_default");
544 my($what,$val) = split /[\s\t]+/, $args, 2;
546 ### TODO: "cannot set values without +m".
547 return unless (&hasFlag("n"));
550 if (defined $what and $what !~ /^[-+]/ and !defined $val and $no_chan) {
551 &pSReply("Showing $what values on all channels...");
554 foreach (keys %chanconf) {
555 my $val = $chanconf{$_}{$what} || "NOT-SET";
559 foreach (keys %vals) {
560 &pSReply(" $what = $_: ".join(' ', keys %{ $vals{$_} } ) );
563 &pSReply("End of list.");
568 ### TODO: move to UserDCC again.
569 if ($cmd eq "chanset" and !defined $what) {
570 &DEBUG("showing channel conf.");
572 foreach $chan ($chan, "_default") {
573 &pSReply("chan: $chan");
574 ### TODO: merge 2 or 3 per line.
577 foreach (sort keys %{ $chanconf{$chan} }) {
578 my $newstr = join(', ', @items);
579 if (length $newstr > 60) {
584 push(@items, "$_ => $chanconf{$chan}{$_}");
586 &pSReply(" $str") if (@items);
591 $cache{confvars}{$what} = $val;
595 &chanSet($cmd, $_, $what, $val);
601 if ($message =~ /^(chanunset|\-chan)(\s+(.*))?$/) {
602 return unless (&hasFlag("n"));
606 if (!defined $args) {
613 if ($args =~ s/^(\-)?($mask{chan})\s*//) {
615 $delete = ($1) ? 1 : 0;
616 &DEBUG("chan => $chan.");
618 &VERB("no chan arg; setting to default.",2);
623 if (!exists $chanconf{$chan}) {
624 &pSReply("no such channel $chan");
630 if (!&getChanConf($args,$chan)) {
631 &pSReply("$args does not exist for $chan");
635 my @chans = &ChanConfList($args);
636 &DEBUG("scalar chans => ".scalar(@chans) );
637 if (scalar @chans == 1 and $chans[0] eq "_default" and !$no_chan) {
638 &psReply("ok, $args was set only for _default; unsetting for _defaul but setting for other chans.");
640 my $val = $chanconf{$_}{_default};
641 foreach (keys %chanconf) {
642 $chanconf{$_}{$args} = $val;
644 delete $chanconf{_default}{$args};
645 $cache{confvars}{$args} = 0;
651 if ($no_chan and !exists($chanconf{_default}{$args})) {
652 &pSReply("ok, $args for _default does not exist, removing from all chans.");
654 foreach (keys %chanconf) {
655 next unless (exists $chanconf{$_}{$args});
656 &DEBUG("delete chanconf{$_}{$args};");
657 delete $chanconf{$_}{$args};
659 $cache{confvars}{$args} = 0;
665 &pSReply("Unsetting channel ($chan) option $args. (was $chanconf{$chan}{$args})");
666 delete $chanconf{$chan}{$args};
672 &pSReply("Deleting channel $chan for sure!");
673 $utime_chanfile = time();
677 &pSReply("Leaving $chan...");
679 delete $chanconf{$chan};
681 &pSReply("Prefix channel with '-' to delete for sure.");
687 if ($message =~ /^newpass(\s+(.*))?$/) {
688 my(@args) = split /[\s\t]+/, $2 || '';
690 if (scalar @args != 1) {
695 my $u = &getUser($who);
696 my $crypt = &mkcrypt($args[0]);
698 &pSReply("Set your passwd to '$crypt'");
699 $users{$u}{PASS} = $crypt;
701 $utime_userfile = time();
707 if ($message =~ /^chpass(\s+(.*))?$/) {
708 my(@args) = split /[\s\t]+/, $2 || '';
715 if (!&IsUser($args[0])) {
716 &pSReply("user $args[0] is not valid.");
720 my $u = &getUser($args[0]);
722 &pSReply("Internal error, u = NULL.");
726 if (scalar @args == 1) { # del pass.
727 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
728 &pSReply("cannot remove passwd of others.");
732 if (!exists $users{$u}{PASS}) {
733 &pSReply("$u does not have pass set anyway.");
737 &pSReply("Deleted pass from $u.");
739 $utime_userfile = time();
742 delete $users{$u}{PASS};
747 my $crypt = &mkcrypt($args[1]);
748 &pSReply("Set $u's passwd to '$crypt'");
749 $users{$u}{PASS} = $crypt;
751 $utime_userfile = time();
757 if ($message =~ /^chattr(\s+(.*))?$/) {
758 my(@args) = split /[\s\t]+/, $2 || '';
767 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
768 $user = &getUser($args[0]);
771 $user = &getUser($who);
772 &DEBUG("user $who... nope.") unless (defined $user);
773 $user = &getUser($verifyUser);
777 if (!defined $user) {
778 &pSReply("user does not exist.");
782 my $flags = $users{$user}{FLAGS};
783 if (!defined $chflag) {
784 &pSReply("Flags for $user: $flags");
788 &DEBUG("who => $who");
789 &DEBUG("verifyUser => $verifyUser");
790 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
791 &pSReply("cannto change attributes of others.");
797 foreach (split //, $chflag) {
798 if ($_ eq "+") { $state = 1; next; }
799 if ($_ eq "-") { $state = 0; next; }
801 if (!defined $state) {
802 &pSReply("no initial + or - was found in attr.");
807 next if ($flags =~ /\Q$_\E/);
810 if (&IsParam("owner")
811 and $param{owner} =~ /^\Q$user\E$/i
812 and $flags =~ /[nmo]/
814 &pSReply("not removing flag $_ for $user.");
817 next unless ($flags =~ s/\Q$_\E//);
824 $utime_userfile = time();
826 &pSReply("Current flags: $flags");
827 $users{$user}{FLAGS} = $flags;
829 &pSReply("No flags changed: $flags");
835 if ($message =~ /^chnick(\s+(.*))?$/) {
836 my(@args) = split /[\s\t]+/, $2 || '';
838 if ($who eq "_default") {
839 &WARN("$who or verifyuser tried to run chnick.");
843 if (!scalar @args or scalar @args > 2) {
848 if (scalar @args == 1) { # 1
849 $user = &getUser($who);
850 &DEBUG("nope, not $who.") unless (defined $user);
851 $user ||= &getUser($verifyUser);
854 $user = &getUser($args[0]);
858 if (!defined $user) {
859 &pSReply("user $who or $args[0] does not exist.");
863 if ($user =~ /^\Q$chnick\E$/i) {
864 &pSReply("user == chnick. why should I do that?");
868 if (&getUser($chnick)) {
869 &pSReply("user $chnick is already used!");
873 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
874 &pSReply("cannto change nick of others.");
875 return "REPLY" if ($who eq "_default");
879 foreach (keys %{ $users{$user} }) {
880 $users{$chnick}{$_} = $users{$user}{$_};
881 delete $users{$user}{$_};
883 undef $users{$user}; # ???
885 $utime_userfile = time();
888 &pSReply("Changed '$user' to '$chnick' successfully.");
893 if ($message =~ /^([-+])host(\s+(.*))?$/) {
895 my(@args) = split /[\s\t]+/, $3 || '';
896 my $state = ($1 eq "+") ? 1 : 0;
903 if ($who eq "_default") {
904 &WARN("$who or verifyuser tried to run $cmd.");
909 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
910 return unless (&hasFlag("n"));
911 $user = &getUser($args[0]);
914 # who or verifyUser. FIXME (don't remember why)
915 $user = &getUser($who);
919 if (!defined $user) {
920 &pSReply("user $user does not exist.");
924 if (!defined $mask) {
926 &pSReply("Hostmasks for $user: $users{$user}{HOSTS}");
931 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
932 &pSReply("cannto change masks of others.");
936 if ($mask !~ /^$mask{nuh}$/) {
937 &pSReply("error: mask ($mask) is not a real hostmask.");
941 my $count = scalar keys %{ $users{$user}{HOSTS} };
944 if (exists $users{$user}{HOSTS}{$mask}) {
945 &pSReply("mask $mask already exists.");
949 ### TODO: override support.
950 $users{$user}{HOSTS}{$mask} = 1;
952 &pSReply("Added $mask to list of masks.");
956 if (!exists $users{$user}{HOSTS}{$mask}) {
957 &pSReply("mask $mask does not exist.");
961 ### TODO: wildcard support. ?
962 delete $users{$user}{HOSTS}{$mask};
964 if (scalar keys %{ $users{$user}{HOSTS} } != $count) {
965 &pSReply("Removed $mask from list of masks.");
967 &pSReply("error: could not find $mask in list of masks.");
972 $utime_userfile = time();
978 if ($message =~ /^([-+])ban(\s+(.*))?$/) {
981 my(@args) = split /[\s\t]+/, $3 || '';
982 my $state = ($1 eq "+") ? 1 : 0;
989 my($mask,$chan,$time,$reason);
991 if ($flatarg =~ s/^($mask{nuh})\s*//) {
994 &DEBUG("arg does not contain nuh mask?");
997 if ($flatarg =~ s/^($mask{chan})\s*//) {
1000 $chan = "*"; # _default instead?
1003 if ($state == 0) { # delete.
1004 my @c = &banDel($mask);
1011 &pSReply("Removed $mask from chans: @c");
1013 &pSReply("$mask was not found in ban list.");
1024 if ($flatarg =~ s/^(\d+)\s*//) {
1026 &DEBUG("time = $time.");
1028 &pSReply("error: time cannot be negatime?");
1035 if ($flatarg =~ s/^(.*)$//) { # need length?
1039 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
1040 &pSReply("cannto change masks of others.");
1044 if ($mask !~ /^$mask{nuh}$/) {
1045 &pSReply("error: mask ($mask) is not a real hostmask.");
1049 if ( &banAdd($mask,$chan,$time,$reason) == 2) {
1050 &pSReply("ban already exists; overwriting.");
1052 &pSReply("Added $mask for $chan (time => $time, reason => $reason)");
1057 if ($message =~ /^whois(\s+(.*))?$/) {
1060 if (!defined $arg) {
1065 my $user = &getUser($arg);
1066 if (!defined $user) {
1067 &pSReply("whois: user $user does not exist.");
1071 ### TODO: better (eggdrop-like) output.
1072 &pSReply("user: $user");
1073 foreach (keys %{ $users{$user} }) {
1074 my $ref = ref $users{$user}{$_};
1076 if ($ref eq "HASH") {
1078 ### DOES NOT WORK???
1079 foreach (keys %{ $users{$user}{$type} }) {
1080 &pSReply(" $type => $_");
1085 &pSReply(" $_ => $users{$user}{$_}");
1087 &pSReply("End of USER whois.");
1092 if ($message =~ /^bans(\s+(.*))?$/) {
1096 if ($arg ne "_default" and !&validChan($arg) ) {
1097 &pSReply("error: chan $chan is invalid.");
1102 if (!scalar keys %bans) {
1103 &pSReply("Ban list is empty.");
1108 &pSReply(" mask: expire, time-added, count, who-by, reason");
1109 foreach $c (keys %bans) {
1110 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1113 foreach (keys %{ $bans{$c} }) {
1114 my $val = $bans{$c}{$_};
1116 if (ref $val eq "ARRAY") {
1117 my @array = @{ $val };
1118 &pSReply(" $_: @array");
1120 &DEBUG("unknown ban: $val");
1124 &pSReply("END of bans.");
1129 if ($message =~ /^banlist(\s+(.*))?$/) {
1132 if (defined $arg and $arg !~ /^$mask{chan}$/) {
1133 &pSReply("error: chan $chan is invalid.");
1137 &DEBUG("bans for global or arg => $arg.");
1138 foreach (keys %bans) { #CHANGE!!!
1139 &DEBUG(" $_ => $bans{$_}.");
1142 &DEBUG("End of bans.");
1143 &pSReply("END of bans.");
1148 if ($message =~ /^save$/) {
1149 return unless (&hasFlag("o"));
1153 &News::writeNews() if (&ChanConfList("news"));
1159 $message =~ s/^addignore/+ignore/;
1160 $message =~ s/^(del|un)ignore/-ignore/;
1163 if ($message =~ /^(\+|\-)ignore(\s+(.*))?$/i) {
1164 return unless (&hasFlag("o"));
1165 my $state = ($1 eq "+") ? 1 : 0;
1166 my $str = $1."ignore";
1174 my($mask,$chan,$time,$comment);
1177 if ($args =~ s/^($mask{nuh})\s*//) {
1180 &ERROR("no NUH mask?");
1184 if (!$state) { # delignore.
1185 if ( &ignoreDel($mask) ) {
1186 &pSReply("ok, deleted X ignores.");
1188 &pSReply("could not find $mask in ignore list.");
1198 if ($args =~ s/^($mask{chan}|\*)\s*//) {
1205 if ($args =~ s/^(\d+)\s*//) {
1215 $comment = "added by $who";
1218 if ( &ignoreAdd($mask, $chan, $time, $comment) > 1) {
1219 &pSReply("warn: $mask already in ignore list; written over anyway. FIXME");
1221 &pSReply("added $mask to ignore list.");
1227 if ($message =~ /^ignore(\s+(.*))?$/) {
1231 if ($arg !~ /^$mask{chan}$/) {
1232 &pSReply("error: chan $chan is invalid.");
1236 if (!&validChan($arg)) {
1237 &pSReply("error: chan $arg is invalid.");
1241 &pSReply("Showing bans for $arg only.");
1244 if (!scalar keys %ignore) {
1245 &pSReply("Ignore list is empty.");
1249 ### TODO: proper (eggdrop-like) formatting.
1251 &pSReply(" mask: expire, time-added, who, comment");
1252 foreach $c (keys %ignore) {
1253 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1256 foreach (keys %{ $ignore{$c} }) {
1257 my $ref = ref $ignore{$c}{$_};
1258 if ($ref eq "ARRAY") {
1259 my @array = @{ $ignore{$c}{$_} };
1260 &pSReply(" $_: @array");
1262 &DEBUG("unknown ignore line?");
1266 &pSReply("END of ignore.");
1272 if ($message =~ /^(\+|\-|add|del)user(\s+(.*))?$/i) {
1274 my $strstr = $1."user";
1275 my @args = split /\s+/, $3 || '';
1277 my $state = ($str =~ /^(\+|add)$/) ? 1 : 0;
1279 if (!scalar @args) {
1285 if (scalar @args != 2) {
1286 &pSReply(".+host requires hostmask argument.");
1289 } elsif (scalar @args != 1) {
1290 &pSReply("too many arguments.");
1294 if ($state) { # adduser.
1295 if (scalar @args == 1) {
1296 $args[1] = &getHostMask($args[0]);
1297 &pSReply("Attemping to guess $args[0]'s hostmask...");
1299 # crude hack... crappy Net::IRC
1300 $conn->schedule(5, sub {
1301 # hopefully this is right.
1302 my $nick = (keys %{ $cache{nuhInfo} })[0];
1303 if (!defined $nick) {
1304 &pSReply("couldn't get nuhinfo... adding user without a hostmask.");
1309 my $mask = &makeHostMask( $cache{nuhInfo}{$nick}{NUH} );
1311 if ( &userAdd($nick, $mask) ) { # success.
1312 &pSReply("Added $nick with flags $users{$nick}{FLAGS}");
1313 my @hosts = keys %{ $users{$nick}{HOSTS} };
1314 &pSReply("hosts: @hosts");
1320 &DEBUG("args => @args");
1321 if ( &userAdd(@args) ) { # success.
1322 &pSReply("Added $args[0] with flags $users{$args[0]}{FLAGS}");
1323 my @hosts = keys %{ $users{$args[0]}{HOSTS} };
1324 &pSReply("hosts: @hosts");
1327 &pSReply("User $args[0] already exists");
1332 if ( &userDel($args[0]) ) { # success.
1333 &pSReply("Deleted $args[0] successfully.");
1336 &pSReply("User $args[0] does not exist.");
1343 if ($message =~ /^sched$/) {
1348 foreach (keys %sched) {
1349 next unless (exists $sched{$_}{TIME});
1350 $time{ $sched{$_}{TIME}-time() }{$_} = 1;
1353 next unless (exists $sched{$_}{RUNNING});
1358 foreach (sort { $a <=> $b } keys %time) {
1359 my $str = join(", ", sort keys %{ $time{$_} });
1360 &DEBUG("time => $_, str => $str");
1361 push(@time, "$str (".&Time2String($_).")");
1364 &pSReply( &formListReply(0, "Schedulers: ", @time ) );
1365 &pSReply( &formListReply(0, "Scheds to run: ", sort @list ) );
1366 &pSReply( &formListReply(0, "Scheds running(should not happen?) ", sort @run ) );
1371 # quite a cool hack: reply in DCC CHAT.
1375 $done++ if &parseCmdHook("main", $message);
1376 $done++ if &parseCmdHook("extra", $message);
1377 $done++ unless (&Modules());
1380 &DEBUG("running non DCC CHAT command inside DCC CHAT!");