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 &DEBUG("on_EOM: calling sS in 60s.");
131 $conn->schedule(60, \&setupSchedulers, "");
135 if (&IsParam("ircUMode")) {
136 &status("Attempting change of user modes to $param{'ircUMode'}.");
137 &rawout("MODE $ident $param{'ircUMode'}");
140 &status("End of motd. Now lets join some channels...");
141 if (!scalar @joinchan) {
142 &WARN("joinchan array is empty!!!");
143 @joinchan = split /[\t\s]+/, $param{'join_channels'};
150 my ($self, $event) = @_;
151 my $type = uc( ($event->args)[1] );
152 my $nick = $event->nick();
154 # pity Net::IRC doesn't store nuh. Here's a hack :)
158 if ($type eq 'SEND') { # GET for us.
159 # incoming DCC SEND. we're receiving a file.
160 my $get = ($event->args)[2];
161 open(DCCGET,">$get");
163 $self->new_get($nick,
170 } elsif ($type eq 'GET') { # SEND for us?
171 &DEBUG("starting get.");
172 $self->new_send($event->args);
173 } elsif ($type eq 'CHAT') {
174 &DEBUG("starting chat.");
175 $self->new_chat($event);
177 &WARN("${b_green}DCC $type$ob (1)");
182 my ($self, $event) = @_;
183 my $nick = $event->nick();
184 my $sock = ($event->to)[0];
186 # DCC CHAT close on fork exit workaround.
187 return if ($bot_pid != $$);
189 &DEBUG("dcc_close: nick => '$nick'.");
191 if (exists $dcc{'SEND'}{$nick} and -f "$param{tempDir}/$nick.txt") {
192 &status("${b_green}DCC SEND$ob close from $b_cyan$nick$ob");
194 &status("dcc_close: purging $nick.txt from Debian.pl");
195 unlink "$param{tempDir}/$nick.txt";
197 delete $dcc{'SEND'}{$nick};
198 } elsif (exists $dcc{'CHAT'}{$nick} and $dcc{'CHAT'}{$nick} eq $sock) {
199 &status("${b_green}DCC CHAT$ob close from $b_cyan$nick$ob");
200 delete $dcc{'CHAT'}{$nick};
202 &status("${b_green}DCC$ob UNKNOWN close from $b_cyan$nick$ob (2)");
207 my ($self, $event) = @_;
208 my $type = uc( ($event->args)[0] );
209 my $nick = $event->nick();
210 my $sock = ($event->to)[0];
215 if ($type eq 'SEND') {
216 &status("${b_green}DCC lGET$ob established with $b_cyan$nick$ob");
217 } elsif ($type eq 'CHAT') {
218 &status("${b_green}DCC CHAT$ob established with $b_cyan$nick$ob $b_yellow($ob$nuh{$nick}$b_yellow)$ob");
219 $userHandle = &verifyUser($nick, $nuh{lc $nick});
220 my $crypto = $userList{$userHandle}{'pass'};
221 $dcc{'CHAT'}{$nick} = $sock;
223 if (defined $crypto) {
224 &dccsay($nick,"Enter Password, $userHandle.");
226 &dccsay($nick,"Welcome to blootbot DCC CHAT interface, $userHandle.");
228 } elsif ($type eq 'SEND') {
229 &DEBUG("Starting DCC receive.");
230 foreach ($event->args) {
234 &WARN("${b_green}DCC $type$ob (3)");
239 my ($self, $event) = @_;
240 my $from = $event->from();
241 my $what = ($event->args)[0];
243 &status("disconnect from $from ($what).");
244 $ircstats{'DisconnectTime'} = time();
245 $ircstats{'DisconnectReason'} = $what;
246 $ircstats{'DisconnectCount'}++;
248 # clear any variables on reconnection.
252 if (!$self->connect()) {
253 &WARN("not connected? help me. gonna call ircCheck() in 1800s");
254 $conn->schedule(1800, \&ircCheck(), "");
259 my ($self, $event) = @_;
260 my $chan = ($event->args)[1];
262 if (exists $jointime{$chan}) {
263 my $delta_time = sprintf("%.03f", &gettimeofday() - $jointime{$chan});
264 $delta_time = 0 if ($delta_time < 0);
266 &status("$b_blue$chan$ob: sync in ${delta_time}s.");
269 rawout("MODE $chan");
273 foreach ("o","v","") {
274 my $count = scalar(keys %{$channels{$chan}{$_}});
275 next unless ($count);
277 $txt = "total" if ($_ eq "");
278 $txt = "voice" if ($_ eq "v");
279 $txt = "ops" if ($_ eq "o");
281 push(@array, "$count $txt");
283 my $chanstats = join(' || ', @array);
284 &status("$b_blue$chan$ob: [$chanstats]");
286 if (scalar @joinchan) { # remaining channels to join.
289 ### chanserv support.
290 ### TODO: what if we rejoin a channel.. need to set a var that
291 ### we've done the request-for-ops-on-join.
292 return unless (&IsParam("chanServ_ops"));
293 return unless ($nickserv);
295 my @chans = split(/[\s\t]+/, $param{'chanServ_ops'});
297 ### TODO: since this function has a chan arg, why don't we use
298 ### that instead of doing the following?
299 foreach $chan (keys %channels) {
300 next unless (grep /^$chan$/i, @chans);
302 if (!exists $channels{$chan}{'o'}{$ident}) {
303 &status("ChanServ ==> Requesting ops for $chan.");
304 &rawout("PRIVMSG ChanServ :OP $chan $ident");
312 my ($self, $event) = @_;
313 my (@args) = ($event->args);
320 my ($self, $event) = @_;
321 my $chan = ($event->args)[0];
322 my $nick = $event->nick;
324 &DEBUG("on_invite: chan => '$chan', nick => '$nick'.");
326 # chan + possible_key.
327 ### do we need to know the key if we're invited???
328 ### grep the channel list?
329 foreach (split /[\s\t]+/, $param{'join_channels'}) {
330 next unless /^\Q$chan\E(,\S+)?$/i;
333 next if ($nick =~ /^\Q$ident\E$/);
334 if (&validChan($chan)) {
335 &msg($who, "i'm already in \002$chan\002.");
339 &status("invited to $b_blue$_$ob by $b_cyan$who$ob");
340 &joinchan($self, $_);
345 my ($self, $event) = @_;
346 my ($user,$host) = split(/\@/, $event->userhost);
347 $chan = lc( ($event->to)[0] ); # CASING!!!!
348 $who = $event->nick();
350 $chanstats{$chan}{'Join'}++;
351 $userstats{lc $who}{'Join'} = time() if (&IsParam("seenStats"));
355 if (exists $netsplit{lc $who}) {
356 delete $netsplit{lc $who};
360 if ($netsplit and !$netsplittime) {
361 &status("ok.... re-running chanlimitCheck in 60.");
362 $conn->schedule(60, sub {
364 $netsplittime = undef;
367 $netsplittime = time();
370 # how to tell if there's a netjoin???
372 my $netsplitstr = "";
373 $netsplitstr = " $b_yellow\[${ob}NETSPLIT VICTIM$b_yellow]$ob" if ($netsplit);
374 &status(">>> join/$b_blue$chan$ob $b_cyan$who$ob $b_yellow($ob$user\@$host$b_yellow)$ob$netsplitstr");
376 $channels{$chan}{''}{$who}++;
377 $nuh{lc $who} = $who."!".$user."\@".$host unless (exists $nuh{lc $who});
380 &rootWarn($who,$user,$host,$chan)
381 if (&IsParam("rootWarn") &&
382 $user =~ /^r(oo|ew|00)t$/i &&
383 $channels{$chan}{'o'}{$ident});
385 # used to determine sync time.
386 if ($who =~ /^$ident$/i) {
387 if (defined( my $whojoin = $joinverb{$chan} )) {
388 &msg($chan, "Okay, I'm here. (courtesy of $whojoin)");
389 delete $joinverb{$chan};
392 ### TODO: move this to &joinchan()?
393 $jointime{$chan} = &gettimeofday();
396 ### TODO: this may go wild on a netjoin :)
403 my ($self, $event) = @_;
404 my ($chan,$reason) = $event->args;
405 my $kicker = $event->nick;
406 my $kickee = ($event->to)[0];
407 my $uh = $event->userhost();
409 &status(">>> kick/$b_blue$chan$ob [$b$kickee!$uh$ob] by $b_cyan$kicker$ob $b_yellow($ob$reason$b_yellow)$ob");
411 $chanstats{$chan}{'Kick'}++;
413 if ($kickee eq $ident) {
414 &clearChanVars($chan);
416 &status("SELF attempting to rejoin lost channel $chan");
419 &DeleteUserInfo($kickee,$chan);
424 my ($self, $event) = @_;
425 my ($user, $host) = split(/\@/, $event->userhost);
426 my @args = $event->args();
427 my $nick = $event->nick();
428 my $chan = ($event->to)[0];
432 if ($nick eq $chan) { # UMODE
433 &status(">>> mode $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
435 &status(">>> mode/$b_blue$chan$ob $b_yellow\[$ob$b@args$b_yellow\]$ob by $b_cyan$nick$ob");
436 &hookMode($chan, @args);
441 my ($self, $event) = @_;
442 my $nick = $event->nick();
443 my ($myself,$chan,@args) = $event->args();
445 &hookMode(lc $chan, @args); # CASING.
449 my ($self, $event) = @_;
450 my $nick = $event->nick;
451 my $chan = lc ( ($event->to)[0] ); # CASING.
452 my $msg = ($event->args)[0];
454 ($user,$host) = split(/\@/, $event->userhost);
455 $uh = $event->userhost();
456 $nuh = $nick."!".$uh;
458 &hookMsg('private', $chan, $nick, $msg);
462 my ($self, $event) = @_;
463 my @args = $event->args;
464 my $chan = lc $args[2]; # CASING, the last of them!
466 foreach (split / /, @args[3..$#args]) {
467 $channels{$chan}{'o'}{$_}++ if s/\@//;
468 $channels{$chan}{'v'}{$_}++ if s/\+//;
469 $channels{$chan}{''}{$_}++;
474 my ($self, $event) = @_;
475 my $nick = $event->nick();
476 my $newnick = ($event->args)[0];
478 if (exists $netsplit{lc $newnick}) {
479 &status("Netsplit: $newnick/$nick came back from netsplit and changed to original nick! removing from hash.");
480 delete $netsplit{lc $newnick};
484 foreach $chan (keys %channels) {
485 foreach $mode (keys %{$channels{$chan}}) {
486 next unless (exists $channels{$chan}{$mode}{$nick});
488 $channels{$chan}{$mode}{$newnick} = $channels{$chan}{$mode}{$nick};
491 &DeleteUserInfo($nick,keys %channels);
492 $nuh{lc $newnick} = $nuh{lc $nick};
493 delete $nuh{lc $nick};
495 # successful self-nick change.
496 if ($nick eq $ident) {
497 &status(">>> I materialized into $b_green$newnick$ob from $nick");
500 &status(">>> $b_cyan$nick$ob materializes into $b_green$newnick$ob");
506 my $nick = $self->nick;
507 my $newnick = substr($nick,0,7)."-";
509 &status("nick taken; changing to temporary nick.");
515 my ($self, $event) = @_;
516 my $nick = $event->nick();
517 my $chan = ($event->to)[0];
518 my $args = ($event->args)[0];
520 if ($nick =~ /^NickServ$/i) { # nickserv.
521 &status("NickServ: <== '$args'");
523 if ($args =~ /^This nickname is registered/i) {
524 &status("nickserv told us to register; doing it.");
525 if (&IsParam("nickServ_pass")) {
526 &status("NickServ: ==> Identifying.");
527 &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
530 &status("We can't tell nickserv a passwd ;(");
535 if ($args =~ /^Password a/i) {
538 } elsif ($nick =~ /^ChanServ$/i) { # chanserv.
539 &status("ChanServ: <== '$args'.");
541 if ($chan =~ /^$mask{chan}$/) { # channel notice.
542 &status("-$nick/$chan- $args");
544 $server = $nick unless (defined $server);
545 &status("-$nick- $args"); # private or server notice.
551 my ($self, $event) = @_;
552 my $chan = ($event->to)[0];
553 my $nick = $event->nick;
555 &status("!!! other called.");
556 &status("!!! $event->args");
560 my ($self, $event) = @_;
561 my $chan = lc( ($event->to)[0] ); # CASING!!!
562 my $nick = $event->nick;
563 my $userhost = $event->userhost;
565 $chanstats{$chan}{'Part'}++;
566 &DeleteUserInfo($nick,$chan);
567 &clearChanVars($chan) if ($nick eq $ident);
568 if (!&IsNickInAnyChan($nick) and &IsParam("seenStats")) {
569 delete $userstats{lc $nick};
572 &status(">>> part/$b_blue$chan$ob $b_cyan$nick$ob $b_yellow($ob$userhost$b_yellow)$ob");
576 my ($self, $event) = @_;
577 my $nick = $event->nick;
579 $self->ctcp_reply($nick, join(' ', ($event->args)));
580 &status(">>> ${b_green}CTCP PING$ob request from $b_cyan$nick$ob received.");
584 my ($self, $event) = @_;
585 my $nick = $event->nick;
586 my $lag = time() - ($event->args)[1];
588 &status(">>> ${b_green}CTCP PING$ob reply from $b_cyan$nick$ob: $lag sec.");
592 my ($self, $event) = @_;
593 my $msg = ($event->args)[0];
594 my $chan = lc( ($event->to)[0] ); # CASING.
595 my $nick = $event->nick;
596 $uh = $event->userhost();
597 $nuh = $nick."!".$uh;
598 ($user,$host) = split(/\@/, $uh);
600 if ($$ != $bot_pid) {
601 &ERROR("SHOULD NEVER HAPPEN.");
606 if ($statcount < 200) {
607 foreach $chan (grep /[A-Z]/, keys %channels) {
608 &DEBUG("leak: chan => '$chan'.");
610 foreach $i (keys %{$channels{$chan}}) {
611 foreach (keys %{$channels{$chan}{$i}}) {
612 &DEBUG("leak: \$channels{$chan}{$i}{$_} ...");
620 $lastWho{$chan} = $nick;
621 ### TODO: use $nick or lc $nick?
622 if (&IsParam("seenStats")) {
623 $userstats{lc $nick}{'Count'}++;
624 $userstats{lc $nick}{'Time'} = time();
627 # if (&IsParam("hehCounter")) {
631 &hookMsg('public', $chan, $nick, $msg);
632 $chanstats{$chan}{'PublicMsg'}++;
636 my ($self, $event) = @_;
637 my $nick = $event->nick();
638 my $reason = ($event->args)[0];
640 foreach (keys %channels) {
641 # fixes inconsistent chanstats bug #1.
642 next unless (&IsNickInChan($nick,$_));
643 $chanstats{$_}{'SignOff'}++;
645 &DeleteUserInfo($nick, keys %channels);
646 if (exists $nuh{lc $nick}) {
647 delete $nuh{lc $nick};
649 &DEBUG("on_quit: nuh{lc $nick} does not exist! FIXME");
651 delete $userstats{lc $nick} if (&IsParam("seenStats"));
653 # should fix chanstats inconsistencies bug #2.
654 if ($reason=~/^($mask{host})\s($mask{host})$/) { # netsplit.
655 $reason = "NETSPLIT: $1 <=> $2";
657 $netsplit{lc $nick} = time();
658 if (!exists $netsplitservers{$1}{$2}) {
659 &status("netsplit detected between $1 and $2.");
660 $netsplitservers{$1}{$2} = time();
664 &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob");
665 if ($nick =~ /^\Q$ident\E$/) {
666 &DEBUG("!!! THIS SHOULD NEVER HAPPEN. FIXME HOPEFULLY");
668 if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$param{'ircNick'}\E$/i) {
669 &status("own nickname became free; changing.");
670 &nick($param{'ircNick'});
674 sub on_targettoofast {
675 my ($self, $event) = @_;
676 my $nick = $event->nick();
677 my $chan = ($event->to)[0];
679 &DEBUG("on_targettoofast: nick => '$nick'.");
680 &DEBUG("on_targettoofast: chan => '$chan'.");
682 foreach ($event->args) {
683 &DEBUG("on_targettoofast: args => '$_'.");
686 ### .* wait (\d+) second/) {
690 &status("going to sleep for $sleep...");
697 my ($self, $event) = @_;
699 if (scalar($event->args) == 1) { # change.
700 my $topic = ($event->args)[0];
701 my $chan = ($event->to)[0];
702 my $nick = $event->nick();
706 # race condition here. To fix, change '1' to '0'.
707 # This will keep track of topics set by bot only.
710 # this may be fixed at a later date with topic queueing.
713 $topic{$chan}{'Current'} = $topic if (1 and &IsParam("topic") == 1);
714 $chanstats{$chan}{'Topic'}++;
716 &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic");
718 my ($nick, $chan, $topic) = $event->args;
719 if (&IsParam("topic")) {
720 $topic{$chan}{'Current'} = $topic;
721 &topicAddHistory($chan,$topic);
724 $topic = &fixString($topic, 1);
725 &status(">>> topic/$b_blue$chan$ob is $topic");
730 my ($self, $event) = @_;
731 my ($myself,$chan,$setby,$time) = $event->args();
734 if (time() - $time > 60*60*24) {
735 $timestr = "at ". localtime $time;
737 $timestr = &Time2String(time() - $time) ." ago";
740 &status(">>> set by $b_cyan$setby$ob $timestr");
744 my ($self, $event) = @_;
745 my $nick = $event->nick;
747 &status(">>> ${b_green}CTCP VERSION$ob request from $b_cyan$nick$ob");
748 $self->ctcp_reply($nick, "VERSION $bot_version");
752 my ($self, $event) = @_;
753 my @args = $event->args;
755 $nuh{lc $args[5]} = $args[5]."!".$args[2]."\@".$args[3];
759 my ($self, $event) = @_;
760 my @args = $event->args;
762 $nuh{lc $args[1]} = $args[1]."!".$args[2]."\@".$args[3];
765 #######################################################################
766 ####### IRC HOOK HELPERS IRC HOOK HELPERS IRC HOOK HELPERS ########
767 #######################################################################
770 # Usage: &hookMode($chan, $modes, @targets);
772 my ($chan, $modes, @targets) = @_;
775 $chan = lc $chan; # !!!.
778 foreach $mode (split(//, $modes)) {
780 if ($mode =~ /[-+]/) {
781 $parity = 1 if ($mode eq "+");
782 $parity = 0 if ($mode eq "-");
787 if ($mode =~ /[bklov]/) {
788 my $target = shift @targets;
791 $chanstats{$chan}{'Op'}++ if ($mode eq "o");
792 $chanstats{$chan}{'Ban'}++ if ($mode eq "b");
794 $chanstats{$chan}{'Deop'}++ if ($mode eq "o");
795 $chanstats{$chan}{'Unban'}++ if ($mode eq "b");
798 # modes w/ target affecting nick => cache it.
799 if ($mode =~ /[ov]/) {
800 $channels{$chan}{$mode}{$target}++ if $parity;
801 delete $channels{$chan}{$mode}{$target} if !$parity;
804 if ($mode =~ /[l]/) {
805 $channels{$chan}{$mode} = $target if $parity;
806 delete $channels{$chan}{$mode} if !$parity;
810 # important channel modes, targetless.
811 if ($mode =~ /[mt]/) {
812 $channels{$chan}{$mode}++ if $parity;
813 delete $channels{$chan}{$mode} if !$parity;
819 ($msgType, $chan, $who, $message) = @_;
823 $orig{message} = $message;
827 $message =~ s/[\cA-\c_]//ig; # strip control characters
828 $message =~ s/^\s+//; # initial whitespaces.
829 $who =~ tr/A-Z/a-z/; # lowercase.
834 if ($msgType =~ /private/) {
839 # addressing revamped by the xk.
840 ### below needs to be fixed...
841 if (&IsParam("addressCharacter")) {
842 if ($message =~ s/^$param{'addressCharacter'}//) {
848 if ($message =~ /^($mask{nick})([\;\:\>\, ]+) */) {
850 if ($1 =~ /^\Q$ident\E$/i) {
851 $message = $newmessage;
854 # ignore messages addressed to other people or unaddressed.
855 $skipmessage++ if ($2 ne "" and $2 !~ /^ /);
860 # Determine floodwho.
861 if ($msgType =~ /public/i) { # public.
862 $floodwho = lc $chan;
863 } elsif ($msgType =~ /private/i) { # private.
866 &DEBUG("FIXME: floodwho = ???");
869 my ($count, $interval) = split(/:/, $param{'floodRepeat'} || "2:10");
871 # flood repeat protection.
873 my $time = $flood{$floodwho}{$message};
875 if (defined $time and (time - $time < $interval)) {
876 ### public != personal who so the below is kind of pointless.
878 foreach (keys %flood) {
879 next if (/^\Q$floodwho\E$/ or /^\Q$chan\E$/);
880 push(@who, grep /^\Q$message\E$/i, keys %{$flood{$_}});
883 &msg($who, "you already said what ".
884 join(' ', @who)." have said.");
886 &msg($who,"Someone already said that ". (time - $time) ." seconds ago" );
889 ### TODO: delete old floodwarn{} keys.
891 if (!exists $floodwarn{$floodwho}) {
894 $floodwarn++ if (time() - $floodwarn{$floodwho} > $interval);
898 &status("FLOOD repetition detected from $floodwho.");
899 $floodwarn{$floodwho} = time();
906 &status("$b_cyan$who$ob is short-addressing me");
908 &status("$b_cyan$who$ob is addressing me");
911 $flood{$floodwho}{$message} = time();
914 ($count, $interval) = split(/:/, $param{'floodMessages'} || "5:30");
915 # flood overflow protection.
917 foreach (keys %{$flood{$floodwho}}) {
918 next unless (time() - $flood{$floodwho}{$_} > $interval);
919 delete $flood{$floodwho}{$_};
922 my $i = scalar keys %{$flood{$floodwho}};
924 &msg($who,"overflow of messages ($i > $count)");
925 &status("FLOOD overflow detected from $floodwho; ignoring");
927 my $expire = $param{'ignoreAutoExpire'} || 5;
928 $ignoreList{"*!$uh"} = time() + ($expire * 60);
932 $flood{$floodwho}{$message} = time();
936 if ($msgType =~ /public/i) {
937 $talkchannel = $chan;
938 &status("<$orig{who}/$chan> $orig{message}");
942 if ($msgType =~ /private/i) {
943 &status("[$orig{who}] $orig{message}");
946 if ((!$skipmessage or &IsParam("seenStoreAll")) and
950 $seencache{$who}{'time'} = time();
951 $seencache{$who}{'nick'} = $orig{who};
952 $seencache{$who}{'host'} = $uh;
953 $seencache{$who}{'chan'} = $talkchannel;
954 $seencache{$who}{'msg'} = $orig{message};
955 $seencache{$who}{'msgcount'}++;
958 return if ($skipmessage);
959 return unless (&IsParam("minVolunteerLength") or $addressed);
962 foreach (keys %ignoreList) {
964 my @parts = split /\*/, "a${ignoreRE}a";
965 my $recast = join '\S*', map quotemeta($_), @parts;
966 $recast =~ s/^a(.*)a$/$1/;
967 if ($nuh =~ /^$recast$/) {
974 $userHandle = &verifyUser($who, $nuh);
976 &DEBUG("hookMsg: 'nuh' not defined?");
979 ### For extra debugging purposes...
980 if ($_ = &process()) {
981 # &DEBUG("IrcHooks: process returned '$_'.");