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 &FIXME("userDCC: quit called.");
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('DumpVars2'));
131 &status("Dumping all variables...");
138 if ($message =~ /^kick(\s+(.*?))$/) {
139 return unless (&hasFlag("o"));
147 my @args = split(/\s+/, $arg);
148 my ($nick,$chan,$reason) = @args;
150 if (&validChan($chan) == 0) {
151 &msg($who,"error: invalid channel \002$chan\002");
155 if (&IsNickInChan($nick,$chan) == 0) {
156 &msg($who,"$nick is not in $chan.");
160 &kick($nick,$chan,$reason);
166 if ($message =~ /^mode(\s+(.*))?$/) {
167 return unless (&hasFlag("n"));
168 my ($chan,$mode) = split /\s+/,$2,2;
175 if (&validChan($chan) == 0) {
176 &msg($who,"error: invalid channel \002$chan\002");
180 if (!$channels{$chan}{o}{$ident}) {
181 &msg($who,"error: don't have ops on \002$chan\002");
191 if ($message =~ /^part(\s+(\S+))?$/i) {
192 return unless (&hasFlag("o"));
195 if ($jchan !~ /^$mask{chan}$/) {
196 &msg($who, "error, invalid chan.");
201 if (!&validChan($jchan)) {
202 &msg($who, "error, I'm not on that chan.");
206 &msg($jchan, "Leaving. (courtesy of $who).");
211 # lobotomy. sometimes we want the bot to be _QUIET_.
212 if ($message =~ /^(lobotomy|bequiet)$/i) {
213 return unless (&hasFlag("o"));
216 &performReply("i'm already lobotomized");
218 &performReply("i have been lobotomized");
226 if ($message =~ /^(unlobotomy|benoisy)$/i) {
227 return unless (&hasFlag("o"));
230 &performReply("i have been unlobotomized, woohoo");
232 delete $cache{lobotomy};
233 # undef $cache{lobotomy}; # ??
235 &performReply("i'm not lobotomized");
242 if ($message =~ /^op(\s+(.*))?$/i) {
243 return unless (&hasFlag("o"));
248 if ($opee =~ /^(\S+)\s+(\S+)$/) {
251 if (!&validChan($2)) {
252 &msg($who,"error: invalid chan ($2).");
256 &msg($who,"error: invalid params.");
260 @chans = keys %channels;
266 next unless (&IsNickInChan($opee,$_));
268 if ($channels{$_}{'o'}{$opee}) {
269 &pSReply("op: $opee already has ops on $_");
274 &pSReply("opping $opee on $_");
279 &pSReply("op: opped on all possible channels.");
281 &DEBUG("op: found => '$found'.");
282 &DEBUG("op: op => '$op'.");
289 if ($message =~ /^deop(\s+(.*))?$/i) {
290 return unless (&hasFlag("o"));
295 if ($opee =~ /^(\S+)\s+(\S+)$/) {
298 if (!&validChan($2)) {
299 &msg($who,"error: invalid chan ($2).");
303 &msg($who,"error: invalid params.");
307 @chans = keys %channels;
313 next unless (&IsNickInChan($opee,$_));
315 if (!exists $channels{$_}{'o'}{$opee}) {
316 &status("deop: $opee already has no ops on $_");
321 &status("deopping $opee on $_ at ${who}'s request");
326 &status("deop: deopped on all possible channels.");
328 &DEBUG("deop: found => '$found'.");
329 &DEBUG("deop: op => '$op'.");
336 if ($message =~ s/^say\s+(\S+)\s+(.*)//) {
337 return unless (&hasFlag("o"));
338 my ($chan,$msg) = (lc $1, $2);
340 &DEBUG("chan => '$1', msg => '$msg'.");
342 # TODO: add nick destination.
343 if (&validChan($chan)) {
346 &msg($who,"i'm not on \002$chan\002, sorry.");
353 if ($message =~ s/^do\s+(\S+)\s+(.*)//) {
354 return unless (&hasFlag("o"));
355 my ($chan,$msg) = (lc $1, $2);
357 &DEBUG("chan => '$1', msg => '$msg'.");
359 # TODO: add nick destination.
360 if (&validChan($chan)) {
361 &action($chan, $msg);
363 &msg($who,"i'm not on \002$chan\002, sorry.");
370 if ($message =~ /^die$/) {
371 return unless (&hasFlag("n"));
375 &status("Dying by $who\'s request");
379 # global factoid substitution.
380 if ($message =~ m|^s([/,#])(.+?)\1(.*?)\1;?\s*$|) {
381 my ($delim,$op,$np) = ($1, $2, $3);
382 return unless (&hasFlag("n"));
383 ### TODO: support flags to do full-on global.
386 if ($np =~ /$delim/) {
387 &performReply("looks like you used the delimiter too many times. You may want to use a different delimiter, like ':' or '#'.");
391 ### TODO: fix up $op to support mysql/sqlite/pgsql
392 ### TODO: => add db/sql specific function to fix this.
393 my @list = &searchTable("factoids", "factoid_key",
394 "factoid_value", $op);
397 &performReply("Expression didn't match anything.");
401 if (scalar @list > 100) {
402 &performReply("regex found more than 100 matches... not doing.");
406 &status("gsubst: going to alter ".scalar(@list)." factoids.");
407 &performReply("going to alter ".scalar(@list)." factoids.");
413 next if (&IsLocked($faqtoid) == 1);
414 my $result = &getFactoid($faqtoid);
416 &DEBUG("was($faqtoid) => '$was'.");
419 # we could support global local (once off).
420 if ($result =~ s/\Q$op/$np/gi) {
421 if (length $result > $param{'maxDataSize'}) {
422 &performReply("that's too long (or was long)");
425 &setFactInfo($faqtoid, "factoid_value", $result);
426 &status("update: '$faqtoid' =is=> '$result'; was '$was'");
428 &WARN("subst: that's weird... thought we found the string ($op) in '$faqtoid'.");
434 &ERROR("Some warnings/errors?");
437 &performReply("Ok... did s/$op/$np/ for ".
438 (scalar(@list) - $error)." factoids");
444 if ($message =~ /^jump(\s+(\S+))?$/i) {
445 return unless (&hasFlag("n"));
453 if ($2 =~ /^(\S+)(:(\d+))?$/) {
457 &msg($who,"invalid format.");
461 &status("jumping servers... $server...");
462 $conn->quit("jumping to $server");
464 if (&irc($server,$port) == 0) {
470 if ($message =~ /^reload$/i) {
471 return unless (&hasFlag("n"));
473 &status("USER reload $who");
474 &pSReply("reloading...");
476 &pSReply("reloaded.");
482 if ($message =~ /^reset$/i) {
483 return unless (&hasFlag("n"));
485 &msg($who,"resetting...");
487 foreach ( keys %channels, keys %chanconf ) {
489 next if (grep /^\Q$c\E$/i, @done);
496 &DEBUG("before clearircvars");
498 &DEBUG("before joinnextchan");
500 &DEBUG("after joinnextchan");
502 &status("USER reset $who");
503 &msg($who,"reset complete");
509 if ($message =~ /^rehash$/) {
510 return unless (&hasFlag("n"));
512 &msg($who,"rehashing...");
514 &status("USER rehash $who");
515 &msg($who,"rehashed");
521 ##### USER//CHAN SPECIFIC CONFIGURATION COMMANDS
524 if ($message =~ /^chaninfo(\s+(.*))?$/) {
525 my @args = split /[\s\t]+/, $2; # hrm.
527 if (scalar @args != 1) {
532 if (!exists $chanconf{$args[0]}) {
533 &pSReply("no such channel $args[0]");
537 &pSReply("showing channel conf.");
538 foreach (sort keys %{ $chanconf{$args[0]} }) {
539 &pSReply("$chan: $_ => $chanconf{$args[0]}{$_}");
541 &pSReply("End of chaninfo.");
547 if ($message =~ /^(chanset|\+chan)(\s+(.*?))?$/) {
552 if (!defined $args) {
558 while ($args =~ s/^($mask{chan})\s*//) {
559 push(@chans, lc($1));
562 if (!scalar @chans) {
563 push(@chans, "_default");
567 my($what,$val) = split /[\s\t]+/, $args, 2;
569 ### TODO: "cannot set values without +m".
570 return unless (&hasFlag("n"));
573 if (defined $what and $what !~ /^[-+]/ and !defined $val and $no_chan) {
574 &pSReply("Showing $what values on all channels...");
577 foreach (keys %chanconf) {
579 if (defined $chanconf{$_}{$what}) {
580 $val = $chanconf{$_}{$what};
587 foreach (keys %vals) {
588 &pSReply(" $what = $_(" . scalar(keys %{$vals{$_}}) . "): ".join(' ', sort keys %{ $vals{$_} } ) );
591 &pSReply("End of list.");
596 ### TODO: move to UserDCC again.
597 if ($cmd eq "chanset" and !defined $what) {
598 &DEBUG("showing channel conf.");
600 foreach $chan (@chans) {
601 if ($chan eq '_default') {
602 &pSReply("Default channel settings");
604 &pSReply("chan: $chan (see _default also)");
608 foreach (sort keys %{ $chanconf{$chan} }) {
609 my $newstr = join(', ', @items);
610 ### TODO: make length use channel line limit?
611 if (length $newstr > 370) {
616 push(@items, "$_ => $chanconf{$chan}{$_}");
618 &pSReply(" $str") if (@items);
623 $cache{confvars}{$what} = $val;
627 &chanSet($cmd, $_, $what, $val);
633 if ($message =~ /^(chanunset|\-chan)(\s+(.*))?$/) {
634 return unless (&hasFlag("n"));
638 if (!defined $args) {
645 if ($args =~ s/^(\-)?($mask{chan})\s*//) {
647 $delete = ($1) ? 1 : 0;
649 &VERB("no chan arg; setting to default.",2);
654 if (!exists $chanconf{$chan}) {
655 &pSReply("no such channel $chan");
661 if (!&getChanConf($args,$chan)) {
662 &pSReply("$args does not exist for $chan");
666 my @chans = &ChanConfList($args);
667 &DEBUG("scalar chans => ".scalar(@chans) );
668 if (scalar @chans == 1 and $chans[0] eq "_default" and !$no_chan) {
669 &psReply("ok, $args was set only for _default; unsetting for _defaul but setting for other chans.");
671 my $val = $chanconf{$_}{_default};
672 foreach (keys %chanconf) {
673 $chanconf{$_}{$args} = $val;
675 delete $chanconf{_default}{$args};
676 $cache{confvars}{$args} = 0;
682 if ($no_chan and !exists($chanconf{_default}{$args})) {
683 &pSReply("ok, $args for _default does not exist, removing from all chans.");
685 foreach (keys %chanconf) {
686 next unless (exists $chanconf{$_}{$args});
687 &DEBUG("delete chanconf{$_}{$args};");
688 delete $chanconf{$_}{$args};
690 $cache{confvars}{$args} = 0;
696 &pSReply("Unsetting channel ($chan) option $args. (was $chanconf{$chan}{$args})");
697 delete $chanconf{$chan}{$args};
703 &pSReply("Deleting channel $chan for sure!");
704 $utime_chanfile = time();
708 &pSReply("Leaving $chan...");
710 delete $chanconf{$chan};
712 &pSReply("Prefix channel with '-' to delete for sure.");
718 if ($message =~ /^newpass(\s+(.*))?$/) {
719 my(@args) = split /[\s\t]+/, $2 || '';
721 if (scalar @args != 1) {
726 my $u = &getUser($who);
727 my $crypt = &mkcrypt($args[0]);
729 &pSReply("Set your passwd to '$crypt'");
730 $users{$u}{PASS} = $crypt;
732 $utime_userfile = time();
738 if ($message =~ /^chpass(\s+(.*))?$/) {
739 my(@args) = split /[\s\t]+/, $2 || '';
746 if (!&IsUser($args[0])) {
747 &pSReply("user $args[0] is not valid.");
751 my $u = &getUser($args[0]);
753 &pSReply("Internal error, u = NULL.");
757 if (scalar @args == 1) {
759 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
760 &pSReply("cannot remove passwd of others.");
764 if (!exists $users{$u}{PASS}) {
765 &pSReply("$u does not have pass set anyway.");
769 &pSReply("Deleted pass from $u.");
771 $utime_userfile = time();
774 delete $users{$u}{PASS};
779 my $crypt = &mkcrypt($args[1]);
780 &pSReply("Set $u's passwd to '$crypt'");
781 $users{$u}{PASS} = $crypt;
783 $utime_userfile = time();
789 if ($message =~ /^chattr(\s+(.*))?$/) {
790 my(@args) = split /[\s\t]+/, $2 || '';
799 if ($args[0] =~ /^$mask{nick}$/i) {
801 $user = &getUser($args[0]);
805 $user = &getUser($who);
806 &DEBUG("user $who... nope.") unless (defined $user);
807 $user = &getUser($verifyUser);
811 if (!defined $user) {
812 &pSReply("user does not exist.");
816 my $flags = $users{$user}{FLAGS};
817 if (!defined $chflag) {
818 &pSReply("Flags for $user: $flags");
822 &DEBUG("who => $who");
823 &DEBUG("verifyUser => $verifyUser");
824 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
825 &pSReply("cannto change attributes of others.");
831 foreach (split //, $chflag) {
832 if ($_ eq "+") { $state = 1; next; }
833 if ($_ eq "-") { $state = 0; next; }
835 if (!defined $state) {
836 &pSReply("no initial + or - was found in attr.");
841 next if ($flags =~ /\Q$_\E/);
844 if (&IsParam("owner")
845 and $param{owner} =~ /^\Q$user\E$/i
846 and $flags =~ /[nmo]/
848 &pSReply("not removing flag $_ for $user.");
851 next unless ($flags =~ s/\Q$_\E//);
858 $utime_userfile = time();
860 &pSReply("Current flags: $flags");
861 $users{$user}{FLAGS} = $flags;
863 &pSReply("No flags changed: $flags");
869 if ($message =~ /^chnick(\s+(.*))?$/) {
870 my(@args) = split /[\s\t]+/, $2 || '';
872 if ($who eq "_default") {
873 &WARN("$who or verifyuser tried to run chnick.");
877 if (!scalar @args or scalar @args > 2) {
882 if (scalar @args == 1) { # 1
883 $user = &getUser($who);
884 &DEBUG("nope, not $who.") unless (defined $user);
885 $user ||= &getUser($verifyUser);
888 $user = &getUser($args[0]);
892 if (!defined $user) {
893 &pSReply("user $who or $args[0] does not exist.");
897 if ($user =~ /^\Q$chnick\E$/i) {
898 &pSReply("user == chnick. why should I do that?");
902 if (&getUser($chnick)) {
903 &pSReply("user $chnick is already used!");
907 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
908 &pSReply("cannto change nick of others.");
909 return "REPLY" if ($who eq "_default");
913 foreach (keys %{ $users{$user} }) {
914 $users{$chnick}{$_} = $users{$user}{$_};
915 delete $users{$user}{$_};
917 undef $users{$user}; # ???
919 $utime_userfile = time();
922 &pSReply("Changed '$user' to '$chnick' successfully.");
927 if ($message =~ /^([-+])host(\s+(.*))?$/) {
929 my(@args) = split /[\s\t]+/, $3 || '';
930 my $state = ($1 eq "+") ? 1 : 0;
937 if ($who eq "_default") {
938 &WARN("$who or verifyuser tried to run $cmd.");
943 if ($args[0] =~ /^$mask{nick}$/i) { # <nick>
944 return unless (&hasFlag("n"));
945 $user = &getUser($args[0]);
948 # FIXME: who or verifyUser. (don't remember why)
949 $user = &getUser($who);
953 if (!defined $user) {
954 &pSReply("user $user does not exist.");
958 if (!defined $mask) {
959 &pSReply("Hostmasks for $user: " . join(" ", keys %{$users{$user}{HOSTS}}));
963 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
964 &pSReply("cannto change masks of others.");
968 my $count = scalar keys %{ $users{$user}{HOSTS} };
971 if ($mask !~ /^$mask{nuh}$/) {
972 &pSReply("error: mask ($mask) is not a real hostmask.");
976 if (exists $users{$user}{HOSTS}{$mask}) {
977 &pSReply("mask $mask already exists.");
981 ### TODO: override support.
982 $users{$user}{HOSTS}{$mask} = 1;
984 &pSReply("Added $mask to list of masks.");
988 if (!exists $users{$user}{HOSTS}{$mask}) {
989 &pSReply("mask $mask does not exist.");
993 ### TODO: wildcard support. ?
994 delete $users{$user}{HOSTS}{$mask};
996 if (scalar keys %{ $users{$user}{HOSTS} } != $count) {
997 &pSReply("Removed $mask from list of masks.");
999 &pSReply("error: could not find $mask in list of masks.");
1004 $utime_userfile = time();
1010 if ($message =~ /^([-+])ban(\s+(.*))?$/) {
1013 my(@args) = split /[\s\t]+/, $3 || '';
1014 my $state = ($1 eq "+") ? 1 : 0;
1016 if (!scalar @args) {
1021 my($mask,$chan,$time,$reason);
1023 if ($flatarg =~ s/^($mask{nuh})\s*//) {
1026 &DEBUG("arg does not contain nuh mask?");
1029 if ($flatarg =~ s/^($mask{chan})\s*//) {
1032 $chan = "*"; # _default instead?
1035 if ($state == 0) { # delete.
1036 my @c = &banDel($mask);
1043 &pSReply("Removed $mask from chans: @c");
1045 &pSReply("$mask was not found in ban list.");
1056 if ($flatarg =~ s/^(\d+)\s*//) {
1058 &DEBUG("time = $time.");
1060 &pSReply("error: time cannot be negatime?");
1067 if ($flatarg =~ s/^(.*)$//) { # need length?
1071 if (!&IsFlag("n") and $who !~ /^\Q$verifyUser\E$/i) {
1072 &pSReply("cannto change masks of others.");
1076 if ($mask !~ /^$mask{nuh}$/) {
1077 &pSReply("error: mask ($mask) is not a real hostmask.");
1081 if ( &banAdd($mask,$chan,$time,$reason) == 2) {
1082 &pSReply("ban already exists; overwriting.");
1084 &pSReply("Added $mask for $chan (time => $time, reason => $reason)");
1089 if ($message =~ /^whois(\s+(.*))?$/) {
1092 if (!defined $arg) {
1097 my $user = &getUser($arg);
1098 if (!defined $user) {
1099 &pSReply("whois: user $user does not exist.");
1103 ### TODO: better (eggdrop-like) output.
1104 &pSReply("user: $user");
1105 foreach (keys %{ $users{$user} }) {
1106 my $ref = ref $users{$user}{$_};
1108 if ($ref eq "HASH") {
1110 ### DOES NOT WORK???
1111 foreach (keys %{ $users{$user}{$type} }) {
1112 &pSReply(" $type => $_");
1117 &pSReply(" $_ => $users{$user}{$_}");
1119 &pSReply("End of USER whois.");
1124 if ($message =~ /^bans(\s+(.*))?$/) {
1128 if ($arg ne "_default" and !&validChan($arg) ) {
1129 &pSReply("error: chan $chan is invalid.");
1134 if (!scalar keys %bans) {
1135 &pSReply("Ban list is empty.");
1140 &pSReply(" mask: expire, time-added, count, who-by, reason");
1141 foreach $c (keys %bans) {
1142 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1145 foreach (keys %{ $bans{$c} }) {
1146 my $val = $bans{$c}{$_};
1148 if (ref $val eq "ARRAY") {
1149 my @array = @{ $val };
1150 &pSReply(" $_: @array");
1152 &DEBUG("unknown ban: $val");
1156 &pSReply("END of bans.");
1161 if ($message =~ /^banlist(\s+(.*))?$/) {
1164 if (defined $arg and $arg !~ /^$mask{chan}$/) {
1165 &pSReply("error: chan $chan is invalid.");
1169 &DEBUG("bans for global or arg => $arg.");
1170 foreach (keys %bans) { #CHANGE!!!
1171 &DEBUG(" $_ => $bans{$_}.");
1174 &DEBUG("End of bans.");
1175 &pSReply("END of bans.");
1180 if ($message =~ /^save$/) {
1181 return unless (&hasFlag("o"));
1185 &pSReply("saved user and chan files");
1191 $message =~ s/^addignore/+ignore/;
1192 $message =~ s/^(del|un)ignore/-ignore/;
1195 if ($message =~ /^(\+|\-)ignore(\s+(.*))?$/i) {
1196 return unless (&hasFlag("o"));
1197 my $state = ($1 eq "+") ? 1 : 0;
1198 my $str = $1."ignore";
1206 my($mask,$chan,$time,$comment);
1209 if ($args =~ s/^($mask{nuh})\s*//) {
1212 &ERROR("no NUH mask?");
1216 if (!$state) { # delignore.
1217 if ( &ignoreDel($mask) ) {
1218 &pSReply("ok, deleted ignores for $mask.");
1220 &pSReply("could not find $mask in ignore list.");
1230 if ($args =~ s/^($mask{chan}|\*)\s*//) {
1237 if ($args =~ s/^(\d+)\s*//) {
1238 $time = $1; # time is in minutes
1247 $comment = "added by $who";
1250 if ( &ignoreAdd($mask, $chan, $time, $comment) > 1) {
1251 &pSReply("FIXME: $mask already in ignore list; written over anyway.");
1253 &pSReply("added $mask to ignore list.");
1259 if ($message =~ /^ignore(\s+(.*))?$/) {
1263 if ($arg !~ /^$mask{chan}$/) {
1264 &pSReply("error: chan $chan is invalid.");
1268 if (!&validChan($arg)) {
1269 &pSReply("error: chan $arg is invalid.");
1273 &pSReply("Showing bans for $arg only.");
1276 if (!scalar keys %ignore) {
1277 &pSReply("Ignore list is empty.");
1281 ### TODO: proper (eggdrop-like) formatting.
1283 &pSReply(" mask: expire, time-added, who, comment");
1284 foreach $c (keys %ignore) {
1285 next unless (!defined $arg or $arg =~ /^\Q$c\E$/i);
1288 foreach (keys %{ $ignore{$c} }) {
1289 my $ref = ref $ignore{$c}{$_};
1290 if ($ref eq "ARRAY") {
1291 my @array = @{ $ignore{$c}{$_} };
1292 &pSReply(" $_: @array");
1294 &DEBUG("unknown ignore line?");
1298 &pSReply("END of ignore.");
1304 if ($message =~ /^(\+|\-|add|del)user(\s+(.*))?$/i) {
1306 my $strstr = $1."user";
1307 my @args = split /\s+/, $3 || '';
1309 my $state = ($str =~ /^(\+|add)$/) ? 1 : 0;
1311 if (!scalar @args) {
1317 if (scalar @args != 2) {
1318 &pSReply("+user requires hostmask argument.");
1321 } elsif (scalar @args != 1) {
1322 &pSReply("too many arguments.");
1328 if (scalar @args == 1) {
1329 $args[1] = &getHostMask($args[0]);
1330 &pSReply("Attemping to guess $args[0]'s hostmask...");
1332 # crude hack... crappy Net::IRC
1333 $conn->schedule(5, sub {
1334 # hopefully this is right.
1335 my $nick = (keys %{ $cache{nuhInfo} })[0];
1336 if (!defined $nick) {
1337 &pSReply("couldn't get nuhinfo... adding user without a hostmask.");
1341 my $mask = &makeHostMask( $cache{nuhInfo}{$nick}{NUH} );
1343 if ( &userAdd($nick, $mask) ) {
1345 &pSReply("Added $nick with flags $users{$nick}{FLAGS}");
1346 my @hosts = keys %{ $users{$nick}{HOSTS} };
1347 &pSReply("hosts: @hosts");
1353 &DEBUG("args => @args");
1354 if ( &userAdd(@args) ) { # success.
1355 &pSReply("Added $args[0] with flags $users{$args[0]}{FLAGS}");
1356 my @hosts = keys %{ $users{$args[0]}{HOSTS} };
1357 &pSReply("hosts: @hosts");
1360 &pSReply("User $args[0] already exists");
1365 if ( &userDel($args[0]) ) { # success.
1366 &pSReply("Deleted $args[0] successfully.");
1369 &pSReply("User $args[0] does not exist.");
1376 if ($message =~ /^sched$/) {
1381 foreach (keys %sched) {
1382 next unless (exists $sched{$_}{TIME});
1383 $time{ $sched{$_}{TIME}-time() }{$_} = 1;
1386 next unless (exists $sched{$_}{RUNNING});
1391 foreach (sort { $a <=> $b } keys %time) {
1392 my $str = join(", ", sort keys %{ $time{$_} });
1393 &DEBUG("time => $_, str => $str");
1394 push(@time, "$str (".&Time2String($_).")");
1397 &pSReply( &formListReply(0, "Schedulers: ", @time ) );
1398 &pSReply( &formListReply(0, "Scheds to run: ", sort @list ) );
1399 &pSReply( &formListReply(0, "Scheds running(should not happen?) ", sort @run ) );
1404 # quite a cool hack: reply in DCC CHAT.
1405 $msgType = "chat" if (exists $dcc{'CHAT'}{$who});
1408 $done++ if &parseCmdHook("main", $message);
1409 $done++ if &parseCmdHook("extra", $message);
1410 $done++ unless (&Modules());
1413 &DEBUG("running non DCC CHAT command inside DCC CHAT!");