- $nuh{lc $args[1]} = $args[1]."!".$args[2]."\@".$args[3];
-}
-
-#######################################################################
-####### IRC HOOK HELPERS IRC HOOK HELPERS IRC HOOK HELPERS ########
-#######################################################################
-
-#####
-# Usage: &hookMode($chan, $modes, @targets);
-sub hookMode {
- my ($chan, $modes, @targets) = @_;
- my $parity = 0;
-
- $chan = lc $chan; # !!!.
-
- my $mode;
- foreach $mode (split(//, $modes)) {
- # sign.
- if ($mode =~ /[-+]/) {
- $parity = 1 if ($mode eq "+");
- $parity = 0 if ($mode eq "-");
- next;
- }
-
- # mode with target.
- if ($mode =~ /[bklov]/) {
- my $target = shift @targets;
-
- if ($parity) {
- $chanstats{$chan}{'Op'}++ if ($mode eq "o");
- $chanstats{$chan}{'Ban'}++ if ($mode eq "b");
- } else {
- $chanstats{$chan}{'Deop'}++ if ($mode eq "o");
- $chanstats{$chan}{'Unban'}++ if ($mode eq "b");
- }
-
- # modes w/ target affecting nick => cache it.
- if ($mode =~ /[ov]/) {
- $channels{$chan}{$mode}{$target}++ if $parity;
- delete $channels{$chan}{$mode}{$target} if !$parity;
- }
-
- if ($mode =~ /[l]/) {
- $channels{$chan}{$mode} = $target if $parity;
- delete $channels{$chan}{$mode} if !$parity;
- }
- }
-
- # important channel modes, targetless.
- if ($mode =~ /[mt]/) {
- $channels{$chan}{$mode}++ if $parity;
- delete $channels{$chan}{$mode} if !$parity;
- }
- }
-}
-
-sub hookMsg {
- ($msgType, $chan, $who, $message) = @_;
- my $skipmessage = 0;
- $addressed = 0;
- $addressedother = 0;
- $orig{message} = $message;
- $orig{who} = $who;
- $addrchar = 0;
-
- $message =~ s/[\cA-\c_]//ig; # strip control characters
- $message =~ s/^\s+//; # initial whitespaces.
- $who =~ tr/A-Z/a-z/; # lowercase.
-
- &showProc();
-
- # addressing.
- if ($msgType =~ /private/) {
- # private messages.
- $addressed = 1;
- } else {
- # public messages.
- # addressing revamped by the xk.
- ### below needs to be fixed...
- if (&IsParam("addressCharacter")) {
- if ($message =~ s/^$param{'addressCharacter'}//) {
- $addrchar = 1;
- $addressed = 1;
- }
- }
-
- if ($message =~ /^($mask{nick})([\;\:\>\, ]+) */) {
- my $newmessage = $';
- if ($1 =~ /^\Q$ident\E$/i) {
- $message = $newmessage;
- $addressed = 1;
- } else {
- # ignore messages addressed to other people or unaddressed.
- $skipmessage++ if ($2 ne "" and $2 !~ /^ /);
- }
- }
- }
-
- # Determine floodwho.
- if ($msgType =~ /public/i) { # public.
- $floodwho = lc $chan;
- } elsif ($msgType =~ /private/i) { # private.
- $floodwho = lc $who;
- } else { # dcc?
- &DEBUG("FIXME: floodwho = ???");
- }
-
- my ($count, $interval) = split(/:/, $param{'floodRepeat'} || "2:10");
-
- # flood repeat protection.
- if ($addressed) {
- my $time = $flood{$floodwho}{$message};
-
- if (defined $time and (time - $time < $interval)) {
- ### public != personal who so the below is kind of pointless.
- my @who;
- foreach (keys %flood) {
- next if (/^\Q$floodwho\E$/ or /^\Q$chan\E$/);
- push(@who, grep /^\Q$message\E$/i, keys %{$flood{$_}});
- }
- if (scalar @who) {
- &msg($who, "you already said what ".
- join(' ', @who)." have said.");
- } else {
- &msg($who,"Someone already said that ". (time - $time) ." seconds ago" );
- }
-
- ### TODO: delete old floodwarn{} keys.
- my $floodwarn = 0;
- if (!exists $floodwarn{$floodwho}) {
- $floodwarn++;
- } else {
- $floodwarn++ if (time() - $floodwarn{$floodwho} > $interval);
- }
-
- if ($floodwarn) {
- &status("FLOOD repetition detected from $floodwho.");
- $floodwarn{$floodwho} = time();
- }
-
- return;
- }
-
- if ($addrchar) {
- &status("$b_cyan$who$ob is short-addressing me");
- } else {
- &status("$b_cyan$who$ob is addressing me");
- }
-
- $flood{$floodwho}{$message} = time();
- }
-
- ($count, $interval) = split(/:/, $param{'floodMessages'} || "5:30");
- # flood overflow protection.
- if ($addressed) {
- foreach (keys %{$flood{$floodwho}}) {
- next unless (time() - $flood{$floodwho}{$_} > $interval);
- delete $flood{$floodwho}{$_};
- }