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 = $userList{$userHandle}{'pass'};
66 if (!defined $crypto) {
67 &DEBUG("chat: no pass required.");
69 } elsif (&ckpasswd($msg, $crypto)) {
70 $self->privmsg($sock,"Authorized.");
71 $self->privmsg($sock,"I'll respond as if through /msg and addressed in public. Addition to that, access to 'user' commands will be allowed, like 'die' and 'jump'.");
72 # hrm... it's stupid to ask for factoids _within_ dcc chat.
73 # perhaps it should be default to commands, especially
74 # commands only authorized through DCC CHAT.
75 &status("DCC CHAT: passwd is ok.");
78 &status("DCC CHAT: incorrect pass; closing connection.");
79 &DEBUG("chat: sock => '$sock'.");
81 delete $dcc{'CHAT'}{$nick};
82 &DEBUG("chat: after closing sock. FIXME");
83 ### BUG: close seizes bot. why?
87 &status("DCC CHAT: user $nick is here!");
88 &DCCBroadcast("$nick ($uh) has joined the chat arena.");
89 $dcc{'CHATvrfy'}{$nick} = 1;
90 if ($userHandle ne "default") {
91 &dccsay($nick,"Flags: $userList{$userHandle}{'flags'}");
98 $userHandle = &verifyUser($who, $nuh);
99 &status("$b_red=$b_cyan$who$b_red=$ob $message");
100 if ($message =~ s/^\.//) { # dcc chat commands.
101 ### TODO: make use of &Forker(); here?
102 &loadMyModule($myModules{'ircdcc'});
103 return '$noreply from userD' if (&userDCC() eq $noreply);
104 $conn->privmsg($dcc{'CHAT'}{$who}, "Invalid command.");
106 } else { # dcc chat arena.
107 foreach (keys %{$dcc{'CHAT'}}) {
108 $conn->privmsg($dcc{'CHAT'}{$_}, "<$who> $orig{message}");
112 return 'DCC CHAT MESSAGE';
118 if (&IsParam("wingate")) {
119 my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
123 next unless (/^(\S+)\*$/);
124 push(@wingateBad, $_);
130 $conn->schedule(60, \&setupSchedulers, "");
134 if (&IsParam("ircUMode")) {
135 &status("Attempting change of user modes to $param{'ircUMode'}.");
136 &rawout("MODE $ident $param{'ircUMode'}");
139 &status("End of motd. Now lets join some channels...");
140 if (!scalar @joinchan) {
141 &WARN("joinchan array is empty!!!");
142 @joinchan = split /[\t\s]+/, $param{'join_channels'};
149 my ($self, $event) = @_;
150 my $type = uc( ($event->args)[1] );
151 my $nick = $event->nick();
153 # pity Net::IRC doesn't store nuh. Here's a hack :)
157 if ($type eq 'SEND') { # GET for us.
158 # incoming DCC SEND. we're receiving a file.
159 my $get = ($event->args)[2];
160 open(DCCGET,">$get");
162 $self->new_get($nick,
169 } elsif ($type eq 'GET') { # SEND for us?
170 &DEBUG("starting get.");
171 $self->new_send($event->args);
172 } elsif ($type eq 'CHAT') {
173 &DEBUG("starting chat.");
174 $self->new_chat($event);
176 &WARN("${b_green}DCC $type$ob (1)");
181 my ($self, $event) = @_;
182 my $nick = $event->nick();
183 my $sock = ($event->to)[0];
185 # DCC CHAT close on fork exit workaround.
186 return if ($bot_pid != $$);
188 &DEBUG("dcc_close: nick => '$nick'.");
190 if (exists $dcc{'SEND'}{$nick} and -f "$param{tempDir}/$nick.txt") {
191 &status("${b_green}DCC SEND$ob close from $b_cyan$nick$ob");
193 &status("dcc_close: purging $nick.txt from Debian.pl");
194 unlink "$param{tempDir}/$nick.txt";
196 delete $dcc{'SEND'}{$nick};
197 } elsif (exists $dcc{'CHAT'}{$nick} and $dcc{'CHAT'}{$nick} eq $sock) {
198 &status("${b_green}DCC CHAT$ob close from $b_cyan$nick$ob");
199 delete $dcc{'CHAT'}{$nick};
201 &status("${b_green}DCC$ob UNKNOWN close from $b_cyan$nick$ob (2)");
206 my ($self, $event) = @_;
207 my $type = uc( ($event->args)[0] );
208 my $nick = $event->nick();
209 my $sock = ($event->to)[0];
214 if ($type eq 'SEND') {
215 &status("${b_green}DCC lGET$ob established with $b_cyan$nick$ob");
216 } elsif ($type eq 'CHAT') {
217 &status("${b_green}DCC CHAT$ob established with $b_cyan$nick$ob $b_yellow($ob$nuh{$nick}$b_yellow)$ob");
218 $userHandle = &verifyUser($nick, $nuh{lc $nick});
219 my $crypto = $userList{$userHandle}{'pass'};
220 $dcc{'CHAT'}{$nick} = $sock;
222 if (defined $crypto) {
223 &dccsay($nick,"Enter Password, $userHandle.");
225 &dccsay($nick,"Welcome to blootbot DCC CHAT interface, $userHandle.");
227 } elsif ($type eq 'SEND') {
228 &DEBUG("Starting DCC receive.");
229 foreach ($event->args) {
233 &WARN("${b_green}DCC $type$ob (3)");
238 my ($self, $event) = @_;
239 my $from = $event->from();
240 my $what = ($event->args)[0];
242 &status("disconnect from $from ($what).");
243 $ircstats{'DisconnectTime'} = time();
244 $ircstats{'DisconnectReason'} = $what;
245 $ircstats{'DisconnectCount'}++;
247 # clear any variables on reconnection.
251 if (!$self->connect()) {
252 &WARN("not connected? help me. gonna call ircCheck() in 1800s");
253 $conn->schedule(1800, \&ircCheck(), "");
258 my ($self, $event) = @_;
259 my $chan = ($event->args)[1];
261 if (exists $jointime{$chan}) {
262 my $delta_time = sprintf("%.03f", &gettimeofday() - $jointime{$chan});
263 $delta_time = 0 if ($delta_time < 0);
265 &status("$b_blue$chan$ob: sync in ${delta_time}s.");
268 rawout("MODE $chan");
272 foreach ("o","v","") {
273 my $count = scalar(keys %{$channels{$chan}{$_}});
274 next unless ($count);
276 $txt = "total" if ($_ eq "");
277 $txt = "voice" if ($_ eq "v");
278 $txt = "ops" if ($_ eq "o");
280 push(@array, "$count $txt");
282 my $chanstats = join(' || ', @array);
283 &status("$b_blue$chan$ob: [$chanstats]");
285 if (scalar @joinchan) { # remaining channels to join.
288 ### chanserv support.
289 ### TODO: what if we rejoin a channel.. need to set a var that
290 ### we've done the request-for-ops-on-join.
291 return unless (&IsParam("chanServ_ops"));
292 return unless ($nickserv);
294 my @chans = split(/[\s\t]+/, $param{'chanServ_ops'});
296 ### TODO: since this function has a chan arg, why don't we use
297 ### that instead of doing the following?
298 foreach $chan (keys %channels) {
299 next unless (grep /^$chan$/i, @chans);
301 if (!exists $channels{$chan}{'o'}{$ident}) {
302 &status("ChanServ ==> Requesting ops for $chan.");
303 &rawout("PRIVMSG ChanServ :OP $chan $ident");
311 my ($self, $event) = @_;
312 my (@args) = ($event->args);
319 my ($self, $event) = @_;
320 my $chan = ($event->args)[0];
321 my $nick = $event->nick;
323 &DEBUG("on_invite: chan => '$chan', nick => '$nick'.");
325 # chan + possible_key.
326 ### do we need to know the key if we're invited???
327 ### grep the channel list?
328 foreach (split /[\s\t]+/, $param{'join_channels'}) {
329 next unless /^\Q$chan\E(,\S+)?$/i;
332 next if ($nick =~ /^\Q$ident\E$/);
333 if (&validChan($chan)) {
334 &msg($who, "i'm already in \002$chan\002.");
338 &status("invited to $b_blue$_$ob by $b_cyan$who$ob");
339 &joinchan($self, $_);
344 my ($self, $event) = @_;
345 my ($user,$host) = split(/\@/, $event->userhost);
346 $chan = lc( ($event->to)[0] ); # CASING!!!!
347 $who = $event->nick();
349 $chanstats{$chan}{'Join'}++;
350 $userstats{lc $who}{'Join'} = time() if (&IsParam("seenStats"));
352 &joinfloodCheck($who, $chan, $event->userhost);
356 if (exists $netsplit{lc $who}) {
357 delete $netsplit{lc $who};
361 if ($netsplit and !$netsplittime) {
362 &status("ok.... re-running chanlimitCheck in 60.");
363 $conn->schedule(60, sub {
365 $netsplittime = undef;
368 $netsplittime = time();
371 # how to tell if there's a netjoin???
373 my $netsplitstr = "";
374 $netsplitstr = " $b_yellow\[${ob}NETSPLIT VICTIM$b_yellow]$ob" if ($netsplit);
375 &status(">>> join/$b_blue$chan$ob $b_cyan$who$ob $b_yellow($ob$user\@$host$b_yellow)$ob$netsplitstr");
377 $channels{$chan}{''}{$who}++;
378 $nuh{lc $who} = $who."!".$user."\@".$host unless (exists $nuh{lc $who});
381 &rootWarn($who,$user,$host,$chan)
382 if (&IsParam("rootWarn") &&
383 $user =~ /^r(oo|ew|00)t$/i &&
384 $channels{$chan}{'o'}{$ident});
386 # used to determine sync time.
387 if ($who =~ /^$ident$/i) {
388 if (defined( my $whojoin = $joinverb{$chan} )) {
389 &msg($chan, "Okay, I'm here. (courtesy of $whojoin)");
390 delete $joinverb{$chan};
393 ### TODO: move this to &joinchan()?
394 $jointime{$chan} = &gettimeofday();
397 ### TODO: this may go wild on a netjoin :)
404 my ($self, $event) = @_;
405 my ($chan,$reason) = $event->args;
406 my $kicker = $event->nick;
407 my $kickee = ($event->to)[0];
408 my $uh = $event->userhost();
410 &status(">>> kick/$b_blue$chan$ob [$b$kickee!$uh$ob] by $b_cyan$kicker$ob $b_yellow($ob$reason$b_yellow)$ob");
412 $chan = lc $chan; # forgot about this, found by xsdg, 20001229.
413 $chanstats{$chan}{'Kick'}++;
415 if ($kickee eq $ident) {
416 &clearChanVars($chan);
418 &status("SELF attempting to rejoin lost channel $chan");
421 &DeleteUserInfo($kickee,$chan);
426 my ($self, $event) = @_;
427 my ($user, $host) = split(/\@/, $event->userhost);
428 my @args = $event->args();
429 my $nick = $event->nick();
430 my $chan = ($event->to)[0];
434 if ($nick eq $chan) { # UMODE
435 &status(">>> mode $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
437 &status(">>> mode/$b_blue$chan$ob $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
438 &hookMode($chan, @args);
443 my ($self, $event) = @_;
444 my $nick = $event->nick();
445 my ($myself,$chan,@args) = $event->args();
447 &hookMode(lc $chan, @args); # CASING.
451 my ($self, $event) = @_;
452 my $nick = $event->nick;
453 my $chan = lc ( ($event->to)[0] ); # CASING.
454 my $msg = ($event->args)[0];
456 ($user,$host) = split(/\@/, $event->userhost);
457 $uh = $event->userhost();
458 $nuh = $nick."!".$uh;
460 &hookMsg('private', $chan, $nick, $msg);
464 my ($self, $event) = @_;
465 my @args = $event->args;
466 my $chan = lc $args[2]; # CASING, the last of them!
468 foreach (split / /, @args[3..$#args]) {
469 $channels{$chan}{'o'}{$_}++ if s/\@//;
470 $channels{$chan}{'v'}{$_}++ if s/\+//;
471 $channels{$chan}{''}{$_}++;
476 my ($self, $event) = @_;
477 my $nick = $event->nick();
478 my $newnick = ($event->args)[0];
480 if (exists $netsplit{lc $newnick}) {
481 &status("Netsplit: $newnick/$nick came back from netsplit and changed to original nick! removing from hash.");
482 delete $netsplit{lc $newnick};
486 foreach $chan (keys %channels) {
487 foreach $mode (keys %{$channels{$chan}}) {
488 next unless (exists $channels{$chan}{$mode}{$nick});
490 $channels{$chan}{$mode}{$newnick} = $channels{$chan}{$mode}{$nick};
493 &DeleteUserInfo($nick,keys %channels);
494 $nuh{lc $newnick} = $nuh{lc $nick};
495 delete $nuh{lc $nick};
497 # successful self-nick change.
498 if ($nick eq $ident) {
499 &status(">>> I materialized into $b_green$newnick$ob from $nick");
502 &status(">>> $b_cyan$nick$ob materializes into $b_green$newnick$ob");
508 my $nick = $self->nick;
509 my $newnick = substr($nick,0,7)."-";
511 &status("nick taken; changing to temporary nick.");
517 my ($self, $event) = @_;
518 my $nick = $event->nick();
519 my $chan = ($event->to)[0];
520 my $args = ($event->args)[0];
522 if ($nick =~ /^NickServ$/i) { # nickserv.
523 &status("NickServ: <== '$args'");
525 if ($args =~ /^This nickname is registered/i) {
526 &status("nickserv told us to register; doing it.");
527 if (&IsParam("nickServ_pass")) {
528 &status("NickServ: ==> Identifying.");
529 &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
532 &status("We can't tell nickserv a passwd ;(");
537 if ($args =~ /^Password a/i) {
540 } elsif ($nick =~ /^ChanServ$/i) { # chanserv.
541 &status("ChanServ: <== '$args'.");
543 if ($chan =~ /^$mask{chan}$/) { # channel notice.
544 &status("-$nick/$chan- $args");
546 $server = $nick unless (defined $server);
547 &status("-$nick- $args"); # private or server notice.
553 my ($self, $event) = @_;
554 my $chan = ($event->to)[0];
555 my $nick = $event->nick;
557 &status("!!! other called.");
558 &status("!!! $event->args");
562 my ($self, $event) = @_;
563 my $chan = lc( ($event->to)[0] ); # CASING!!!
564 my $nick = $event->nick;
565 my $userhost = $event->userhost;
567 if (!exists $floodjoin{$chan}{$nick}{Time}) {
568 &WARN("on_part: $nick/$chan not in floodjoin hash?");
570 delete $floodjoin{$chan}{$nick};
573 $chanstats{$chan}{'Part'}++;
574 &DeleteUserInfo($nick,$chan);
575 &clearChanVars($chan) if ($nick eq $ident);
576 if (!&IsNickInAnyChan($nick) and &IsParam("seenStats")) {
577 delete $userstats{lc $nick};
580 &status(">>> part/$b_blue$chan$ob $b_cyan$nick$ob $b_yellow($ob$userhost$b_yellow)$ob");
584 my ($self, $event) = @_;
585 my $nick = $event->nick;
587 $self->ctcp_reply($nick, join(' ', ($event->args)));
588 &status(">>> ${b_green}CTCP PING$ob request from $b_cyan$nick$ob received.");
592 my ($self, $event) = @_;
593 my $nick = $event->nick;
594 my $lag = time() - ($event->args)[1];
596 &status(">>> ${b_green}CTCP PING$ob reply from $b_cyan$nick$ob: $lag sec.");
600 my ($self, $event) = @_;
601 my $msg = ($event->args)[0];
602 my $chan = lc( ($event->to)[0] ); # CASING.
603 my $nick = $event->nick;
604 $uh = $event->userhost();
605 $nuh = $nick."!".$uh;
606 ($user,$host) = split(/\@/, $uh);
608 if ($$ != $bot_pid) {
609 &ERROR("SHOULD NEVER HAPPEN.");
614 if ($statcount < 200) {
615 foreach $chan (grep /[A-Z]/, keys %channels) {
616 &DEBUG("leak: chan => '$chan'.");
618 foreach $i (keys %{$channels{$chan}}) {
619 foreach (keys %{$channels{$chan}{$i}}) {
620 &DEBUG("leak: \$channels{$chan}{$i}{$_} ...");
628 $lastWho{$chan} = $nick;
629 ### TODO: use $nick or lc $nick?
630 if (&IsParam("seenStats")) {
631 $userstats{lc $nick}{'Count'}++;
632 $userstats{lc $nick}{'Time'} = time();
635 # if (&IsParam("hehCounter")) {
639 &hookMsg('public', $chan, $nick, $msg);
640 $chanstats{$chan}{'PublicMsg'}++;
644 my ($self, $event) = @_;
645 my $nick = $event->nick();
646 my $reason = ($event->args)[0];
648 foreach (keys %channels) {
649 # fixes inconsistent chanstats bug #1.
650 next unless (&IsNickInChan($nick,$_));
651 $chanstats{$_}{'SignOff'}++;
653 &DeleteUserInfo($nick, keys %channels);
654 if (exists $nuh{lc $nick}) {
655 delete $nuh{lc $nick};
657 &DEBUG("on_quit: nuh{lc $nick} does not exist! FIXME");
659 delete $userstats{lc $nick} if (&IsParam("seenStats"));
661 # should fix chanstats inconsistencies bug #2.
662 if ($reason=~/^($mask{host})\s($mask{host})$/) { # netsplit.
663 $reason = "NETSPLIT: $1 <=> $2";
665 $netsplit{lc $nick} = time();
666 if (!exists $netsplitservers{$1}{$2}) {
667 &status("netsplit detected between $1 and $2.");
668 $netsplitservers{$1}{$2} = time();
672 &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob");
673 if ($nick =~ /^\Q$ident\E$/) {
674 &DEBUG("!!! THIS SHOULD NEVER HAPPEN. FIXME HOPEFULLY");
676 if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) {
677 &status("own nickname became free; changing.");
678 &nick($param{'ircNick'});
682 sub on_targettoofast {
683 my ($self, $event) = @_;
684 my $nick = $event->nick();
685 my $chan = ($event->to)[0];
687 &DEBUG("on_targettoofast: nick => '$nick'.");
688 &DEBUG("on_targettoofast: chan => '$chan'.");
690 foreach ($event->args) {
691 &DEBUG("on_targettoofast: args => '$_'.");
694 ### .* wait (\d+) second/) {
698 &status("going to sleep for $sleep...");
705 my ($self, $event) = @_;
707 if (scalar($event->args) == 1) { # change.
708 my $topic = ($event->args)[0];
709 my $chan = ($event->to)[0];
710 my $nick = $event->nick();
714 # race condition here. To fix, change '1' to '0'.
715 # This will keep track of topics set by bot only.
718 # this may be fixed at a later date with topic queueing.
721 $topic{$chan}{'Current'} = $topic if (1 and &IsParam("topic") == 1);
722 $chanstats{$chan}{'Topic'}++;
724 &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic");
726 my ($nick, $chan, $topic) = $event->args;
727 if (&IsParam("topic")) {
728 $topic{$chan}{'Current'} = $topic;
729 &topicAddHistory($chan,$topic);
732 $topic = &fixString($topic, 1);
733 &status(">>> topic/$b_blue$chan$ob is $topic");
738 my ($self, $event) = @_;
739 my ($myself,$chan,$setby,$time) = $event->args();
742 if (time() - $time > 60*60*24) {
743 $timestr = "at ". localtime $time;
745 $timestr = &Time2String(time() - $time) ." ago";
748 &status(">>> set by $b_cyan$setby$ob $timestr");
752 my ($self, $event) = @_;
753 my $nick = $event->nick;
755 &status(">>> ${b_green}CTCP VERSION$ob request from $b_cyan$nick$ob");
756 $self->ctcp_reply($nick, "VERSION $bot_version");
760 my ($self, $event) = @_;
761 my @args = $event->args;
763 $nuh{lc $args[5]} = $args[5]."!".$args[2]."\@".$args[3];
767 my ($self, $event) = @_;
768 my @args = $event->args;
770 $nuh{lc $args[1]} = $args[1]."!".$args[2]."\@".$args[3];
773 #######################################################################
774 ####### IRC HOOK HELPERS IRC HOOK HELPERS IRC HOOK HELPERS ########
775 #######################################################################
778 # Usage: &hookMode($chan, $modes, @targets);
780 my ($chan, $modes, @targets) = @_;
783 $chan = lc $chan; # !!!.
786 foreach $mode (split(//, $modes)) {
788 if ($mode =~ /[-+]/) {
789 $parity = 1 if ($mode eq "+");
790 $parity = 0 if ($mode eq "-");
795 if ($mode =~ /[bklov]/) {
796 my $target = shift @targets;
799 $chanstats{$chan}{'Op'}++ if ($mode eq "o");
800 $chanstats{$chan}{'Ban'}++ if ($mode eq "b");
802 $chanstats{$chan}{'Deop'}++ if ($mode eq "o");
803 $chanstats{$chan}{'Unban'}++ if ($mode eq "b");
806 # modes w/ target affecting nick => cache it.
807 if ($mode =~ /[ov]/) {
808 $channels{$chan}{$mode}{$target}++ if $parity;
809 delete $channels{$chan}{$mode}{$target} if !$parity;
812 if ($mode =~ /[l]/) {
813 $channels{$chan}{$mode} = $target if $parity;
814 delete $channels{$chan}{$mode} if !$parity;
818 # important channel modes, targetless.
819 if ($mode =~ /[mt]/) {
820 $channels{$chan}{$mode}++ if $parity;
821 delete $channels{$chan}{$mode} if !$parity;
827 ($msgType, $chan, $who, $message) = @_;
831 $orig{message} = $message;
835 $message =~ s/[\cA-\c_]//ig; # strip control characters
836 $message =~ s/^\s+//; # initial whitespaces.
837 $who =~ tr/A-Z/a-z/; # lowercase.
842 if ($msgType =~ /private/) {
847 # addressing revamped by the xk.
848 ### below needs to be fixed...
849 if (&IsParam("addressCharacter")) {
850 if ($message =~ s/^$param{'addressCharacter'}//) {
856 if ($message =~ /^($mask{nick})([\;\:\>\, ]+) */) {
858 if ($1 =~ /^\Q$ident\E$/i) {
859 $message = $newmessage;
862 # ignore messages addressed to other people or unaddressed.
863 $skipmessage++ if ($2 ne "" and $2 !~ /^ /);
868 # Determine floodwho.
869 if ($msgType =~ /public/i) { # public.
870 $floodwho = lc $chan;
871 } elsif ($msgType =~ /private/i) { # private.
874 &DEBUG("FIXME: floodwho = ???");
877 my ($count, $interval) = split(/:/, $param{'floodRepeat'} || "2:10");
879 # flood repeat protection.
881 my $time = $flood{$floodwho}{$message};
883 if (defined $time and (time - $time < $interval)) {
884 ### public != personal who so the below is kind of pointless.
886 foreach (keys %flood) {
887 next if (/^\Q$floodwho\E$/ or /^\Q$chan\E$/);
888 push(@who, grep /^\Q$message\E$/i, keys %{$flood{$_}});
891 &msg($who, "you already said what ".
892 join(' ', @who)." have said.");
894 &msg($who,"Someone already said that ". (time - $time) ." seconds ago" );
897 ### TODO: delete old floodwarn{} keys.
899 if (!exists $floodwarn{$floodwho}) {
902 $floodwarn++ if (time() - $floodwarn{$floodwho} > $interval);
906 &status("FLOOD repetition detected from $floodwho.");
907 $floodwarn{$floodwho} = time();
914 &status("$b_cyan$who$ob is short-addressing me");
916 &status("$b_cyan$who$ob is addressing me");
919 $flood{$floodwho}{$message} = time();
922 ($count, $interval) = split(/:/, $param{'floodMessages'} || "5:30");
923 # flood overflow protection.
925 foreach (keys %{$flood{$floodwho}}) {
926 next unless (time() - $flood{$floodwho}{$_} > $interval);
927 delete $flood{$floodwho}{$_};
930 my $i = scalar keys %{$flood{$floodwho}};
932 &msg($who,"overflow of messages ($i > $count)");
933 &status("FLOOD overflow detected from $floodwho; ignoring");
935 my $expire = $param{'ignoreAutoExpire'} || 5;
936 $ignoreList{"*!$uh"} = time() + ($expire * 60);
940 $flood{$floodwho}{$message} = time();
944 if ($msgType =~ /public/i) {
945 $talkchannel = $chan;
946 &status("<$orig{who}/$chan> $orig{message}");
950 if ($msgType =~ /private/i) {
951 &status("[$orig{who}] $orig{message}");
954 if ((!$skipmessage or &IsParam("seenStoreAll")) and
958 $seencache{$who}{'time'} = time();
959 $seencache{$who}{'nick'} = $orig{who};
960 $seencache{$who}{'host'} = $uh;
961 $seencache{$who}{'chan'} = $talkchannel;
962 $seencache{$who}{'msg'} = $orig{message};
963 $seencache{$who}{'msgcount'}++;
966 return if ($skipmessage);
967 return unless (&IsParam("minVolunteerLength") or $addressed);
970 foreach (keys %ignoreList) {
972 my @parts = split /\*/, "a${ignoreRE}a";
973 my $recast = join '\S*', map quotemeta($_), @parts;
974 $recast =~ s/^a(.*)a$/$1/;
975 if ($nuh =~ /^$recast$/) {
982 $userHandle = &verifyUser($who, $nuh);
984 &DEBUG("hookMsg: 'nuh' not defined?");
987 ### For extra debugging purposes...
988 if ($_ = &process()) {
989 # &DEBUG("IrcHooks: process returned '$_'.");