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 ) {
448 next if (grep /^\Q$c\E$/i, @done);
455 &DEBUG("before clearircvars");
457 &DEBUG("before joinnextchan");
459 &DEBUG("after joinnextchan");
461 &status("USER reset $who");
462 &msg($who,"resetted");
468 if ($message =~ /^rehash$/) {
469 return unless (&hasFlag("n"));
471 &msg($who,"rehashing...");
473 &status("USER rehash $who");
474 &msg($who,"rehashed");
480 ##### USER//CHAN SPECIFIC CONFIGURATION COMMANDS
483 if ($message =~ /^chaninfo(\s+(.*))?$/) {
484 my @args = split /[\s\t]+/, $2; # hrm.
486 if (scalar @args != 1) {
491 if (!exists $chanconf{$args[0]}) {
492 &pSReply("no such channel $args[0]");
496 &pSReply("showing channel conf.");
497 foreach (sort keys %{ $chanconf{$args[0]} }) {
498 &pSReply("$chan: $_ => $chanconf{$args[0]}{$_}");
500 &pSReply("End of chaninfo.");
506 if ($message =~ /^(chanset|\+chan)(\s+(.*?))?$/) {
511 if (!defined $args) {
517 while ($args =~ s/^($mask{chan})\s*//) {
521 if (!scalar @chans) {
522 push(@chans, "_default");
526 my($what,$val) = split /[\s\t]+/, $args, 2;
528 ### TODO: "cannot set values without +m".
529 return unless (&hasFlag("n"));
532 if (defined $what and $what !~ /^[-+]/ and !defined $val and $no_chan) {
533 &pSReply("Showing $what values on all channels...");
536 foreach (keys %chanconf) {
537 my $val = $chanconf{$_}{$what} || "NOT-SET";
541 foreach (keys %vals) {
542 &pSReply(" $what = $_: ".join(' ', keys %{ $vals{$_} } ) );
545 &pSReply("End of list.");
550 ### TODO: move to UserDCC again.
551 if ($cmd eq "chanset" and !defined $what) {
552 &DEBUG("showing channel conf.");
554 foreach $chan ($chan, "_default") {
555 &pSReply("chan: $chan");
556 ### TODO: merge 2 or 3 per line.
559 foreach (sort keys %{ $chanconf{$chan} }) {
560 my $newstr = join(', ', @items);
561 if (length $newstr > 60) {
566 push(@items, "$_ => $chanconf{$chan}{$_}");
568 &pSReply(" $str") if (@items);
573 $cache{confvars}{$what} = $val;
577 &chanSet($cmd, $_, $what, $val);
583 if ($message =~ /^(chanunset|\-chan)(\s+(.*))?$/) {
584 return unless (&hasFlag("n"));
588 if (!defined $args) {
595 if ($args =~ s/^(\-)?($mask{chan})\s*//) {
597 $delete = ($1) ? 1 : 0;
598 &DEBUG("chan => $chan.");
600 &VERB("no chan arg; setting to default.",2);
605 if (!exists $chanconf{$chan}) {
606 &pSReply("no such channel $chan");
612 if (!&getChanConf($args,$chan)) {
613 &pSReply("$args does not exist for $chan");
617 my @chans = &ChanConfList($args);
618 &DEBUG("scalar chans => ".scalar(@chans) );
619 if (scalar @chans == 1 and $chans[0] eq "_default" and !$no_chan) {
620 &psReply("ok, $args was set only for _default; unsetting for _defaul but setting for other chans.");
622 my $val = $chanconf{$_}{_default};
623 foreach (keys %chanconf) {
624 $chanconf{$_}{$args} = $val;
626 delete $chanconf{_default}{$args};
627 $cache{confvars}{$args} = 0;
633 if ($no_chan and !exists($chanconf{_default}{$args})) {
634 &pSReply("ok, $args for _default does not exist, removing from all chans.");
636 foreach (keys %chanconf) {
637 next unless (exists $chanconf{$_}{$args});
638 &DEBUG("delete chanconf{$_}{$args};");
639 delete $chanconf{$_}{$args};
641 $cache{confvars}{$args} = 0;
647 &pSReply("Unsetting channel ($chan) option $args. (was $chanconf{$chan}{$args})");
648 delete $chanconf{$chan}{$args};
654 &pSReply("Deleting channel $chan for sure!");
655 $utime_chanfile = time();
659 &pSReply("Leaving $chan...");
661 delete $chanconf{$chan};
663 &pSReply("Prefix channel with '-' to delete for sure.");
669 if ($message =~ /^newpass(\s+(.*))?$/) {
670 my(@args) = split /[\s\t]+/, $2 || '';
672 if (scalar @args != 1) {
677 my $u = &getUser($who);
678 my $crypt = &mkcrypt($args[0]);
680 &pSReply("Set your passwd to '$crypt'");
681 $users{$u}{PASS} = $crypt;
683 $utime_userfile = time();
689 if ($message =~ /^chpass(\s+(.*))?$/) {
690 my(@args) = split /[\s\t]+/, $2 || '';
697 if (!&IsUser($args[0])) {
698 &pSReply("user $args[0] is not valid.");
702 my $u = &getUser($args[0]);
704 &pSReply("Internal error, u = NULL.");
708 if (scalar @args == 1) { # del pass.
709 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
710 &pSReply("cannot remove passwd of others.");
714 if (!exists $users{$u}{PASS}) {
715 &pSReply("$u does not have pass set anyway.");
719 &pSReply("Deleted pass from $u.");
721 $utime_userfile = time();
724 delete $users{$u}{PASS};
729 my $crypt = &mkcrypt($args[1]);
730 &pSReply("Set $u's passwd to '$crypt'");
731 $users{$u}{PASS} = $crypt;
733 $utime_userfile = time();
739 if ($message =~ /^chattr(\s+(.*))?$/) {
740 my(@args) = split /[\s\t]+/, $2 || '';
748 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
749 $user = &getUser($args[0]);
752 $user = &getUser($who);
753 &DEBUG("user $who... nope.") unless (defined $user);
754 $user = &getUser($verifyUser);
758 if (!defined $user) {
759 &pSReply("user does not exist.");
763 my $flags = $users{$user}{FLAGS};
764 if (!defined $chflag) {
765 &pSReply("Flags for $user: $flags");
769 &DEBUG("who => $who");
770 &DEBUG("verifyUser => $verifyUser");
771 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
772 &pSReply("cannto change attributes of others.");
778 foreach (split //, $chflag) {
779 if ($_ eq "+") { $state = 1; next; }
780 if ($_ eq "-") { $state = 0; next; }
782 if (!defined $state) {
783 &pSReply("no initial + or - was found in attr.");
788 next if ($flags =~ /\Q$_\E/);
791 if (&IsParam("owner")
792 and $param{owner} =~ /^\Q$user\E$/i
793 and $flags =~ /[nmo]/
795 &pSReply("not removing flag $_ for $user.");
798 next unless ($flags =~ s/\Q$_\E//);
805 $utime_userfile = time();
807 &pSReply("Current flags: $flags");
808 $users{$user}{FLAGS} = $flags;
810 &pSReply("No flags changed: $flags");
816 if ($message =~ /^chnick(\s+(.*))?$/) {
817 my(@args) = split /[\s\t]+/, $2 || '';
819 if ($who eq "_default") {
820 &WARN("$who or verifyuser tried to run chnick.");
824 if (!scalar @args or scalar @args > 2) {
829 if (scalar @args == 1) { # 1
830 $user = &getUser($who);
831 &DEBUG("nope, not $who.") unless (defined $user);
832 $user ||= &getUser($verifyUser);
835 $user = &getUser($args[0]);
839 if (!defined $user) {
840 &pSReply("user $who or $args[0] does not exist.");
844 if ($user =~ /^\Q$chnick\E$/i) {
845 &pSReply("user == chnick. why should I do that?");
849 if (&getUser($chnick)) {
850 &pSReply("user $chnick is already used!");
854 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
855 &pSReply("cannto change nick of others.");
856 return "REPLY" if ($who eq "_default");
860 foreach (keys %{ $users{$user} }) {
861 $users{$chnick}{$_} = $users{$user}{$_};
862 delete $users{$user}{$_};
864 undef $users{$user}; # ???
866 $utime_userfile = time();
869 &pSReply("Changed '$user' to '$chnick' successfully.");
874 if ($message =~ /^([-+])host(\s+(.*))?$/) {
876 my(@args) = split /[\s\t]+/, $3 || '';
877 my $state = ($1 eq "+") ? 1 : 0;
884 if ($who eq "_default") {
885 &WARN("$who or verifyuser tried to run $cmd.");
890 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
891 return unless (&hasFlag("n"));
892 $user = &getUser($args[0]);
895 # who or verifyUser. FIXME!!!
896 $user = &getUser($who);
900 if (!defined $user) {
901 &pSReply("user $user does not exist.");
905 if (!defined $mask) {
907 &pSReply("Hostmasks for $user: $users{$user}{HOSTS}");
912 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
913 &pSReply("cannto change masks of others.");
917 if ($mask !~ /^$mask{nuh}$/) {
918 &pSReply("error: mask ($mask) is not a real hostmask.");
922 my $count = scalar keys %{ $users{$user}{HOSTS} };
925 if (exists $users{$user}{HOSTS}{$mask}) {
926 &pSReply("mask $mask already exists.");
930 ### TODO: override support.
931 $users{$user}{HOSTS}{$mask} = 1;
933 &pSReply("Added $mask to list of masks.");
937 if (!exists $users{$user}{HOSTS}{$mask}) {
938 &pSReply("mask $mask does not exist.");
942 ### TODO: wildcard support. ?
943 delete $users{$user}{HOSTS}{$mask};
945 if (scalar keys %{ $users{$user}{HOSTS} } != $count) {
946 &pSReply("Removed $mask from list of masks.");
948 &pSReply("error: could not find $mask in list of masks.");
953 $utime_userfile = time();
959 if ($message =~ /^([-+])ban(\s+(.*))?$/) {
962 my(@args) = split /[\s\t]+/, $3 || '';
963 my $state = ($1 eq "+") ? 1 : 0;
970 my($mask,$chan,$time,$reason);
972 if ($flatarg =~ s/^($mask{nuh})\s*//) {
975 &DEBUG("arg does not contain nuh mask?");
978 if ($flatarg =~ s/^($mask{chan})\s*//) {
981 $chan = "*"; # _default instead?
984 if ($state == 0) { # delete.
985 my @c = &banDel($mask);
992 &pSReply("Removed $mask from chans: @c");
994 &pSReply("$mask was not found in ban list.");
1005 if ($flatarg =~ s/^(\d+)\s*//) {
1007 &DEBUG("time = $time.");
1009 &pSReply("error: time cannot be negatime?");
1016 if ($flatarg =~ s/^(.*)$//) { # need length?
1020 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
1021 &pSReply("cannto change masks of others.");
1025 if ($mask !~ /^$mask{nuh}$/) {
1026 &pSReply("error: mask ($mask) is not a real hostmask.");
1030 if ( &banAdd($mask,$chan,$time,$reason) == 2) {
1031 &pSReply("ban already exists; overwriting.");
1033 &pSReply("Added $mask for $chan (time => $time, reason => $reason)");
1038 if ($message =~ /^whois(\s+(.*))?$/) {
1041 if (!defined $arg) {
1046 my $user = &getUser($arg);
1047 if (!defined $user) {
1048 &pSReply("whois: user $user does not exist.");
1052 ### TODO: better (eggdrop-like) output.
1053 &pSReply("user: $user");
1054 foreach (keys %{ $users{$user} }) {
1055 my $ref = ref $users{$user}{$_};
1057 if ($ref eq "HASH") {
1059 ### DOES NOT WORK???
1060 foreach (keys %{ $users{$user}{$type} }) {
1061 &pSReply(" $type => $_");
1066 &pSReply(" $_ => $users{$user}{$_}");
1068 &pSReply("End of USER whois.");
1073 if ($message =~ /^bans(\s+(.*))?$/) {
1077 if ($arg ne "_default" and !&validChan($arg) ) {
1078 &pSReply("error: chan $chan is invalid.");
1083 if (!scalar keys %bans) {
1084 &pSReply("Ban list is empty.");
1089 &pSReply(" mask: expire, time-added, count, who-by, reason");
1090 foreach $c (keys %bans) {
1091 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1094 foreach (keys %{ $bans{$c} }) {
1095 my $val = $bans{$c}{$_};
1097 if (ref $val eq "ARRAY") {
1098 my @array = @{ $val };
1099 &pSReply(" $_: @array");
1101 &DEBUG("unknown ban: $val");
1105 &pSReply("END of bans.");
1110 if ($message =~ /^banlist(\s+(.*))?$/) {
1113 if (defined $arg and $arg !~ /^$mask_chan$/) {
1114 &pSReply("error: chan $chan is invalid.");
1118 &DEBUG("bans for global or arg => $arg.");
1119 foreach (keys %bans) { #CHANGE!!!
1120 &DEBUG(" $_ => $bans{$_}.");
1123 &DEBUG("End of bans.");
1124 &pSReply("END of bans.");
1129 if ($message =~ /^save$/) {
1130 return unless (&hasFlag("o"));
1134 &News::writeNews() if (&ChanConfList("news"));
1140 $message =~ s/^addignore/+ignore/;
1141 $message =~ s/^(del|un)ignore/-ignore/;
1144 if ($message =~ /^(\+|\-)ignore(\s+(.*))?$/i) {
1145 return unless (&hasFlag("o"));
1146 my $state = ($1 eq "+") ? 1 : 0;
1147 my $str = $1."ignore";
1155 my($mask,$chan,$time,$comment);
1158 if ($args =~ s/^($mask{nuh})\s*//) {
1161 &ERROR("no NUH mask?");
1165 if (!$state) { # delignore.
1166 if ( &ignoreDel($mask) ) {
1167 &pSReply("ok, deleted X ignores.");
1169 &pSReply("could not find $mask in ignore list.");
1179 if ($args =~ s/^($mask{chan}|\*)\s*//) {
1186 if ($args =~ s/^(\d+)\s*//) {
1196 $comment = "added by $who";
1199 if ( &ignoreAdd($mask, $chan, $time, $comment) > 1) {
1200 &pSReply("warn: $mask already in ignore list; written over anyway. FIXME");
1202 &pSReply("added $mask to ignore list.");
1208 if ($message =~ /^ignore(\s+(.*))?$/) {
1212 if ($arg !~ /^$mask{chan}$/) {
1213 &pSReply("error: chan $chan is invalid.");
1217 if (!&validChan($arg)) {
1218 &pSReply("error: chan $arg is invalid.");
1222 &pSReply("Showing bans for $arg only.");
1225 if (!scalar keys %ignore) {
1226 &pSReply("Ignore list is empty.");
1230 ### TODO: proper (eggdrop-like) formatting.
1232 &pSReply(" mask: expire, time-added, who, comment");
1233 foreach $c (keys %ignore) {
1234 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1237 foreach (keys %{ $ignore{$c} }) {
1238 my $ref = ref $ignore{$c}{$_};
1239 if ($ref eq "ARRAY") {
1240 my @array = @{ $ignore{$c}{$_} };
1241 &pSReply(" $_: @array");
1243 &DEBUG("unknown ignore line?");
1247 &pSReply("END of ignore.");
1253 if ($message =~ /^(\+|\-|add|del)user(\s+(.*))?$/i) {
1255 my $strstr = $1."user";
1256 my @args = split /\s+/, $3 || '';
1258 my $state = ($str =~ /^(\+|add)$/) ? 1 : 0;
1260 if (!scalar @args) {
1266 if (scalar @args != 2) {
1267 &pSReply(".+host requires hostmask argument.");
1270 } elsif (scalar @args != 1) {
1271 &pSReply("too many arguments.");
1275 if ($state) { # adduser.
1276 if (scalar @args == 1) {
1277 $args[1] = &getHostMask($args[0]);
1278 &pSReply("Attemping to guess $args[0]'s hostmask...");
1280 # crude hack... crappy Net::IRC
1281 $conn->schedule(5, sub {
1282 # hopefully this is right.
1283 my $nick = (keys %{ $cache{nuhInfo} })[0];
1284 if (!defined $nick) {
1285 &pSReply("couldn't get nuhinfo... adding user without a hostmask.");
1290 my $mask = &makeHostMask( $cache{nuhInfo}{$nick}{NUH} );
1292 if ( &userAdd($nick, $mask) ) { # success.
1293 &pSReply("Added $nick with flags $users{$nick}{FLAGS}");
1294 my @hosts = keys %{ $users{$nick}{HOSTS} };
1295 &pSReply("hosts: @hosts");
1301 &DEBUG("args => @args");
1302 if ( &userAdd(@args) ) { # success.
1303 &pSReply("Added $args[0] with flags $users{$args[0]}{FLAGS}");
1304 my @hosts = keys %{ $users{$args[0]}{HOSTS} };
1305 &pSReply("hosts: @hosts");
1308 &pSReply("User $args[0] already exists");
1313 if ( &userDel($args[0]) ) { # success.
1314 &pSReply("Deleted $args[0] successfully.");
1317 &pSReply("User $args[0] does not exist.");
1324 if ($message =~ /^sched$/) {
1329 foreach (keys %sched) {
1330 next unless (exists $sched{$_}{TIME});
1331 $time{ $sched{$_}{TIME}-time() }{$_} = 1;
1334 next unless (exists $sched{$_}{RUNNING});
1339 foreach (sort { $a <=> $b } keys %time) {
1340 my $str = join(", ", sort keys %{ $time{$_} });
1341 &DEBUG("time => $_, str => $str");
1342 push(@time, "$str (".&Time2String($_).")");
1345 &pSReply( &formListReply(0, "Schedulers: ", @time ) );
1346 &pSReply( &formListReply(0, "Scheds to run: ", sort @list ) );
1347 &pSReply( &formListReply(0, "Scheds running(should not happen?) ", sort @run ) );
1352 # quite a cool hack: reply in DCC CHAT.
1356 $done++ if &parseCmdHook("main", $message);
1357 $done++ if &parseCmdHook("extra", $message);
1358 $done++ unless (&Modules());
1361 &DEBUG("running non DCC CHAT command inside DCC CHAT!");