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{'CHAT'}{$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 &DEBUG("chat: after closing sock. FIXME");
82 ### BUG: close seizes bot. why?
86 &status("DCC CHAT: user $nick is here!");
87 $dcc{'CHAT'}{$nick} = $sock;
88 &DCCBroadcast("$nick ($uh) has joined the chat arena.");
94 $userHandle = &verifyUser($who, $nuh);
95 &status("$b_red=$b_cyan$who$b_red=$ob $message");
96 if ($message =~ s/^\.//) { # dcc chat commands.
97 ### TODO: make use of &Forker(); here?
98 &loadMyModule($myModules{'ircdcc'});
99 return '$noreply from userD' if (&userDCC() eq $noreply);
100 $conn->privmsg($dcc{'CHAT'}{$who}, "Invalid command.");
102 } else { # dcc chat arena.
103 foreach (keys %{$dcc{'CHAT'}}) {
104 $conn->privmsg($dcc{'CHAT'}{$_}, "<$who> $orig{message}");
108 return 'DCC CHAT MESSAGE';
114 if (&IsParam("wingate")) {
115 my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
119 next unless (/^(\S+)\*$/);
120 push(@wingateBad, $_);
126 &DEBUG("on_EOM: calling sS in 60s.");
127 $conn->schedule(60, \&setupSchedulers, "");
131 if (&IsParam("ircUMode")) {
132 &status("Attempting change of user modes to $param{'ircUMode'}.");
133 &rawout("MODE $ident $param{'ircUMode'}");
136 &status("End of motd. Now lets join some channels...");
137 if (!scalar @joinchan) {
138 &WARN("joinchan array is empty!!!");
139 @joinchan = split /[\t\s]+/, $param{'join_channels'};
146 my ($self, $event) = @_;
147 my $type = uc( ($event->args)[1] );
148 my $nick = $event->nick();
150 # pity Net::IRC doesn't store nuh. Here's a hack :)
153 if ($type eq 'SEND') { # GET for us.
154 # incoming DCC SEND. we're receiving a file.
155 my $get = ($event->args)[2];
156 open(DCCGET,">$get");
158 $self->new_get($nick,
165 } elsif ($type eq 'GET') { # SEND for us?
166 &DEBUG("starting get.");
167 $self->new_send($event->args);
168 } elsif ($type eq 'CHAT') {
169 &DEBUG("starting chat.");
170 $self->new_chat($event);
172 &status("${b_green}DCC $type$ob unknown ...");
177 my ($self, $event) = @_;
178 my $nick = $event->nick();
179 my $sock = ($event->to)[0];
181 # DCC CHAT close on fork exit workaround.
182 return if ($bot_pid != $$);
184 &DEBUG("dcc_close: nick => '$nick'.");
186 if (exists $dcc{'SEND'}{$nick} and -f "$param{tempDir}/$nick.txt") {
187 &status("${b_green}DCC SEND$ob close from $b_cyan$nick$ob");
189 &status("dcc_close: purging $nick.txt from Debian.pl");
190 unlink "$param{tempDir}/$nick.txt";
192 delete $dcc{'SEND'}{$nick};
193 } elsif (exists $dcc{'CHAT'}{$nick} and $dcc{'CHAT'}{$nick} eq $sock) {
194 &status("${b_green}DCC CHAT$ob close from $b_cyan$nick$ob");
195 delete $dcc{'CHAT'}{$nick};
197 &status("${b_green}DCC$ob UNKNOWN close from $b_cyan$nick$ob");
202 my ($self, $event) = @_;
203 my $type = uc( ($event->args)[0] );
204 my $nick = $event->nick();
205 my $sock = ($event->to)[0];
208 if ($type eq 'SEND') {
209 &status("${b_green}DCC lGET$ob established with $b_cyan$nick$ob");
210 } elsif ($type eq 'CHAT') {
211 &status("${b_green}DCC CHAT$ob established with $b_cyan$nick$ob ($nuh{$nick})");
212 $userHandle = &verifyUser($nick, $nuh{lc $nick});
213 my $crypto = $userList{$userHandle}{'pass'};
214 if (defined $crypto) {
215 $self->privmsg($sock,"Enter Password, $userHandle.");
217 $self->privmsg($sock,"Welcome to blootbot DCC CHAT interface, $userHandle.");
219 } elsif ($type eq 'SEND') {
220 &DEBUG("Starting DCC receive.");
221 foreach ($event->args) {
225 &status("${b_green}DCC $type$ob unknown ...");
230 my ($self, $event) = @_;
231 my $from = $event->from();
232 my $what = ($event->args)[0];
234 &status("disconnect from $from ($what).");
235 $ircstats{'DisconnectTime'} = time();
236 $ircstats{'DisconnectReason'} = $what;
237 $ircstats{'DisconnectCount'}++;
239 # clear any variables on reconnection.
243 if (!$self->connect()) {
244 &WARN("not connected? help me. gonna call ircCheck() in 1800s");
245 $conn->schedule(1800, \&ircCheck(), "");
250 my ($self, $event) = @_;
251 my $chan = ($event->args)[1];
253 if (exists $jointime{$chan}) {
254 my $delta_time = sprintf("%.03f", &gettimeofday() - $jointime{$chan});
255 $delta_time = 0 if ($delta_time < 0);
257 &status("$b_blue$chan$ob: sync in ${delta_time}s.");
260 rawout("MODE $chan");
264 foreach ("o","v","") {
265 my $count = scalar(keys %{$channels{$chan}{$_}});
266 next unless ($count);
268 $txt = "total" if ($_ eq "");
269 $txt = "voice" if ($_ eq "v");
270 $txt = "ops" if ($_ eq "o");
272 push(@array, "$count $txt");
274 my $chanstats = join(' || ', @array);
275 &status("$b_blue$chan$ob: [$chanstats]");
277 if (scalar @joinchan) { # remaining channels to join.
280 ### chanserv support.
281 ### TODO: what if we rejoin a channel.. need to set a var that
282 ### we've done the request-for-ops-on-join.
283 return unless (&IsParam("chanServ_ops"));
284 return unless ($nickserv);
286 my @chans = split(/[\s\t]+/, $param{'chanServ_ops'});
288 ### TODO: since this function has a chan arg, why don't we use
289 ### that instead of doing the following?
290 foreach $chan (keys %channels) {
291 next unless (grep /^$chan$/i, @chans);
293 if (!exists $channels{$chan}{'o'}{$ident}) {
294 &status("ChanServ ==> Requesting ops for $chan.");
295 &rawout("PRIVMSG ChanServ :OP $chan $ident");
303 my ($self, $event) = @_;
304 my (@args) = ($event->args);
311 my ($self, $event) = @_;
312 my $chan = ($event->args)[0];
313 my $nick = $event->nick;
315 &DEBUG("on_invite: chan => '$chan', nick => '$nick'.");
317 # chan + possible_key.
318 ### do we need to know the key if we're invited???
319 ### grep the channel list?
320 foreach (split /[\s\t]+/, $param{'join_channels'}) {
321 next unless /^\Q$chan\E(,\S+)?$/i;
324 next if ($nick =~ /^\Q$ident\E$/);
325 if (&validChan($chan)) {
326 &msg($who, "i'm already in \002$chan\002.");
330 &status("invited to $b_blue$_$ob by $b_cyan$who$ob");
331 &joinchan($self, $_);
336 my ($self, $event) = @_;
337 my ($user,$host) = split(/\@/, $event->userhost);
338 $chan = lc( ($event->to)[0] ); # CASING!!!!
339 $who = $event->nick();
341 $chanstats{$chan}{'Join'}++;
342 $userstats{lc $who}{'Join'} = time() if (&IsParam("seenStats"));
346 if (exists $netsplit{lc $who}) {
347 delete $netsplit{lc $who};
351 # how to tell if there's a netjoin???
353 my $netsplitstr = "";
354 $netsplitstr = " $b_yellow\[${ob}NETSPLIT VICTIM$b_yellow]$ob" if ($netsplit);
355 &status(">>> join/$b_blue$chan$ob $b_cyan$who$ob $b_yellow($ob$user\@$host$b_yellow)$ob$netsplitstr");
357 $channels{$chan}{''}{$who}++;
358 $nuh{lc $who} = $who."!".$user."\@".$host unless (exists $nuh{lc $who});
361 &rootWarn($who,$user,$host,$chan)
362 if (&IsParam("rootWarn") &&
363 $user =~ /^r(oo|ew|00)t$/i &&
364 $channels{$chan}{'o'}{$ident});
366 # used to determine sync time.
367 if ($who =~ /^$ident$/i) {
368 if (defined( my $whojoin = $joinverb{$chan} )) {
369 &msg($chan, "Okay, I'm here. (courtesy of $whojoin)");
370 delete $joinverb{$chan};
373 ### TODO: move this to &joinchan()?
374 $jointime{$chan} = &gettimeofday();
377 ### TODO: this may go wild on a netjoin :)
384 my ($self, $event) = @_;
385 my ($chan,$reason) = $event->args;
386 my $kicker = $event->nick;
387 my $kickee = ($event->to)[0];
388 my $uh = $event->userhost();
390 &status(">>> kick/$b_blue$chan$ob [$b$kickee!$uh$ob] by $b_cyan$kicker$ob $b_yellow($ob$reason$b_yellow)$ob");
392 $chanstats{$chan}{'Kick'}++;
394 if ($kickee eq $ident) {
395 &clearChanVars($chan);
397 &status("SELF attempting to rejoin lost channel $chan");
400 &DeleteUserInfo($kickee,$chan);
405 my ($self, $event) = @_;
406 my ($user, $host) = split(/\@/, $event->userhost);
407 my @args = $event->args();
408 my $nick = $event->nick();
409 my $chan = ($event->to)[0];
413 if ($nick eq $chan) { # UMODE
414 &status(">>> mode $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
416 &status(">>> mode/$b_blue$chan$ob $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
417 &hookMode($chan, @args);
422 my ($self, $event) = @_;
423 my $nick = $event->nick();
424 my ($myself,$chan,@args) = $event->args();
426 &hookMode(lc $chan, @args); # CASING.
430 my ($self, $event) = @_;
431 my $nick = $event->nick;
432 my $chan = lc ( ($event->to)[0] ); # CASING.
433 my $msg = ($event->args)[0];
435 ($user,$host) = split(/\@/, $event->userhost);
436 $uh = $event->userhost();
437 $nuh = $nick."!".$uh;
439 &hookMsg('private', $chan, $nick, $msg);
443 my ($self, $event) = @_;
444 my @args = $event->args;
445 my $chan = lc $args[2]; # CASING, the last of them!
447 foreach (split / /, @args[3..$#args]) {
448 $channels{$chan}{'o'}{$_}++ if s/\@//;
449 $channels{$chan}{'v'}{$_}++ if s/\+//;
450 $channels{$chan}{''}{$_}++;
455 my ($self, $event) = @_;
456 my $nick = $event->nick();
457 my $newnick = ($event->args)[0];
459 if (exists $netsplit{lc $newnick}) {
460 &status("Netsplit: $newnick/$nick came back from netsplit and changed to original nick! removing from hash.");
461 delete $netsplit{lc $newnick};
465 foreach $chan (keys %channels) {
466 foreach $mode (keys %{$channels{$chan}}) {
467 next unless (exists $channels{$chan}{$mode}{$nick});
469 $channels{$chan}{$mode}{$newnick} = $channels{$chan}{$mode}{$nick};
472 &DeleteUserInfo($nick,keys %channels);
473 $nuh{lc $newnick} = $nuh{lc $nick};
474 delete $nuh{lc $nick};
476 # successful self-nick change.
477 if ($nick eq $ident) {
478 &status(">>> I materialized into $b_green$newnick$ob from $nick");
481 &status(">>> $b_cyan$nick$ob materializes into $b_green$newnick$ob");
487 my $nick = $self->nick;
488 my $newnick = substr($nick,0,7)."-";
490 &status("nick taken; changing to temporary nick.");
496 my ($self, $event) = @_;
497 my $nick = $event->nick();
498 my $chan = ($event->to)[0];
499 my $args = ($event->args)[0];
501 if ($nick =~ /^NickServ$/i) { # nickserv.
502 &status("NickServ: <== '$args'");
504 if ($args =~ /^This nickname is registered/i) {
505 &status("nickserv told us to register; doing it.");
506 if (&IsParam("nickServ_pass")) {
507 &status("NickServ: ==> Identifying.");
508 &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
511 &status("We can't tell nickserv a passwd ;(");
516 if ($args =~ /^Password a/i) {
519 } elsif ($nick =~ /^ChanServ$/i) { # chanserv.
520 &status("ChanServ: <== '$args'.");
522 if ($chan =~ /^$mask{chan}$/) { # channel notice.
523 &status("-$nick/$chan- $args");
525 $server = $nick unless (defined $server);
526 &status("-$nick- $args"); # private or server notice.
532 my ($self, $event) = @_;
533 my $chan = ($event->to)[0];
534 my $nick = $event->nick;
536 &status("!!! other called.");
537 &status("!!! $event->args");
541 my ($self, $event) = @_;
542 my $chan = lc( ($event->to)[0] ); # CASING!!!
543 my $nick = $event->nick;
544 my $userhost = $event->userhost;
546 $chanstats{$chan}{'Part'}++;
547 &DeleteUserInfo($nick,$chan);
548 &clearChanVars($chan) if ($nick eq $ident);
549 if (!&IsNickInAnyChan($nick) and &IsParam("seenStats")) {
550 delete $userstats{lc $nick};
553 &status(">>> part/$b_blue$chan$ob $b_cyan$nick$ob $b_yellow($ob$userhost$b_yellow)$ob");
557 my ($self, $event) = @_;
558 my $nick = $event->nick;
560 $self->ctcp_reply($nick, join(' ', ($event->args)));
561 &status(">>> ${b_green}CTCP PING$ob request from $b_cyan$nick$ob received.");
565 my ($self, $event) = @_;
566 my $nick = $event->nick;
567 my $lag = time() - ($event->args)[1];
569 &status(">>> ${b_green}CTCP PING$ob reply from $b_cyan$nick$ob: $lag sec.");
573 my ($self, $event) = @_;
574 my $msg = ($event->args)[0];
575 my $chan = lc( ($event->to)[0] ); # CASING.
576 my $nick = $event->nick;
577 $uh = $event->userhost();
578 $nuh = $nick."!".$uh;
579 ($user,$host) = split(/\@/, $uh);
581 if ($$ != $bot_pid) {
582 &ERROR("SHOULD NEVER HAPPEN.");
587 if ($statcount < 200) {
588 foreach $chan (grep /[A-Z]/, keys %channels) {
589 &DEBUG("leak: chan => '$chan'.");
591 foreach $i (keys %{$channels{$chan}}) {
592 foreach (keys %{$channels{$chan}{$i}}) {
593 &DEBUG("leak: \$channels{$chan}{$i}{$_} ...");
601 $lastWho{$chan} = $nick;
602 ### TODO: use $nick or lc $nick?
603 if (&IsParam("seenStats")) {
604 $userstats{lc $nick}{'Count'}++;
605 $userstats{lc $nick}{'Time'} = time();
608 # if (&IsParam("hehCounter")) {
612 &hookMsg('public', $chan, $nick, $msg);
613 $chanstats{$chan}{'PublicMsg'}++;
617 my ($self, $event) = @_;
618 my $nick = $event->nick();
619 my $reason = ($event->args)[0];
621 foreach (keys %channels) {
622 # fixes inconsistent chanstats bug #1.
623 next unless (&IsNickInChan($nick,$_));
624 $chanstats{$_}{'SignOff'}++;
626 &DeleteUserInfo($nick, keys %channels);
627 if (exists $nuh{lc $nick}) {
628 delete $nuh{lc $nick};
630 &DEBUG("on_quit: nuh{lc $nick} does not exist! FIXME");
632 delete $userstats{lc $nick} if (&IsParam("seenStats"));
634 # should fix chanstats inconsistencies bug #2.
635 if ($reason=~/^($mask{host})\s($mask{host})$/) { # netsplit.
636 $reason = "NETSPLIT: $1 <=> $2";
638 $netsplit{lc $nick} = time();
639 if (!exists $netsplitservers{$1}{$2}) {
640 &status("netsplit detected between $1 and $2.");
641 $netsplitservers{$1}{$2} = time();
645 &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob");
646 if ($nick =~ /^\Q$ident\E$/) {
647 &DEBUG("!!! THIS SHOULD NEVER HAPPEN. FIXME HOPEFULLY");
649 if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) {
650 &status("own nickname became free; changing.");
651 &nick($param{'ircNick'});
655 sub on_targettoofast {
656 my ($self, $event) = @_;
657 my $nick = $event->nick();
658 my $chan = ($event->to)[0];
660 &DEBUG("on_targettoofast: nick => '$nick'.");
661 &DEBUG("on_targettoofast: chan => '$chan'.");
663 foreach ($event->args) {
664 &DEBUG("on_targettoofast: args => '$_'.");
667 ### .* wait (\d+) second/) {
671 &status("going to sleep for $sleep...");
678 my ($self, $event) = @_;
680 if (scalar($event->args) == 1) { # change.
681 my $topic = ($event->args)[0];
682 my $chan = ($event->to)[0];
683 my $nick = $event->nick();
687 # race condition here. To fix, change '1' to '0'.
688 # This will keep track of topics set by bot only.
691 # this may be fixed at a later date with topic queueing.
694 $topic{$chan}{'Current'} = $topic if (1 and &IsParam("topic") == 1);
695 $chanstats{$chan}{'Topic'}++;
697 &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic");
699 my ($nick, $chan, $topic) = $event->args;
700 if (&IsParam("topic")) {
701 $topic{$chan}{'Current'} = $topic;
702 &topicAddHistory($chan,$topic);
705 $topic = &fixString($topic, 1);
706 &status(">>> topic/$b_blue$chan$ob is $topic");
711 my ($self, $event) = @_;
712 my ($myself,$chan,$setby,$time) = $event->args();
715 if (time() - $time > 60*60*24) {
716 $timestr = "at ". localtime $time;
718 $timestr = &Time2String(time() - $time) ." ago";
721 &status(">>> set by $b_cyan$setby$ob $timestr");
725 my ($self, $event) = @_;
726 my $nick = $event->nick;
728 &status(">>> ${b_green}CTCP VERSION$ob request from $b_cyan$nick$ob");
729 $self->ctcp_reply($nick, "VERSION $bot_version");
733 my ($self, $event) = @_;
734 my @args = $event->args;
736 $nuh{lc $args[5]} = $args[5]."!".$args[2]."\@".$args[3];
740 my ($self, $event) = @_;
741 my @args = $event->args;
743 $nuh{lc $args[1]} = $args[1]."!".$args[2]."\@".$args[3];
746 #######################################################################
747 ####### IRC HOOK HELPERS IRC HOOK HELPERS IRC HOOK HELPERS ########
748 #######################################################################
751 # Usage: &hookMode($chan, $modes, @targets);
753 my ($chan, $modes, @targets) = @_;
756 $chan = lc $chan; # !!!.
759 foreach $mode (split(//, $modes)) {
761 if ($mode =~ /[-+]/) {
762 $parity = 1 if ($mode eq "+");
763 $parity = 0 if ($mode eq "-");
768 if ($mode =~ /[bklov]/) {
769 my $target = shift @targets;
772 $chanstats{$chan}{'Op'}++ if ($mode eq "o");
773 $chanstats{$chan}{'Ban'}++ if ($mode eq "b");
775 $chanstats{$chan}{'Deop'}++ if ($mode eq "o");
776 $chanstats{$chan}{'Unban'}++ if ($mode eq "b");
779 # modes w/ target affecting nick => cache it.
780 if ($mode =~ /[ov]/) {
781 $channels{$chan}{$mode}{$target}++ if $parity;
782 delete $channels{$chan}{$mode}{$target} if !$parity;
785 if ($mode =~ /[l]/) {
786 $channels{$chan}{$mode} = $target if $parity;
787 delete $channels{$chan}{$mode} if !$parity;
791 # important channel modes, targetless.
792 if ($mode =~ /[mt]/) {
793 $channels{$chan}{$mode}++ if $parity;
794 delete $channels{$chan}{$mode} if !$parity;
800 ($msgType, $chan, $who, $message) = @_;
804 $orig{message} = $message;
808 $message =~ s/[\cA-\c_]//ig; # strip control characters
809 $message =~ s/^\s+//; # initial whitespaces.
810 $who =~ tr/A-Z/a-z/; # lowercase.
815 if ($msgType =~ /private/) {
820 # addressing revamped by the xk.
821 ### below needs to be fixed...
822 if (&IsParam("addressCharacter")) {
823 if ($message =~ s/^$param{'addressCharacter'}//) {
829 if ($message =~ /^($mask{nick})([\;\:\>\, ]+) */) {
831 if ($1 =~ /^\Q$ident\E$/i) {
832 $message = $newmessage;
835 # ignore messages addressed to other people or unaddressed.
836 $skipmessage++ if ($2 ne "" and $2 !~ /^ /);
841 # Determine floodwho.
842 if ($msgType =~ /public/i) { # public.
843 $floodwho = lc $chan;
844 } elsif ($msgType =~ /private/i) { # private.
847 &DEBUG("FIXME: floodwho = ???");
850 my ($count, $interval) = split(/:/, $param{'floodRepeat'} || "2:10");
852 # flood repeat protection.
854 my $time = $flood{$floodwho}{$message};
856 if (defined $time and (time - $time < $interval)) {
857 ### public != personal who so the below is kind of pointless.
859 foreach (keys %flood) {
860 next if (/^\Q$floodwho\E$/ or /^\Q$chan\E$/);
861 push(@who, grep /^\Q$message\E$/i, keys %{$flood{$_}});
864 &msg($who, "you already said what ".
865 join(' ', @who)." have said.");
867 &msg($who,"Someone already said that ". (time - $time) ." seconds ago" );
870 ### TODO: delete old floodwarn{} keys.
872 if (!exists $floodwarn{$floodwho}) {
875 $floodwarn++ if (time() - $floodwarn{$floodwho} > $interval);
879 &status("FLOOD repetition detected from $floodwho.");
880 $floodwarn{$floodwho} = time();
887 &status("$b_cyan$who$ob is short-addressing me");
889 &status("$b_cyan$who$ob is addressing me");
892 $flood{$floodwho}{$message} = time();
895 ($count, $interval) = split(/:/, $param{'floodMessages'} || "5:30");
896 # flood overflow protection.
898 foreach (keys %{$flood{$floodwho}}) {
899 next unless (time() - $flood{$floodwho}{$_} > $interval);
900 delete $flood{$floodwho}{$_};
903 my $i = scalar keys %{$flood{$floodwho}};
905 &msg($who,"overflow of messages ($i > $count)");
906 &status("FLOOD overflow detected from $floodwho; ignoring");
908 my $expire = $param{'ignoreAutoExpire'} || 5;
909 $ignoreList{"*!$uh"} = time() + ($expire * 60);
913 $flood{$floodwho}{$message} = time();
917 if ($msgType =~ /public/i) {
918 $talkchannel = $chan;
919 &status("<$orig{who}/$chan> $orig{message}");
923 if ($msgType =~ /private/i) {
924 &status("[$orig{who}] $orig{message}");
927 if ((!$skipmessage or &IsParam("seenStoreAll")) and
931 $seencache{$who}{'time'} = time();
932 $seencache{$who}{'nick'} = $orig{who};
933 $seencache{$who}{'host'} = $uh;
934 $seencache{$who}{'chan'} = $talkchannel;
935 $seencache{$who}{'msg'} = $orig{message};
936 $seencache{$who}{'msgcount'}++;
939 return if ($skipmessage);
940 return unless (&IsParam("minVolunteerLength") or $addressed);
943 foreach (keys %ignoreList) {
945 my @parts = split /\*/, "a${ignoreRE}a";
946 my $recast = join '\S*', map quotemeta($_), @parts;
947 $recast =~ s/^a(.*)a$/$1/;
948 if ($nuh =~ /^$recast$/) {
955 $userHandle = &verifyUser($who, $nuh);
957 &DEBUG("hookMsg: 'nuh' not defined?");
960 ### For extra debugging purposes...
961 if ($_ = &process()) {
962 # &DEBUG("IrcHooks: process returned '$_'.");