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 my $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.");
95 $userHandle = &verifyUser($who, $nuh);
96 &status("$b_red=$b_cyan$who$b_red=$ob $message");
97 if ($message =~ s/^\.//) { # dcc chat commands.
98 ### TODO: make use of &Forker(); here?
99 &loadMyModule($myModules{'ircdcc'});
100 return '$noreply from userD' if (&userDCC() eq $noreply);
101 $conn->privmsg($dcc{'CHAT'}{$who}, "Invalid command.");
103 } else { # dcc chat arena.
104 foreach (keys %{$dcc{'CHAT'}}) {
105 $conn->privmsg($dcc{'CHAT'}{$_}, "<$who> $orig{message}");
109 return 'DCC CHAT MESSAGE';
115 if (&IsParam("wingate")) {
116 my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
120 next unless (/^(\S+)\*$/);
121 push(@wingateBad, $_);
127 &DEBUG("on_EOM: calling sS in 60s.");
128 $conn->schedule(60, \&setupSchedulers, "");
132 if (&IsParam("ircUMode")) {
133 &status("Attempting change of user modes to $param{'ircUMode'}.");
134 &rawout("MODE $ident $param{'ircUMode'}");
137 &status("End of motd. Now lets join some channels...");
138 if (!scalar @joinchan) {
139 &WARN("joinchan array is empty!!!");
140 @joinchan = split /[\t\s]+/, $param{'join_channels'};
147 my ($self, $event) = @_;
148 my $type = uc( ($event->args)[1] );
149 my $nick = $event->nick();
151 # pity Net::IRC doesn't store nuh. Here's a hack :)
154 if ($type eq 'SEND') { # GET for us.
155 # incoming DCC SEND. we're receiving a file.
156 my $get = ($event->args)[2];
157 open(DCCGET,">$get");
159 $self->new_get($nick,
166 } elsif ($type eq 'GET') { # SEND for us?
167 &DEBUG("starting get.");
168 $self->new_send($event->args);
169 } elsif ($type eq 'CHAT') {
170 &DEBUG("starting chat.");
171 $self->new_chat($event);
173 &status("${b_green}DCC $type$ob unknown ...");
178 my ($self, $event) = @_;
179 my $nick = $event->nick();
180 my $sock = ($event->to)[0];
182 # DCC CHAT close on fork exit workaround.
183 return if ($bot_pid != $$);
185 &DEBUG("dcc_close: nick => '$nick'.");
187 if (exists $dcc{'SEND'}{$nick} and -f "temp/$nick.txt") {
188 &status("${b_green}DCC SEND$ob close from $b_cyan$nick$ob");
190 &status("dcc_close: purging $nick.txt from Debian.pl");
191 unlink "temp/$nick.txt";
193 delete $dcc{'SEND'}{$nick};
194 } elsif (exists $dcc{'CHAT'}{$nick} and $dcc{'CHAT'}{$nick} eq $sock) {
195 &status("${b_green}DCC CHAT$ob close from $b_cyan$nick$ob");
196 delete $dcc{'CHAT'}{$nick};
198 &status("${b_green}DCC$ob UNKNOWN close from $b_cyan$nick$ob");
203 my ($self, $event) = @_;
204 my $type = uc( ($event->args)[0] );
205 my $nick = $event->nick();
206 my $sock = ($event->to)[0];
209 if ($type eq 'SEND') {
210 &status("${b_green}DCC lGET$ob established with $b_cyan$nick$ob");
211 } elsif ($type eq 'CHAT') {
212 &status("${b_green}DCC CHAT$ob established with $b_cyan$nick$ob ($nuh{$nick})");
213 my $userHandle = &verifyUser($nick, $nuh{lc $nick});
214 my $crypto = $userList{$userHandle}{'pass'};
215 if (defined $crypto) {
216 $self->privmsg($sock,"Enter Password, $userHandle.");
218 $self->privmsg($sock,"Welcome to blootbot DCC CHAT interface, $userHandle.");
220 } elsif ($type eq 'SEND') {
221 &DEBUG("Starting DCC receive.");
222 foreach ($event->args) {
226 &status("${b_green}DCC $type$ob unknown ...");
231 my ($self, $event) = @_;
232 my $from = $event->from();
233 my $what = ($event->args)[0];
235 &status("disconnect from $from ($what).");
236 $ircstats{'DisconnectTime'} = time();
237 $ircstats{'DisconnectReason'} = $what;
238 $ircstats{'DisconnectCount'}++;
240 # clear any variables on reconnection.
244 if (!$self->connect()) {
245 &WARN("not connected? help me. gonna call ircCheck() in 1800s");
246 $conn->schedule(1800, \&ircCheck(), "");
251 my ($self, $event) = @_;
252 my $chan = ($event->args)[1];
254 if (exists $jointime{$chan}) {
255 my $delta_time = sprintf("%.03f", &gettimeofday() - $jointime{$chan});
256 $delta_time = 0 if ($delta_time < 0);
258 &status("$b_blue$chan$ob: sync in ${delta_time}s.");
261 rawout("MODE $chan");
265 foreach ("o","v","") {
266 my $count = scalar(keys %{$channels{$chan}{$_}});
267 next unless ($count);
269 $txt = "total" if ($_ eq "");
270 $txt = "voice" if ($_ eq "v");
271 $txt = "ops" if ($_ eq "o");
273 push(@array, "$count $txt");
275 my $chanstats = join(' || ', @array);
276 &status("$b_blue$chan$ob: [$chanstats]");
278 if (scalar @joinchan) { # remaining channels to join.
281 ### chanserv support.
282 ### TODO: what if we rejoin a channel.. need to set a var that
283 ### we've done the request-for-ops-on-join.
284 return unless (&IsParam("chanServ_ops"));
285 return unless ($nickserv);
287 my @chans = split(/[\s\t]+/, $param{'chanServ_ops'});
289 ### TODO: since this function has a chan arg, why don't we use
290 ### that instead of doing the following?
291 foreach $chan (keys %channels) {
292 next unless (grep /^$chan$/i, @chans);
294 if (!exists $channels{$chan}{'o'}{$ident}) {
295 &status("ChanServ ==> Requesting ops for $chan.");
296 &rawout("PRIVMSG ChanServ :OP $chan $ident");
304 my ($self, $event) = @_;
305 my (@args) = ($event->args);
312 my ($self, $event) = @_;
313 my $chan = ($event->args)[0];
314 my $nick = $event->nick;
316 &DEBUG("on_invite: chan => '$chan', nick => '$nick'.");
318 # chan + possible_key.
319 ### do we need to know the key if we're invited???
320 ### grep the channel list?
321 foreach (split /[\s\t]+/, $param{'join_channels'}) {
322 next unless /^\Q$chan\E(,\S+)?$/i;
325 next if ($nick =~ /^\Q$ident\E$/);
326 if (&validChan($chan)) {
327 &msg($who, "i'm already in \002$chan\002.");
331 &status("invited to $b_blue$_$ob by $b_cyan$who$ob");
332 &joinchan($self, $_);
337 my ($self, $event) = @_;
338 my ($user,$host) = split(/\@/, $event->userhost);
339 $chan = lc( ($event->to)[0] ); # CASING!!!!
340 $who = $event->nick();
342 $chanstats{$chan}{'Join'}++;
343 $userstats{lc $who}{'Join'} = time() if (&IsParam("seenStats"));
347 if (exists $netsplit{lc $who}) {
348 delete $netsplit{lc $who};
352 # how to tell if there's a netjoin???
354 my $netsplitstr = "";
355 $netsplitstr = " $b_yellow\[${ob}NETSPLIT VICTIM$b_yellow]$ob" if ($netsplit);
356 &status(">>> join/$b_blue$chan$ob $b_cyan$who$ob $b_yellow($ob$user\@$host$b_yellow)$ob$netsplitstr");
358 $channels{$chan}{''}{$who}++;
359 $nuh{lc $who} = $who."!".$user."\@".$host unless (exists $nuh{lc $who});
362 &rootWarn($who,$user,$host,$chan)
363 if (&IsParam("rootWarn") &&
364 $user =~ /^r(oo|ew|00)t$/i &&
365 $channels{$chan}{'o'}{$ident});
367 # used to determine sync time.
368 if ($who =~ /^$ident$/i) {
369 if (defined( my $whojoin = $joinverb{$chan} )) {
370 &msg($chan, "Okay, I'm here. (courtesy of $whojoin)");
371 delete $joinverb{$chan};
374 ### TODO: move this to &joinchan()?
375 $jointime{$chan} = &gettimeofday();
378 ### TODO: this may go wild on a netjoin :)
385 my ($self, $event) = @_;
386 my ($chan,$reason) = $event->args;
387 my $kicker = $event->nick;
388 my $kickee = ($event->to)[0];
389 my $uh = $event->userhost();
391 &status(">>> kick/$b_blue$chan$ob [$b$kickee!$uh$ob] by $b_cyan$kicker$ob $b_yellow($ob$reason$b_yellow)$ob");
393 $chanstats{$chan}{'Kick'}++;
395 if ($kickee eq $ident) {
396 &clearChanVars($chan);
398 &status("SELF attempting to rejoin lost channel $chan");
401 &DeleteUserInfo($kickee,$chan);
406 my ($self, $event) = @_;
407 my ($user, $host) = split(/\@/, $event->userhost);
408 my @args = $event->args();
409 my $nick = $event->nick();
410 my $chan = ($event->to)[0];
414 if ($nick eq $chan) { # UMODE
415 &status(">>> mode $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
417 &status(">>> mode/$b_blue$chan$ob $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
418 &hookMode($chan, @args);
423 my ($self, $event) = @_;
424 my $nick = $event->nick();
425 my ($myself,$chan,@args) = $event->args();
427 &hookMode(lc $chan, @args); # CASING.
431 my ($self, $event) = @_;
432 my $nick = $event->nick;
433 my $chan = lc ( ($event->to)[0] ); # CASING.
434 my $msg = ($event->args)[0];
436 ($user,$host) = split(/\@/, $event->userhost);
437 $uh = $event->userhost();
438 $nuh = $nick."!".$uh;
440 &hookMsg('private', $chan, $nick, $msg);
444 my ($self, $event) = @_;
445 my @args = $event->args;
446 my $chan = lc $args[2]; # CASING, the last of them!
448 foreach (split / /, @args[3..$#args]) {
449 $channels{$chan}{'o'}{$_}++ if s/\@//;
450 $channels{$chan}{'v'}{$_}++ if s/\+//;
451 $channels{$chan}{''}{$_}++;
456 my ($self, $event) = @_;
457 my $nick = $event->nick();
458 my $newnick = ($event->args)[0];
460 if (exists $netsplit{lc $newnick}) {
461 &DEBUG("on_nick: $newnick/$nick came back from netsplit and changed to original nick! removing from hash.");
462 delete $netsplit{lc $newnick};
466 foreach $chan (keys %channels) {
467 foreach $mode (keys %{$channels{$chan}}) {
468 next unless (exists $channels{$chan}{$mode}{$nick});
470 $channels{$chan}{$mode}{$newnick} = $channels{$chan}{$mode}{$nick};
473 &DeleteUserInfo($nick,keys %channels);
474 $nuh{lc $newnick} = $nuh{lc $nick};
475 delete $nuh{lc $nick};
477 # successful self-nick change.
478 if ($nick eq $ident) {
479 &status(">>> I materialized into $b_green$newnick$ob from $nick");
482 &status(">>> $b_cyan$nick$ob materializes into $b_green$newnick$ob");
488 my $nick = $self->nick;
489 my $newnick = substr($nick,0,7)."-";
491 &status("nick taken; changing to temporary nick.");
497 my ($self, $event) = @_;
498 my $nick = $event->nick();
499 my $chan = ($event->to)[0];
500 my $args = ($event->args)[0];
502 if ($nick =~ /^NickServ$/i) { # nickserv.
503 &status("NickServ: <== '$args'");
505 if ($args =~ /^This nickname is registered/i) {
506 &status("nickserv told us to register; doing it.");
507 if (&IsParam("nickServ_pass")) {
508 &status("NickServ: ==> Identifying.");
509 &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
512 &status("We can't tell nickserv a passwd ;(");
517 if ($args =~ /^Password a/i) {
520 } elsif ($nick =~ /^ChanServ$/i) { # chanserv.
521 &status("ChanServ: <== '$args'.");
523 if ($chan =~ /^$mask{chan}$/) { # channel notice.
524 &status("-$nick/$chan- $args");
526 $server = $nick unless (defined $server);
527 &status("-$nick- $args"); # private or server notice.
533 my ($self, $event) = @_;
534 my $chan = ($event->to)[0];
535 my $nick = $event->nick;
537 &status("!!! other called.");
538 &status("!!! $event->args");
542 my ($self, $event) = @_;
543 my $chan = lc( ($event->to)[0] ); # CASING!!!
544 my $nick = $event->nick;
545 my $userhost = $event->userhost;
547 $chanstats{$chan}{'Part'}++;
548 &DeleteUserInfo($nick,$chan);
549 &clearChanVars($chan) if ($nick eq $ident);
550 if (!&IsNickInAnyChan($nick) and &IsParam("seenStats")) {
551 delete $userstats{lc $nick};
554 &status(">>> part/$b_blue$chan$ob $b_cyan$nick$ob $b_yellow($ob$userhost$b_yellow)$ob");
558 my ($self, $event) = @_;
559 my $nick = $event->nick;
561 $self->ctcp_reply($nick, join(' ', ($event->args)));
562 &status(">>> ${b_green}CTCP PING$ob request from $b_cyan$nick$ob received.");
566 my ($self, $event) = @_;
567 my $nick = $event->nick;
568 my $lag = time() - ($event->args)[1];
570 &status(">>> ${b_green}CTCP PING$ob reply from $b_cyan$nick$ob: $lag sec.");
574 my ($self, $event) = @_;
575 my $msg = ($event->args)[0];
576 my $chan = lc( ($event->to)[0] ); # CASING.
577 my $nick = $event->nick;
578 $uh = $event->userhost();
579 $nuh = $nick."!".$uh;
580 ($user,$host) = split(/\@/, $uh);
582 if ($$ != $bot_pid) {
583 &ERROR("SHOULD NEVER HAPPEN.");
588 if ($statcount < 200) {
589 foreach $chan (grep /[A-Z]/, keys %channels) {
590 &DEBUG("leak: chan => '$chan'.");
592 foreach $i (keys %{$channels{$chan}}) {
593 foreach (keys %{$channels{$chan}{$i}}) {
594 &DEBUG("leak: \$channels{$chan}{$i}{$_} ...");
602 $lastWho{$chan} = $nick;
603 ### TODO: use $nick or lc $nick?
604 if (&IsParam("seenStats")) {
605 $userstats{lc $nick}{'Count'}++;
606 $userstats{lc $nick}{'Time'} = time();
609 # if (&IsParam("hehCounter")) {
613 &hookMsg('public', $chan, $nick, $msg);
614 $chanstats{$chan}{'PublicMsg'}++;
618 my ($self, $event) = @_;
619 my $nick = $event->nick();
620 my $reason = ($event->args)[0];
622 foreach (keys %channels) {
623 # fixes inconsistent chanstats bug #1.
624 next unless (&IsNickInChan($nick,$_));
625 $chanstats{$_}{'SignOff'}++;
627 &DeleteUserInfo($nick, keys %channels);
628 if (exists $nuh{lc $nick}) {
629 delete $nuh{lc $nick};
631 &DEBUG("on_quit: nuh{lc $nick} does not exist! FIXME");
633 delete $userstats{lc $nick} if (&IsParam("seenStats"));
635 # should fix chanstats inconsistencies bug #2.
636 if ($reason=~/^($mask{host})\s($mask{host})$/) { # netsplit.
637 $reason = "NETSPLIT: $1 <=> $2";
639 $netsplit{lc $nick} = time();
640 if (!exists $netsplitservers{$1}{$2}) {
641 &status("netsplit detected between $1 and $2.");
642 $netsplitservers{$1}{$2} = time();
646 &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob");
647 if ($nick =~ /^\Q$ident\E$/) {
648 &DEBUG("!!! THIS SHOULD NEVER HAPPEN. FIXME HOPEFULLY");
650 if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) {
651 &status("own nickname became free; changing.");
652 &nick($param{'ircNick'});
656 sub on_targettoofast {
657 my ($self, $event) = @_;
658 my $nick = $event->nick();
659 my $chan = ($event->to)[0];
661 &DEBUG("on_targettoofast: nick => '$nick'.");
662 &DEBUG("on_targettoofast: chan => '$chan'.");
664 foreach ($event->args) {
665 &DEBUG("on_targettoofast: args => '$_'.");
668 ### .* wait (\d+) second/) {
672 &status("going to sleep for $sleep...");
679 my ($self, $event) = @_;
681 if (scalar($event->args) == 1) { # change.
682 my $topic = ($event->args)[0];
683 my $chan = ($event->to)[0];
684 my $nick = $event->nick();
688 # race condition here. To fix, change '1' to '0'.
689 # This will keep track of topics set by bot only.
692 # this may be fixed at a later date with topic queueing.
695 $topic{$chan}{'Current'} = $topic if (1 and &IsParam("topic") == 1);
696 $chanstats{$chan}{'Topic'}++;
698 &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic");
700 my ($nick, $chan, $topic) = $event->args;
701 if (&IsParam("topic")) {
702 $topic{$chan}{'Current'} = $topic;
703 &topicAddHistory($chan,$topic);
706 $topic = &fixString($topic, 1);
707 &status(">>> topic/$b_blue$chan$ob is $topic");
712 my ($self, $event) = @_;
713 my ($myself,$chan,$setby,$time) = $event->args();
716 if (time() - $time > 60*60*24) {
717 $timestr = "at ". localtime $time;
719 $timestr = &Time2String(time() - $time) ." ago";
722 &status(">>> set by $b_cyan$setby$ob $timestr");
726 my ($self, $event) = @_;
727 my $nick = $event->nick;
729 &status(">>> ${b_green}CTCP VERSION$ob request from $b_cyan$nick$ob");
730 $self->ctcp_reply($nick, "VERSION $bot_version");
734 my ($self, $event) = @_;
735 my @args = $event->args;
737 $nuh{lc $args[5]} = $args[5]."!".$args[2]."\@".$args[3];
741 my ($self, $event) = @_;
742 my @args = $event->args;
744 $nuh{lc $args[1]} = $args[1]."!".$args[2]."\@".$args[3];
747 #######################################################################
748 ####### IRC HOOK HELPERS IRC HOOK HELPERS IRC HOOK HELPERS ########
749 #######################################################################
752 # Usage: &hookMode($chan, $modes, @targets);
754 my ($chan, $modes, @targets) = @_;
757 $chan = lc $chan; # !!!.
760 foreach $mode (split(//, $modes)) {
762 if ($mode =~ /[-+]/) {
763 $parity = 1 if ($mode eq "+");
764 $parity = 0 if ($mode eq "-");
769 if ($mode =~ /[bklov]/) {
770 my $target = shift @targets;
773 $chanstats{$chan}{'Op'}++ if ($mode eq "o");
774 $chanstats{$chan}{'Ban'}++ if ($mode eq "b");
776 $chanstats{$chan}{'Deop'}++ if ($mode eq "o");
777 $chanstats{$chan}{'Unban'}++ if ($mode eq "b");
780 # modes w/ target affecting nick => cache it.
781 if ($mode =~ /[ov]/) {
782 $channels{$chan}{$mode}{$target}++ if $parity;
783 delete $channels{$chan}{$mode}{$target} if !$parity;
786 if ($mode =~ /[l]/) {
787 $channels{$chan}{$mode} = $target if $parity;
788 delete $channels{$chan}{$mode} if !$parity;
792 # important channel modes, targetless.
793 if ($mode =~ /[mt]/) {
794 $channels{$chan}{$mode}++ if $parity;
795 delete $channels{$chan}{$mode} if !$parity;
801 ($msgType, $chan, $who, $message) = @_;
805 $orig{message} = $message;
809 $message =~ s/[\cA-\c_]//ig; # strip control characters
810 $message =~ s/^\s+//; # initial whitespaces.
811 $who =~ tr/A-Z/a-z/; # lowercase.
816 if ($msgType =~ /private/) {
821 # addressing revamped by the xk.
822 ### below needs to be fixed...
823 if (&IsParam("addressCharacter")) {
824 if ($message =~ s/^$param{'addressCharacter'}//) {
830 if ($message =~ /^($mask{nick})([\;\:\>\, ]+) */) {
832 if ($1 =~ /^\Q$ident\E$/i) {
833 $message = $newmessage;
836 # ignore messages addressed to other people or unaddressed.
837 $skipmessage++ if ($2 ne "" and $2 !~ /^ /);
842 # Determine floodwho.
843 if ($msgType =~ /public/i) { # public.
844 $floodwho = lc $chan;
845 } elsif ($msgType =~ /private/i) { # private.
848 &DEBUG("FIXME: floodwho = ???");
851 my ($count, $interval) = split(/:/, $param{'floodRepeat'} || "2:10");
853 # flood repeat protection.
855 my $time = $flood{$floodwho}{$message};
857 if (defined $time and (time - $time < $interval)) {
858 ### public != personal who so the below is kind of pointless.
860 foreach (keys %flood) {
861 next if (/^\Q$floodwho\E$/ or /^\Q$chan\E$/);
862 push(@who, grep /^\Q$message\E$/i, keys %{$flood{$_}});
865 &msg($who, "you already said what ".
866 join(' ', @who)." have said.");
868 &msg($who,"Someone already said that ". (time - $time) ." seconds ago" );
871 ### TODO: delete old floodwarn{} keys.
873 if (!exists $floodwarn{$floodwho}) {
876 $floodwarn++ if (time() - $floodwarn{$floodwho} > $interval);
880 &status("FLOOD repetition detected from $floodwho.");
881 $floodwarn{$floodwho} = time();
888 &status("$b_cyan$who$ob is short-addressing me");
890 &status("$b_cyan$who$ob is addressing me");
893 $flood{$floodwho}{$message} = time();
896 ($count, $interval) = split(/:/, $param{'floodMessages'} || "5:30");
897 # flood overflow protection.
899 foreach (keys %{$flood{$floodwho}}) {
900 next unless (time() - $flood{$floodwho}{$_} > $interval);
901 delete $flood{$floodwho}{$_};
904 my $i = scalar keys %{$flood{$floodwho}};
906 &msg($who,"overflow of messages ($i > $count)");
907 &status("FLOOD overflow detected from $floodwho; ignoring");
909 my $expire = $param{'ignoreAutoExpire'} || 5;
910 $ignoreList{"*!$uh"} = time() + ($expire * 60);
914 $flood{$floodwho}{$message} = time();
918 if ($msgType =~ /public/i) {
919 $talkchannel = $chan;
920 &status("<$orig{who}/$chan> $orig{message}");
924 if ($msgType =~ /private/i) {
925 &status("[$orig{who}] $orig{message}");
928 if ((!$skipmessage or &IsParam("seenStoreAll")) and
932 $seencache{$who}{'time'} = time();
933 $seencache{$who}{'nick'} = $orig{who};
934 $seencache{$who}{'host'} = $uh;
935 $seencache{$who}{'chan'} = $talkchannel;
936 $seencache{$who}{'msg'} = $orig{message};
937 $seencache{$who}{'msgcount'}++;
940 return if ($skipmessage);
941 return unless (&IsParam("minVolunteerLength") or $addressed);
944 foreach (keys %ignoreList) {
946 my @parts = split /\*/, "a${ignoreRE}a";
947 my $recast = join '\S*', map quotemeta($_), @parts;
948 $recast =~ s/^a(.*)a$/$1/;
949 if ($nuh =~ /^$recast$/) {
956 $userHandle = &verifyUser($who, $nuh);
958 &DEBUG("hookMsg: 'nuh' not defined?");
961 ### For extra debugging purposes...
962 if ($_ = &process()) {
963 # &DEBUG("IrcHooks: process returned '$_'.");