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 =~ /^symdump$/i) {
121 return unless (&hasFlag("o"));
122 return unless (&IsParam("symdump"));
124 &status("Dumping all variables...");
131 if ($message =~ /^kick(\s+(\S+)(\s+(\S+))?)?/) {
132 return unless (&hasFlag("o"));
133 my ($nick,$chan) = (lc $2,lc $4);
140 if (&validChan($chan) == 0) {
141 &msg($who,"error: invalid channel \002$chan\002");
145 if (&IsNickInChan($nick,$chan) == 0) {
146 &msg($who,"$nick is not in $chan.");
156 if ($message =~ /^mode(\s+(.*))?$/) {
157 return unless (&hasFlag("n"));
158 my ($chan,$mode) = split /\s+/,$2,2;
165 if (&validChan($chan) == 0) {
166 &msg($who,"error: invalid channel \002$chan\002");
170 if (!$channels{$chan}{o}{$ident}) {
171 &msg($who,"error: don't have ops on \002$chan\002");
181 if ($message =~ /^part(\s+(\S+))?$/i) {
182 return unless (&hasFlag("o"));
185 if ($jchan !~ /^$mask{chan}$/) {
186 &msg($who, "error, invalid chan.");
191 if (!&validChan($jchan)) {
192 &msg($who, "error, I'm not on that chan.");
196 &msg($jchan, "Leaving. (courtesy of $who).");
201 # lobotomy. sometimes we want the bot to be _QUIET_.
202 if ($message =~ /^(lobotomy|bequiet)$/i) {
203 return unless (&hasFlag("o"));
206 &performReply("i'm already lobotomized");
208 &performReply("i have been lobotomized");
216 if ($message =~ /^(unlobotomy|benoisy)$/i) {
217 return unless (&hasFlag("o"));
220 &performReply("i have been unlobotomized, woohoo");
222 delete $cache{lobotomy};
223 # undef $cache{lobotomy}; # ??
225 &performReply("i'm not lobotomized");
232 if ($message =~ /^op(\s+(.*))?$/i) {
233 return unless (&hasFlag("o"));
238 if ($opee =~ /^(\S+)\s+(\S+)$/) {
241 if (!&validChan($2)) {
242 &msg($who,"error: invalid chan ($2).");
246 &msg($who,"error: invalid params.");
250 @chans = keys %channels;
256 next unless (&IsNickInChan($opee,$_));
258 if ($channels{$_}{'o'}{$opee}) {
259 &pSReply("op: $opee already has ops on $_");
264 &pSReply("opping $opee on $_");
269 &pSReply("op: opped on all possible channels.");
271 &DEBUG("op: found => '$found'.");
272 &DEBUG("op: op => '$op'.");
279 if ($message =~ /^deop(\s+(.*))?$/i) {
280 return unless (&hasFlag("o"));
285 if ($opee =~ /^(\S+)\s+(\S+)$/) {
288 if (!&validChan($2)) {
289 &msg($who,"error: invalid chan ($2).");
293 &msg($who,"error: invalid params.");
297 @chans = keys %channels;
303 next unless (&IsNickInChan($opee,$_));
305 if (!exists $channels{$_}{'o'}{$opee}) {
306 &status("deop: $opee already has no ops on $_");
311 &status("deopping $opee on $_ at ${who}'s request");
316 &status("deop: deopped on all possible channels.");
318 &DEBUG("deop: found => '$found'.");
319 &DEBUG("deop: op => '$op'.");
326 if ($message =~ s/^say\s+(\S+)\s+(.*)//) {
327 return unless (&hasFlag("o"));
328 my ($chan,$msg) = (lc $1, $2);
329 &DEBUG("chan => '$1', msg => '$msg'.");
331 if (&validChan($chan)) {
334 &msg($who,"i'm not on \002$1\002, sorry.");
340 if ($message =~ /^die$/) {
341 return unless (&hasFlag("n"));
345 &status("Dying by $who\'s request");
349 # global factoid substitution.
350 if ($message =~ m|^s([/,#])(.+?)\1(.*?)\1;?\s*$|) {
351 my ($delim,$op,$np) = ($1, $2, $3);
352 return unless (&hasFlag("n"));
353 ### TODO: support flags to do full-on global.
356 if ($np =~ /$delim/) {
357 &performReply("looks like you used the delimiter too many times. You may want to use a different delimiter, like ':' or '#'.");
361 ### TODO: fix up $op to support mysql/sqlite/pgsql/dbm(perl)
362 ### TODO: => add db/sql specific function to fix this.
363 my @list = &searchTable("factoids", "factoid_key",
364 "factoid_value", $op);
367 &performReply("Expression didn't match anything.");
371 if (scalar @list > 100) {
372 &performReply("regex found more than 100 matches... not doing.");
376 &status("gsubst: going to alter ".scalar(@list)." factoids.");
377 &performReply("going to alter ".scalar(@list)." factoids.");
383 next if (&IsLocked($faqtoid) == 1);
384 my $result = &getFactoid($faqtoid);
386 &DEBUG("was($faqtoid) => '$was'.");
389 # we could support global local (once off).
390 if ($result =~ s/\Q$op/$np/gi) {
391 if (length $result > $param{'maxDataSize'}) {
392 &performReply("that's too long (or was long)");
395 &setFactInfo($faqtoid, "factoid_value", $result);
396 &status("update: '$faqtoid' =is=> '$result'; was '$was'");
398 &WARN("subst: that's weird... thought we found the string ($op) in '$faqtoid'.");
404 &ERROR("Some warnings/errors?");
407 &performReply("Ok... did s/$op/$np/ for ".
408 (scalar(@list) - $error)." factoids");
414 if ($message =~ /^jump(\s+(\S+))?$/i) {
415 return unless (&hasFlag("n"));
423 if ($2 =~ /^(\S+)(:(\d+))?$/) {
427 &msg($who,"invalid format.");
431 &status("jumping servers... $server...");
432 $conn->quit("jumping to $server");
434 if (&irc($server,$port) == 0) {
440 if ($message =~ /^reload$/i) {
441 return unless (&hasFlag("n"));
443 &status("USER reload $who");
444 &pSReply("reloading...");
446 &pSReply("reloaded.");
452 if ($message =~ /^reset$/i) {
453 return unless (&hasFlag("n"));
455 &msg($who,"resetting...");
457 foreach ( keys %channels, keys %chanconf ) {
459 next if (grep /^\Q$c\E$/i, @done);
466 &DEBUG("before clearircvars");
468 &DEBUG("before joinnextchan");
470 &DEBUG("after joinnextchan");
472 &status("USER reset $who");
473 &msg($who,"resetted");
479 if ($message =~ /^rehash$/) {
480 return unless (&hasFlag("n"));
482 &msg($who,"rehashing...");
484 &status("USER rehash $who");
485 &msg($who,"rehashed");
491 ##### USER//CHAN SPECIFIC CONFIGURATION COMMANDS
494 if ($message =~ /^chaninfo(\s+(.*))?$/) {
495 my @args = split /[\s\t]+/, $2; # hrm.
497 if (scalar @args != 1) {
502 if (!exists $chanconf{$args[0]}) {
503 &pSReply("no such channel $args[0]");
507 &pSReply("showing channel conf.");
508 foreach (sort keys %{ $chanconf{$args[0]} }) {
509 &pSReply("$chan: $_ => $chanconf{$args[0]}{$_}");
511 &pSReply("End of chaninfo.");
517 if ($message =~ /^(chanset|\+chan)(\s+(.*?))?$/) {
522 if (!defined $args) {
528 while ($args =~ s/^($mask{chan})\s*//) {
532 if (!scalar @chans) {
533 push(@chans, "_default");
537 my($what,$val) = split /[\s\t]+/, $args, 2;
539 ### TODO: "cannot set values without +m".
540 return unless (&hasFlag("n"));
543 if (defined $what and $what !~ /^[-+]/ and !defined $val and $no_chan) {
544 &pSReply("Showing $what values on all channels...");
547 foreach (keys %chanconf) {
548 my $val = $chanconf{$_}{$what} || "NOT-SET";
552 foreach (keys %vals) {
553 &pSReply(" $what = $_: ".join(' ', keys %{ $vals{$_} } ) );
556 &pSReply("End of list.");
561 ### TODO: move to UserDCC again.
562 if ($cmd eq "chanset" and !defined $what) {
563 &DEBUG("showing channel conf.");
565 foreach $chan ($chan, "_default") {
566 &pSReply("chan: $chan");
567 ### TODO: merge 2 or 3 per line.
570 foreach (sort keys %{ $chanconf{$chan} }) {
571 my $newstr = join(', ', @items);
572 if (length $newstr > 60) {
577 push(@items, "$_ => $chanconf{$chan}{$_}");
579 &pSReply(" $str") if (@items);
584 $cache{confvars}{$what} = $val;
588 &chanSet($cmd, $_, $what, $val);
594 if ($message =~ /^(chanunset|\-chan)(\s+(.*))?$/) {
595 return unless (&hasFlag("n"));
599 if (!defined $args) {
606 if ($args =~ s/^(\-)?($mask{chan})\s*//) {
608 $delete = ($1) ? 1 : 0;
609 &DEBUG("chan => $chan.");
611 &VERB("no chan arg; setting to default.",2);
616 if (!exists $chanconf{$chan}) {
617 &pSReply("no such channel $chan");
623 if (!&getChanConf($args,$chan)) {
624 &pSReply("$args does not exist for $chan");
628 my @chans = &ChanConfList($args);
629 &DEBUG("scalar chans => ".scalar(@chans) );
630 if (scalar @chans == 1 and $chans[0] eq "_default" and !$no_chan) {
631 &psReply("ok, $args was set only for _default; unsetting for _defaul but setting for other chans.");
633 my $val = $chanconf{$_}{_default};
634 foreach (keys %chanconf) {
635 $chanconf{$_}{$args} = $val;
637 delete $chanconf{_default}{$args};
638 $cache{confvars}{$args} = 0;
644 if ($no_chan and !exists($chanconf{_default}{$args})) {
645 &pSReply("ok, $args for _default does not exist, removing from all chans.");
647 foreach (keys %chanconf) {
648 next unless (exists $chanconf{$_}{$args});
649 &DEBUG("delete chanconf{$_}{$args};");
650 delete $chanconf{$_}{$args};
652 $cache{confvars}{$args} = 0;
658 &pSReply("Unsetting channel ($chan) option $args. (was $chanconf{$chan}{$args})");
659 delete $chanconf{$chan}{$args};
665 &pSReply("Deleting channel $chan for sure!");
666 $utime_chanfile = time();
670 &pSReply("Leaving $chan...");
672 delete $chanconf{$chan};
674 &pSReply("Prefix channel with '-' to delete for sure.");
680 if ($message =~ /^newpass(\s+(.*))?$/) {
681 my(@args) = split /[\s\t]+/, $2 || '';
683 if (scalar @args != 1) {
688 my $u = &getUser($who);
689 my $crypt = &mkcrypt($args[0]);
691 &pSReply("Set your passwd to '$crypt'");
692 $users{$u}{PASS} = $crypt;
694 $utime_userfile = time();
700 if ($message =~ /^chpass(\s+(.*))?$/) {
701 my(@args) = split /[\s\t]+/, $2 || '';
708 if (!&IsUser($args[0])) {
709 &pSReply("user $args[0] is not valid.");
713 my $u = &getUser($args[0]);
715 &pSReply("Internal error, u = NULL.");
719 if (scalar @args == 1) { # del pass.
720 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
721 &pSReply("cannot remove passwd of others.");
725 if (!exists $users{$u}{PASS}) {
726 &pSReply("$u does not have pass set anyway.");
730 &pSReply("Deleted pass from $u.");
732 $utime_userfile = time();
735 delete $users{$u}{PASS};
740 my $crypt = &mkcrypt($args[1]);
741 &pSReply("Set $u's passwd to '$crypt'");
742 $users{$u}{PASS} = $crypt;
744 $utime_userfile = time();
750 if ($message =~ /^chattr(\s+(.*))?$/) {
751 my(@args) = split /[\s\t]+/, $2 || '';
759 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
760 $user = &getUser($args[0]);
763 $user = &getUser($who);
764 &DEBUG("user $who... nope.") unless (defined $user);
765 $user = &getUser($verifyUser);
769 if (!defined $user) {
770 &pSReply("user does not exist.");
774 my $flags = $users{$user}{FLAGS};
775 if (!defined $chflag) {
776 &pSReply("Flags for $user: $flags");
780 &DEBUG("who => $who");
781 &DEBUG("verifyUser => $verifyUser");
782 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
783 &pSReply("cannto change attributes of others.");
789 foreach (split //, $chflag) {
790 if ($_ eq "+") { $state = 1; next; }
791 if ($_ eq "-") { $state = 0; next; }
793 if (!defined $state) {
794 &pSReply("no initial + or - was found in attr.");
799 next if ($flags =~ /\Q$_\E/);
802 if (&IsParam("owner")
803 and $param{owner} =~ /^\Q$user\E$/i
804 and $flags =~ /[nmo]/
806 &pSReply("not removing flag $_ for $user.");
809 next unless ($flags =~ s/\Q$_\E//);
816 $utime_userfile = time();
818 &pSReply("Current flags: $flags");
819 $users{$user}{FLAGS} = $flags;
821 &pSReply("No flags changed: $flags");
827 if ($message =~ /^chnick(\s+(.*))?$/) {
828 my(@args) = split /[\s\t]+/, $2 || '';
830 if ($who eq "_default") {
831 &WARN("$who or verifyuser tried to run chnick.");
835 if (!scalar @args or scalar @args > 2) {
840 if (scalar @args == 1) { # 1
841 $user = &getUser($who);
842 &DEBUG("nope, not $who.") unless (defined $user);
843 $user ||= &getUser($verifyUser);
846 $user = &getUser($args[0]);
850 if (!defined $user) {
851 &pSReply("user $who or $args[0] does not exist.");
855 if ($user =~ /^\Q$chnick\E$/i) {
856 &pSReply("user == chnick. why should I do that?");
860 if (&getUser($chnick)) {
861 &pSReply("user $chnick is already used!");
865 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
866 &pSReply("cannto change nick of others.");
867 return "REPLY" if ($who eq "_default");
871 foreach (keys %{ $users{$user} }) {
872 $users{$chnick}{$_} = $users{$user}{$_};
873 delete $users{$user}{$_};
875 undef $users{$user}; # ???
877 $utime_userfile = time();
880 &pSReply("Changed '$user' to '$chnick' successfully.");
885 if ($message =~ /^([-+])host(\s+(.*))?$/) {
887 my(@args) = split /[\s\t]+/, $3 || '';
888 my $state = ($1 eq "+") ? 1 : 0;
895 if ($who eq "_default") {
896 &WARN("$who or verifyuser tried to run $cmd.");
901 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
902 return unless (&hasFlag("n"));
903 $user = &getUser($args[0]);
906 # who or verifyUser. FIXME (don't remember why)
907 $user = &getUser($who);
911 if (!defined $user) {
912 &pSReply("user $user does not exist.");
916 if (!defined $mask) {
918 &pSReply("Hostmasks for $user: $users{$user}{HOSTS}");
923 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
924 &pSReply("cannto change masks of others.");
928 if ($mask !~ /^$mask{nuh}$/) {
929 &pSReply("error: mask ($mask) is not a real hostmask.");
933 my $count = scalar keys %{ $users{$user}{HOSTS} };
936 if (exists $users{$user}{HOSTS}{$mask}) {
937 &pSReply("mask $mask already exists.");
941 ### TODO: override support.
942 $users{$user}{HOSTS}{$mask} = 1;
944 &pSReply("Added $mask to list of masks.");
948 if (!exists $users{$user}{HOSTS}{$mask}) {
949 &pSReply("mask $mask does not exist.");
953 ### TODO: wildcard support. ?
954 delete $users{$user}{HOSTS}{$mask};
956 if (scalar keys %{ $users{$user}{HOSTS} } != $count) {
957 &pSReply("Removed $mask from list of masks.");
959 &pSReply("error: could not find $mask in list of masks.");
964 $utime_userfile = time();
970 if ($message =~ /^([-+])ban(\s+(.*))?$/) {
973 my(@args) = split /[\s\t]+/, $3 || '';
974 my $state = ($1 eq "+") ? 1 : 0;
981 my($mask,$chan,$time,$reason);
983 if ($flatarg =~ s/^($mask{nuh})\s*//) {
986 &DEBUG("arg does not contain nuh mask?");
989 if ($flatarg =~ s/^($mask{chan})\s*//) {
992 $chan = "*"; # _default instead?
995 if ($state == 0) { # delete.
996 my @c = &banDel($mask);
1003 &pSReply("Removed $mask from chans: @c");
1005 &pSReply("$mask was not found in ban list.");
1016 if ($flatarg =~ s/^(\d+)\s*//) {
1018 &DEBUG("time = $time.");
1020 &pSReply("error: time cannot be negatime?");
1027 if ($flatarg =~ s/^(.*)$//) { # need length?
1031 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
1032 &pSReply("cannto change masks of others.");
1036 if ($mask !~ /^$mask{nuh}$/) {
1037 &pSReply("error: mask ($mask) is not a real hostmask.");
1041 if ( &banAdd($mask,$chan,$time,$reason) == 2) {
1042 &pSReply("ban already exists; overwriting.");
1044 &pSReply("Added $mask for $chan (time => $time, reason => $reason)");
1049 if ($message =~ /^whois(\s+(.*))?$/) {
1052 if (!defined $arg) {
1057 my $user = &getUser($arg);
1058 if (!defined $user) {
1059 &pSReply("whois: user $user does not exist.");
1063 ### TODO: better (eggdrop-like) output.
1064 &pSReply("user: $user");
1065 foreach (keys %{ $users{$user} }) {
1066 my $ref = ref $users{$user}{$_};
1068 if ($ref eq "HASH") {
1070 ### DOES NOT WORK???
1071 foreach (keys %{ $users{$user}{$type} }) {
1072 &pSReply(" $type => $_");
1077 &pSReply(" $_ => $users{$user}{$_}");
1079 &pSReply("End of USER whois.");
1084 if ($message =~ /^bans(\s+(.*))?$/) {
1088 if ($arg ne "_default" and !&validChan($arg) ) {
1089 &pSReply("error: chan $chan is invalid.");
1094 if (!scalar keys %bans) {
1095 &pSReply("Ban list is empty.");
1100 &pSReply(" mask: expire, time-added, count, who-by, reason");
1101 foreach $c (keys %bans) {
1102 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1105 foreach (keys %{ $bans{$c} }) {
1106 my $val = $bans{$c}{$_};
1108 if (ref $val eq "ARRAY") {
1109 my @array = @{ $val };
1110 &pSReply(" $_: @array");
1112 &DEBUG("unknown ban: $val");
1116 &pSReply("END of bans.");
1121 if ($message =~ /^banlist(\s+(.*))?$/) {
1124 if (defined $arg and $arg !~ /^$mask_chan$/) {
1125 &pSReply("error: chan $chan is invalid.");
1129 &DEBUG("bans for global or arg => $arg.");
1130 foreach (keys %bans) { #CHANGE!!!
1131 &DEBUG(" $_ => $bans{$_}.");
1134 &DEBUG("End of bans.");
1135 &pSReply("END of bans.");
1140 if ($message =~ /^save$/) {
1141 return unless (&hasFlag("o"));
1145 &News::writeNews() if (&ChanConfList("news"));
1151 $message =~ s/^addignore/+ignore/;
1152 $message =~ s/^(del|un)ignore/-ignore/;
1155 if ($message =~ /^(\+|\-)ignore(\s+(.*))?$/i) {
1156 return unless (&hasFlag("o"));
1157 my $state = ($1 eq "+") ? 1 : 0;
1158 my $str = $1."ignore";
1166 my($mask,$chan,$time,$comment);
1169 if ($args =~ s/^($mask{nuh})\s*//) {
1172 &ERROR("no NUH mask?");
1176 if (!$state) { # delignore.
1177 if ( &ignoreDel($mask) ) {
1178 &pSReply("ok, deleted X ignores.");
1180 &pSReply("could not find $mask in ignore list.");
1190 if ($args =~ s/^($mask{chan}|\*)\s*//) {
1197 if ($args =~ s/^(\d+)\s*//) {
1207 $comment = "added by $who";
1210 if ( &ignoreAdd($mask, $chan, $time, $comment) > 1) {
1211 &pSReply("warn: $mask already in ignore list; written over anyway. FIXME");
1213 &pSReply("added $mask to ignore list.");
1219 if ($message =~ /^ignore(\s+(.*))?$/) {
1223 if ($arg !~ /^$mask{chan}$/) {
1224 &pSReply("error: chan $chan is invalid.");
1228 if (!&validChan($arg)) {
1229 &pSReply("error: chan $arg is invalid.");
1233 &pSReply("Showing bans for $arg only.");
1236 if (!scalar keys %ignore) {
1237 &pSReply("Ignore list is empty.");
1241 ### TODO: proper (eggdrop-like) formatting.
1243 &pSReply(" mask: expire, time-added, who, comment");
1244 foreach $c (keys %ignore) {
1245 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1248 foreach (keys %{ $ignore{$c} }) {
1249 my $ref = ref $ignore{$c}{$_};
1250 if ($ref eq "ARRAY") {
1251 my @array = @{ $ignore{$c}{$_} };
1252 &pSReply(" $_: @array");
1254 &DEBUG("unknown ignore line?");
1258 &pSReply("END of ignore.");
1264 if ($message =~ /^(\+|\-|add|del)user(\s+(.*))?$/i) {
1266 my $strstr = $1."user";
1267 my @args = split /\s+/, $3 || '';
1269 my $state = ($str =~ /^(\+|add)$/) ? 1 : 0;
1271 if (!scalar @args) {
1277 if (scalar @args != 2) {
1278 &pSReply(".+host requires hostmask argument.");
1281 } elsif (scalar @args != 1) {
1282 &pSReply("too many arguments.");
1286 if ($state) { # adduser.
1287 if (scalar @args == 1) {
1288 $args[1] = &getHostMask($args[0]);
1289 &pSReply("Attemping to guess $args[0]'s hostmask...");
1291 # crude hack... crappy Net::IRC
1292 $conn->schedule(5, sub {
1293 # hopefully this is right.
1294 my $nick = (keys %{ $cache{nuhInfo} })[0];
1295 if (!defined $nick) {
1296 &pSReply("couldn't get nuhinfo... adding user without a hostmask.");
1301 my $mask = &makeHostMask( $cache{nuhInfo}{$nick}{NUH} );
1303 if ( &userAdd($nick, $mask) ) { # success.
1304 &pSReply("Added $nick with flags $users{$nick}{FLAGS}");
1305 my @hosts = keys %{ $users{$nick}{HOSTS} };
1306 &pSReply("hosts: @hosts");
1312 &DEBUG("args => @args");
1313 if ( &userAdd(@args) ) { # success.
1314 &pSReply("Added $args[0] with flags $users{$args[0]}{FLAGS}");
1315 my @hosts = keys %{ $users{$args[0]}{HOSTS} };
1316 &pSReply("hosts: @hosts");
1319 &pSReply("User $args[0] already exists");
1324 if ( &userDel($args[0]) ) { # success.
1325 &pSReply("Deleted $args[0] successfully.");
1328 &pSReply("User $args[0] does not exist.");
1335 if ($message =~ /^sched$/) {
1340 foreach (keys %sched) {
1341 next unless (exists $sched{$_}{TIME});
1342 $time{ $sched{$_}{TIME}-time() }{$_} = 1;
1345 next unless (exists $sched{$_}{RUNNING});
1350 foreach (sort { $a <=> $b } keys %time) {
1351 my $str = join(", ", sort keys %{ $time{$_} });
1352 &DEBUG("time => $_, str => $str");
1353 push(@time, "$str (".&Time2String($_).")");
1356 &pSReply( &formListReply(0, "Schedulers: ", @time ) );
1357 &pSReply( &formListReply(0, "Scheds to run: ", sort @list ) );
1358 &pSReply( &formListReply(0, "Scheds running(should not happen?) ", sort @run ) );
1363 # quite a cool hack: reply in DCC CHAT.
1367 $done++ if &parseCmdHook("main", $message);
1368 $done++ if &parseCmdHook("extra", $message);
1369 $done++ unless (&Modules());
1372 &DEBUG("running non DCC CHAT command inside DCC CHAT!");