2 # IrcHooks.pl: IRC Hooks stuff.
5 # NOTE: Based on code by Kevin Lenzo & Patrick Cole (c) 1997
8 if (&IsParam("useStrict")) { use strict; }
14 my ($self, $event) = @_;
15 my $nick = $event->nick();
16 my $chan = ($event->to)[0];
18 &DEBUG("on_generic: nick => '$nick'.");
19 &DEBUG("on_generic: chan => '$chan'.");
21 foreach ($event->args) {
22 &DEBUG("on_generic: args => '$_'.");
27 my ($self, $event) = @_;
28 my ($nick, @args) = ($event->nick, $event->args);
29 my $chan = ($event->to)[0];
33 if ($chan eq $ident) {
34 &status("* [$nick] @args");
36 &status("* $nick/$chan @args");
41 my ($self, $event) = @_;
42 my $msg = ($event->args)[0];
43 my $sock = ($event->to)[0];
44 my $nick = $event->nick();
46 if (!exists $nuh{lc $nick}) {
47 &DEBUG("chat: nuh{$nick} doesn't exist; hrm should retry.");
48 &msg($nick, "could not get whois info?");
54 $orig{message} = $msg;
56 $uh = (split /\!/, $nuh)[1];
61 if (!exists $dcc{'CHATvrfy'}{$nick}) {
62 $userHandle = &verifyUser($who, $nuh);
63 my $crypto = $users{$userHandle}{PASS};
66 if (!defined $crypto) {
67 &DEBUG("chat: no pass required.");
70 } elsif (&ckpasswd($msg, $crypto)) {
71 # stolen from eggdrop.
72 $self->privmsg($sock, "Connected to $ident");
73 $self->privmsg($sock, "Commands start with '.' (like '.quit' or '.help')");
74 $self->privmsg($sock, "Everything else goes out to the party line.");
76 &dccStatus(2) if (scalar keys %{ $dcc{'CHAT'} } == 1);
81 &status("DCC CHAT: incorrect pass; closing connection.");
82 &DEBUG("chat: sock => '$sock'.");
84 delete $dcc{'CHAT'}{$nick};
85 &DEBUG("chat: after closing sock. FIXME");
86 ### BUG: close seizes bot. why?
90 &status("DCC CHAT: user $nick is here!");
91 # &DCCBroadcast("$nick ($uh) has joined the chat arena.");
92 &DCCBroadcast("*** $nick ($uh) joined the party line.");
94 $dcc{'CHATvrfy'}{$nick} = 1;
95 if ($userHandle ne "_default") {
96 &dccsay($nick,"Flags: $users{$userHandle}{FLAGS}");
103 $userHandle = &verifyUser($who, $nuh);
104 &status("$b_red=$b_cyan$who$b_red=$ob $message");
106 if ($message =~ s/^\.//) { # dcc chat commands.
107 ### TODO: make use of &Forker(); here?
108 &loadMyModule($myModules{'ircdcc'});
110 &DCCBroadcast("#$who# $message","m");
112 my $retval = &userDCC();
113 return unless (defined $retval);
114 return if ($retval eq $noreply);
116 $conn->privmsg($dcc{'CHAT'}{$who}, "Invalid command.");
118 } else { # dcc chat arena.
120 foreach (keys %{$dcc{'CHAT'}}) {
121 $conn->privmsg($dcc{'CHAT'}{$_}, "<$who> $orig{message}");
125 return 'DCC CHAT MESSAGE';
131 # what's the following for?
132 $ident = $param{'ircNick'};
134 $ircstats{'ConnectTime'} = time();
135 $ircstats{'ConnectCount'}++;
137 if (&IsParam("wingate")) {
138 my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
142 next unless (/^(\S+)\*$/);
143 push(@wingateBad, $_);
149 $conn->schedule(60, \&setupSchedulers, "");
153 if (&IsParam("ircUMode")) {
154 &status("Attempting change of user modes to $param{'ircUMode'}.");
155 &rawout("MODE $ident $param{'ircUMode'}");
158 &status("End of motd. Now lets join some channels...");
159 if (!scalar @joinchan) {
160 &WARN("joinchan array is empty!!!");
161 @joinchan = &getJoinChans();
168 my ($self, $event) = @_;
169 my $type = uc( ($event->args)[1] );
170 my $nick = $event->nick();
172 # pity Net::IRC doesn't store nuh. Here's a hack :)
176 if ($type eq 'SEND') { # GET for us.
177 # incoming DCC SEND. we're receiving a file.
178 my $get = ($event->args)[2];
179 open(DCCGET,">$get");
181 $self->new_get($nick,
188 } elsif ($type eq 'GET') { # SEND for us?
189 &DEBUG("starting get.");
190 $self->new_send($event->args);
191 } elsif ($type eq 'CHAT') {
192 &DEBUG("starting chat.");
193 $self->new_chat($event);
195 &WARN("${b_green}DCC $type$ob (1)");
200 my ($self, $event) = @_;
201 my $nick = $event->nick();
202 my $sock = ($event->to)[0];
204 # DCC CHAT close on fork exit workaround.
205 if ($bot_pid != $$) {
206 &WARN("run-away fork; exiting.");
210 &DEBUG("dcc_close: nick => '$nick'.");
212 if (exists $dcc{'SEND'}{$nick} and -f "$param{tempDir}/$nick.txt") {
213 &status("${b_green}DCC SEND$ob close from $b_cyan$nick$ob");
215 &status("dcc_close: purging $nick.txt from Debian.pl");
216 unlink "$param{tempDir}/$nick.txt";
218 delete $dcc{'SEND'}{$nick};
219 } elsif (exists $dcc{'CHAT'}{$nick} and $dcc{'CHAT'}{$nick} eq $sock) {
220 &status("${b_green}DCC CHAT$ob close from $b_cyan$nick$ob");
221 delete $dcc{'CHAT'}{$nick};
223 &status("${b_green}DCC$ob UNKNOWN close from $b_cyan$nick$ob (2)");
228 my ($self, $event) = @_;
229 my $type = uc( ($event->args)[0] );
230 my $nick = $event->nick();
231 my $sock = ($event->to)[0];
236 if ($type eq 'SEND') {
237 &status("${b_green}DCC lGET$ob established with $b_cyan$nick$ob");
238 } elsif ($type eq 'CHAT') {
239 &status("${b_green}DCC CHAT$ob established with $b_cyan$nick$ob $b_yellow($ob$nuh{$nick}$b_yellow)$ob");
240 $userHandle = &verifyUser($nick, $nuh{lc $nick});
241 my $crypto = $users{$userHandle}{PASS};
242 $dcc{'CHAT'}{$nick} = $sock;
244 foreach (keys %{ $users{$userHandle} }) {
245 &VERB(" $_ => $users{$userHandle}{$_}",2);
248 if (defined $crypto) {
249 ### &dccsay($nick,"Enter your password, $userHandle.");
250 &dccsay($nick,"Enter your password.");
252 &dccsay($nick,"Welcome to blootbot DCC CHAT interface, $userHandle.");
254 } elsif ($type eq 'SEND') {
255 &DEBUG("Starting DCC receive.");
256 foreach ($event->args) {
260 &WARN("${b_green}DCC $type$ob (3)");
265 my ($self, $event) = @_;
266 my $from = $event->from();
267 my $what = ($event->args)[0];
269 &status("disconnect from $from ($what).");
270 $ircstats{'DisconnectTime'} = time();
271 $ircstats{'DisconnectReason'} = $what;
272 $ircstats{'DisconnectCount'}++;
274 # clear any variables on reconnection.
278 if (!$self->connect()) {
279 &WARN("not connected? help me. gonna call ircCheck() in 1800s");
280 $conn->schedule(1800, \&ircCheck(), "");
285 my ($self, $event) = @_;
286 my $chan = ($event->args)[1];
288 if (exists $jointime{$chan}) {
289 my $delta_time = sprintf("%.03f", &gettimeofday() - $jointime{$chan});
290 $delta_time = 0 if ($delta_time < 0);
292 &status("$b_blue$chan$ob: sync in ${delta_time}s.");
295 rawout("MODE $chan");
299 foreach ("o","v","") {
300 my $count = scalar(keys %{$channels{$chan}{$_}});
301 next unless ($count);
303 $txt = "total" if ($_ eq "");
304 $txt = "voice" if ($_ eq "v");
305 $txt = "ops" if ($_ eq "o");
307 push(@array, "$count $txt");
309 my $chanstats = join(' || ', @array);
310 &status("$b_blue$chan$ob: [$chanstats]");
312 if (scalar @joinchan) { # remaining channels to join.
315 ### chanserv support.
316 ### TODO: what if we rejoin a channel.. need to set a var that
317 ### we've done the request-for-ops-on-join.
318 return unless (&IsParam("chanServ_ops"));
319 return unless ($nickserv);
321 my @chans = split(/[\s\t]+/, $param{'chanServ_ops'});
323 ### TODO: since this function has a chan arg, why don't we use
324 ### that instead of doing the following?
325 foreach $chan (keys %channels) {
326 next unless (grep /^$chan$/i, @chans);
328 if (!exists $channels{$chan}{'o'}{$ident}) {
329 &status("ChanServ ==> Requesting ops for $chan.");
330 &rawout("PRIVMSG ChanServ :OP $chan $ident");
338 my ($self, $event) = @_;
339 my (@args) = ($event->args);
346 my ($self, $event) = @_;
347 my $chan = ($event->args)[0];
348 my $nick = $event->nick;
350 &DEBUG("on_invite: chan => '$chan', nick => '$nick'.");
352 # chan + possible_key.
353 ### do we need to know the key if we're invited???
354 ### grep the channel list?
355 foreach (split /[\s\t]+/, $param{'join_channels'}) {
356 next unless /^\Q$chan\E(,\S+)?$/i;
359 next if ($nick =~ /^\Q$ident\E$/);
360 if (&validChan($chan)) {
361 &msg($who, "i'm already in \002$chan\002.");
365 &status("invited to $b_blue$_$ob by $b_cyan$who$ob");
366 &joinchan($self, $_);
371 my ($self, $event) = @_;
372 my ($user,$host) = split(/\@/, $event->userhost);
373 $chan = lc( ($event->to)[0] ); # CASING!!!!
374 $who = $event->nick();
376 $chanstats{$chan}{'Join'}++;
377 $userstats{lc $who}{'Join'} = time() if (&IsParam("seenStats"));
379 &joinfloodCheck($who, $chan, $event->userhost);
383 if (exists $netsplit{lc $who}) {
384 delete $netsplit{lc $who};
388 if ($netsplit and !$netsplittime) {
389 &status("ok.... re-running chanlimitCheck in 60.");
390 $conn->schedule(60, sub {
392 $netsplittime = undef;
395 $netsplittime = time();
398 # how to tell if there's a netjoin???
400 my $netsplitstr = "";
401 $netsplitstr = " $b_yellow\[${ob}NETSPLIT VICTIM$b_yellow]$ob" if ($netsplit);
402 &status(">>> join/$b_blue$chan$ob $b_cyan$who$ob $b_yellow($ob$user\@$host$b_yellow)$ob$netsplitstr");
404 $channels{$chan}{''}{$who}++;
405 $nuh{lc $who} = $who."!".$user."\@".$host unless (exists $nuh{lc $who});
408 &rootWarn($who,$user,$host,$chan)
409 if (&IsParam("rootWarn") &&
410 $user =~ /^r(oo|ew|00)t$/i &&
411 $channels{$chan}{'o'}{$ident});
413 # used to determine sync time.
414 if ($who =~ /^$ident$/i) {
415 if (defined( my $whojoin = $joinverb{$chan} )) {
416 &msg($chan, "Okay, I'm here. (courtesy of $whojoin)");
417 delete $joinverb{$chan};
420 ### TODO: move this to &joinchan()?
421 $jointime{$chan} = &gettimeofday();
424 ### TODO: this may go wild on a netjoin :)
431 my ($self, $event) = @_;
432 my ($chan,$reason) = $event->args;
433 my $kicker = $event->nick;
434 my $kickee = ($event->to)[0];
435 my $uh = $event->userhost();
437 &status(">>> kick/$b_blue$chan$ob [$b$kickee!$uh$ob] by $b_cyan$kicker$ob $b_yellow($ob$reason$b_yellow)$ob");
439 $chan = lc $chan; # forgot about this, found by xsdg, 20001229.
440 $chanstats{$chan}{'Kick'}++;
442 if ($kickee eq $ident) {
443 &clearChanVars($chan);
445 &status("SELF attempting to rejoin lost channel $chan");
448 &DeleteUserInfo($kickee,$chan);
453 my ($self, $event) = @_;
454 my ($user, $host) = split(/\@/, $event->userhost);
455 my @args = $event->args();
456 my $nick = $event->nick();
457 my $chan = ($event->to)[0];
461 if ($nick eq $chan) { # UMODE
462 &status(">>> mode $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
464 &status(">>> mode/$b_blue$chan$ob $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
465 &hookMode($chan, @args);
470 my ($self, $event) = @_;
471 my $nick = $event->nick();
472 my ($myself,$chan,@args) = $event->args();
474 &hookMode(lc $chan, @args); # CASING.
478 my ($self, $event) = @_;
479 my $nick = $event->nick;
480 my $chan = lc ( ($event->to)[0] ); # CASING.
481 my $msg = ($event->args)[0];
483 ($user,$host) = split(/\@/, $event->userhost);
484 $uh = $event->userhost();
485 $nuh = $nick."!".$uh;
487 &hookMsg('private', $chan, $nick, $msg);
491 my ($self, $event) = @_;
492 my @args = $event->args;
493 my $chan = lc $args[2]; # CASING, the last of them!
495 foreach (split / /, @args[3..$#args]) {
496 $channels{$chan}{'o'}{$_}++ if s/\@//;
497 $channels{$chan}{'v'}{$_}++ if s/\+//;
498 $channels{$chan}{''}{$_}++;
503 my ($self, $event) = @_;
504 my $nick = $event->nick();
505 my $newnick = ($event->args)[0];
507 if (exists $netsplit{lc $newnick}) {
508 &status("Netsplit: $newnick/$nick came back from netsplit and changed to original nick! removing from hash.");
509 delete $netsplit{lc $newnick};
513 foreach $chan (keys %channels) {
514 foreach $mode (keys %{$channels{$chan}}) {
515 next unless (exists $channels{$chan}{$mode}{$nick});
517 $channels{$chan}{$mode}{$newnick} = $channels{$chan}{$mode}{$nick};
520 &DeleteUserInfo($nick,keys %channels);
521 $nuh{lc $newnick} = $nuh{lc $nick};
522 delete $nuh{lc $nick};
524 # successful self-nick change.
525 if ($nick eq $ident) {
526 &status(">>> I materialized into $b_green$newnick$ob from $nick");
529 &status(">>> $b_cyan$nick$ob materializes into $b_green$newnick$ob");
535 my $nick = $self->nick;
536 my $newnick = substr($nick,0,7)."-";
538 &status("nick taken; changing to temporary nick.");
544 my ($self, $event) = @_;
545 my $nick = $event->nick();
546 my $chan = ($event->to)[0];
547 my $args = ($event->args)[0];
549 if ($nick =~ /^NickServ$/i) { # nickserv.
550 &status("NickServ: <== '$args'");
552 if ($args =~ /^This nickname is registered/i) {
553 &status("nickserv told us to register; doing it.");
554 if (&IsParam("nickServ_pass")) {
555 &status("NickServ: ==> Identifying.");
556 &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
559 &status("We can't tell nickserv a passwd ;(");
564 if ($args =~ /^Password a/i) {
567 } elsif ($nick =~ /^ChanServ$/i) { # chanserv.
568 &status("ChanServ: <== '$args'.");
570 if ($chan =~ /^$mask{chan}$/) { # channel notice.
571 &status("-$nick/$chan- $args");
573 $server = $nick unless (defined $server);
574 &status("-$nick- $args"); # private or server notice.
580 my ($self, $event) = @_;
581 my $chan = ($event->to)[0];
582 my $nick = $event->nick;
584 &status("!!! other called.");
585 &status("!!! $event->args");
589 my ($self, $event) = @_;
590 my $chan = lc( ($event->to)[0] ); # CASING!!!
591 my $nick = $event->nick;
592 my $userhost = $event->userhost;
594 if (!exists $floodjoin{$chan}{$nick}{Time}) {
595 &WARN("on_part: $nick/$chan not in floodjoin hash?");
597 delete $floodjoin{$chan}{$nick};
600 $chanstats{$chan}{'Part'}++;
601 &DeleteUserInfo($nick,$chan);
602 &clearChanVars($chan) if ($nick eq $ident);
603 if (!&IsNickInAnyChan($nick) and &IsParam("seenStats")) {
604 delete $userstats{lc $nick};
607 &status(">>> part/$b_blue$chan$ob $b_cyan$nick$ob $b_yellow($ob$userhost$b_yellow)$ob");
611 my ($self, $event) = @_;
612 my $nick = $event->nick;
614 $self->ctcp_reply($nick, join(' ', ($event->args)));
615 &status(">>> ${b_green}CTCP PING$ob request from $b_cyan$nick$ob received.");
619 my ($self, $event) = @_;
620 my $nick = $event->nick;
621 my $lag = time() - ($event->args)[1];
623 &status(">>> ${b_green}CTCP PING$ob reply from $b_cyan$nick$ob: $lag sec.");
627 my ($self, $event) = @_;
628 my $msg = ($event->args)[0];
629 my $chan = lc( ($event->to)[0] ); # CASING.
630 my $nick = $event->nick;
631 $uh = $event->userhost();
632 $nuh = $nick."!".$uh;
633 ($user,$host) = split(/\@/, $uh);
635 if ($bot_pid != $$) {
636 &ERROR("run-away fork; exiting.");
641 if ($statcount < 200) {
642 foreach $chan (grep /[A-Z]/, keys %channels) {
643 &DEBUG("leak: chan => '$chan'.");
645 foreach $i (keys %{$channels{$chan}}) {
646 foreach (keys %{$channels{$chan}{$i}}) {
647 &DEBUG("leak: \$channels{$chan}{$i}{$_} ...");
655 $lastWho{$chan} = $nick;
656 ### TODO: use $nick or lc $nick?
657 if (&IsParam("seenStats")) {
658 $userstats{lc $nick}{'Count'}++;
659 $userstats{lc $nick}{'Time'} = time();
662 # if (&IsParam("hehCounter")) {
666 &hookMsg('public', $chan, $nick, $msg);
667 $chanstats{$chan}{'PublicMsg'}++;
671 my ($self, $event) = @_;
672 my $nick = $event->nick();
673 my $reason = ($event->args)[0];
675 foreach (keys %channels) {
676 # fixes inconsistent chanstats bug #1.
677 next unless (&IsNickInChan($nick,$_));
678 $chanstats{$_}{'SignOff'}++;
680 &DeleteUserInfo($nick, keys %channels);
681 if (exists $nuh{lc $nick}) {
682 delete $nuh{lc $nick};
684 &DEBUG("on_quit: nuh{lc $nick} does not exist! FIXME");
686 delete $userstats{lc $nick} if (&IsParam("seenStats"));
688 # should fix chanstats inconsistencies bug #2.
689 if ($reason=~/^($mask{host})\s($mask{host})$/) { # netsplit.
690 $reason = "NETSPLIT: $1 <=> $2";
692 $netsplit{lc $nick} = time();
693 if (!exists $netsplitservers{$1}{$2}) {
694 &status("netsplit detected between $1 and $2.");
695 $netsplitservers{$1}{$2} = time();
699 &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob");
700 if ($nick =~ /^\Q$ident\E$/) {
701 &DEBUG("!!! THIS SHOULD NEVER HAPPEN. FIXME HOPEFULLY");
703 if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) {
704 &status("own nickname became free; changing.");
705 &nick($param{'ircNick'});
709 sub on_targettoofast {
710 my ($self, $event) = @_;
711 my $nick = $event->nick();
712 my $chan = ($event->to)[0];
714 &DEBUG("on_targettoofast: nick => '$nick'.");
715 &DEBUG("on_targettoofast: chan => '$chan'.");
717 foreach ($event->args) {
718 &DEBUG("on_targettoofast: args => '$_'.");
721 ### .* wait (\d+) second/) {
725 &status("going to sleep for $sleep...");
732 my ($self, $event) = @_;
734 if (scalar($event->args) == 1) { # change.
735 my $topic = ($event->args)[0];
736 my $chan = ($event->to)[0];
737 my $nick = $event->nick();
741 # race condition here. To fix, change '1' to '0'.
742 # This will keep track of topics set by bot only.
745 # this may be fixed at a later date with topic queueing.
748 $topic{$chan}{'Current'} = $topic if (1 and &IsParam("topic") == 1);
749 $chanstats{$chan}{'Topic'}++;
751 &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic");
753 my ($nick, $chan, $topic) = $event->args;
754 if (&IsParam("topic")) {
755 $topic{$chan}{'Current'} = $topic;
756 &topicAddHistory($chan,$topic);
759 $topic = &fixString($topic, 1);
760 &status(">>> topic/$b_blue$chan$ob is $topic");
765 my ($self, $event) = @_;
766 my ($myself,$chan,$setby,$time) = $event->args();
769 if (time() - $time > 60*60*24) {
770 $timestr = "at ". localtime $time;
772 $timestr = &Time2String(time() - $time) ." ago";
775 &status(">>> set by $b_cyan$setby$ob $timestr");
779 my ($self, $event) = @_;
780 my $nick = $event->nick;
782 &status(">>> ${b_green}CTCP VERSION$ob request from $b_cyan$nick$ob");
783 $self->ctcp_reply($nick, "VERSION $bot_version");
787 my ($self, $event) = @_;
788 my @args = $event->args;
790 $nuh{lc $args[5]} = $args[5]."!".$args[2]."\@".$args[3];
794 my ($self, $event) = @_;
795 my @args = $event->args;
797 $nuh{lc $args[1]} = $args[1]."!".$args[2]."\@".$args[3];
800 #######################################################################
801 ####### IRC HOOK HELPERS IRC HOOK HELPERS IRC HOOK HELPERS ########
802 #######################################################################
805 # Usage: &hookMode($chan, $modes, @targets);
807 my ($chan, $modes, @targets) = @_;
810 $chan = lc $chan; # !!!.
813 foreach $mode (split(//, $modes)) {
815 if ($mode =~ /[-+]/) {
816 $parity = 1 if ($mode eq "+");
817 $parity = 0 if ($mode eq "-");
822 if ($mode =~ /[bklov]/) {
823 my $target = shift @targets;
826 $chanstats{$chan}{'Op'}++ if ($mode eq "o");
827 $chanstats{$chan}{'Ban'}++ if ($mode eq "b");
829 $chanstats{$chan}{'Deop'}++ if ($mode eq "o");
830 $chanstats{$chan}{'Unban'}++ if ($mode eq "b");
833 # modes w/ target affecting nick => cache it.
834 if ($mode =~ /[ov]/) {
835 $channels{$chan}{$mode}{$target}++ if $parity;
836 delete $channels{$chan}{$mode}{$target} if !$parity;
839 if ($mode =~ /[l]/) {
840 $channels{$chan}{$mode} = $target if $parity;
841 delete $channels{$chan}{$mode} if !$parity;
845 # important channel modes, targetless.
846 if ($mode =~ /[mt]/) {
847 $channels{$chan}{$mode}++ if $parity;
848 delete $channels{$chan}{$mode} if !$parity;
854 ($msgType, $chan, $who, $message) = @_;
858 $orig{message} = $message;
862 $message =~ s/[\cA-\c_]//ig; # strip control characters
863 $message =~ s/^\s+//; # initial whitespaces.
864 $who =~ tr/A-Z/a-z/; # lowercase.
869 if ($msgType =~ /private/) {
874 # addressing revamped by the xk.
875 ### below needs to be fixed...
876 if (&IsParam("addressCharacter")) {
877 if ($message =~ s/^$param{'addressCharacter'}//) {
883 if ($message =~ /^($mask{nick})([\;\:\>\, ]+) */) {
885 if ($1 =~ /^\Q$ident\E$/i) {
886 $message = $newmessage;
889 # ignore messages addressed to other people or unaddressed.
890 $skipmessage++ if ($2 ne "" and $2 !~ /^ /);
895 # Determine floodwho.
896 if ($msgType =~ /public/i) { # public.
897 $floodwho = lc $chan;
898 } elsif ($msgType =~ /private/i) { # private.
901 &DEBUG("FIXME: floodwho = ???");
904 my ($count, $interval) = split(/:/, $param{'floodRepeat'} || "2:10");
906 # flood repeat protection.
908 my $time = $flood{$floodwho}{$message};
910 if (defined $time and (time - $time < $interval)) {
911 ### public != personal who so the below is kind of pointless.
913 foreach (keys %flood) {
914 next if (/^\Q$floodwho\E$/ or /^\Q$chan\E$/);
915 push(@who, grep /^\Q$message\E$/i, keys %{$flood{$_}});
918 &msg($who, "you already said what ".
919 join(' ', @who)." have said.");
921 &msg($who,"Someone already said that ". (time - $time) ." seconds ago" );
924 ### TODO: delete old floodwarn{} keys.
926 if (!exists $floodwarn{$floodwho}) {
929 $floodwarn++ if (time() - $floodwarn{$floodwho} > $interval);
933 &status("FLOOD repetition detected from $floodwho.");
934 $floodwarn{$floodwho} = time();
941 &status("$b_cyan$who$ob is short-addressing me");
943 &status("$b_cyan$who$ob is addressing me");
946 $flood{$floodwho}{$message} = time();
949 ($count, $interval) = split(/:/, $param{'floodMessages'} || "5:30");
950 # flood overflow protection.
952 foreach (keys %{$flood{$floodwho}}) {
953 next unless (time() - $flood{$floodwho}{$_} > $interval);
954 delete $flood{$floodwho}{$_};
957 my $i = scalar keys %{$flood{$floodwho}};
959 &msg($who,"overflow of messages ($i > $count)");
960 &status("FLOOD overflow detected from $floodwho; ignoring");
962 my $expire = $param{'ignoreAutoExpire'} || 5;
963 &ignoreAdd("*!$uh", $chan, $expire, "flood overflow auto-detected.");
967 $flood{$floodwho}{$message} = time();
971 if ($msgType =~ /public/i) {
972 $talkchannel = $chan;
973 &status("<$orig{who}/$chan> $orig{message}");
977 if ($msgType =~ /private/i) {
978 &status("[$orig{who}] $orig{message}");
981 if ((!$skipmessage or &IsParam("seenStoreAll")) and
985 $seencache{$who}{'time'} = time();
986 $seencache{$who}{'nick'} = $orig{who};
987 $seencache{$who}{'host'} = $uh;
988 $seencache{$who}{'chan'} = $talkchannel;
989 $seencache{$who}{'msg'} = $orig{message};
990 $seencache{$who}{'msgcount'}++;
993 return if ($skipmessage);
994 return unless (&IsParam("minVolunteerLength") or $addressed);
996 ### TODO: hash list of already-checked users.
997 ### eg: $ignoreChecked{$mask} = time();
1001 if (my @m = grep /^$nuh$/i, keys %ignoreChecked) {
1002 &DEBUG("found ignore for $nuh.");
1004 &DEBUG("masks => $_ ($ignoreChecked{$_})");
1008 foreach (keys %ignore) {
1010 &DEBUG("c = $_, chan = $chan.");
1012 foreach (keys %{ $ignore{$c} }) {
1016 next unless ($nuh =~ /^\Q$m\E$/i);
1018 $ignoreChecked{$nuh} = $c;
1023 if (!$ignore and !$checked) {
1024 push(@ignore_off, $nuh);
1028 $userHandle = &verifyUser($who, $nuh);
1030 &DEBUG("hookMsg: 'nuh' not defined?");
1033 ### For extra debugging purposes...
1034 if ($_ = &process()) {
1035 # &DEBUG("IrcHooks: process returned '$_'.");