#
use strict;
+no strict 'refs';
use vars qw(%floodjoin %nuh %dcc %cache %channels %param %mask
%chanconf %orig %ircPort %ircstats %last %netsplit);
return;
}
- if ($msgType =~ /chat/i) {
- # todo: warn that we're using msg() to do DCC CHAT?
- &dccsay($nick, $msg);
- # todo: make dccsay deal with flood protection?
- return;
- }
-
&status(">$nick< $msg");
- if (&whatInterface() =~ /IRC/) {
- my $t = time();
+ return unless (&whatInterface() =~ /IRC/);
+ my $t = time();
- if ($t == $msgtime) {
- $msgcount++;
- $msgsize += length $msg;
-
- my $i = &getChanConfDefault("sendPrivateLimitLines", 3);
- my $j = &getChanConfDefault("sendPrivateLimitBytes", 1000);
- if ( ($msgcount % $i) == 0 and $msgcount) {
- sleep 1;
- } elsif ($msgsize > $j) {
- sleep 1;
- $msgsize -= $j;
- }
+ if ($t == $msgtime) {
+ $msgcount++;
+ $msgsize += length $msg;
- } else {
- $msgcount = 0;
- $msgtime = $t;
- $msgsize = length $msg;
+ my $i = &getChanConfDefault("sendPrivateLimitLines", 3);
+ my $j = &getChanConfDefault("sendPrivateLimitBytes", 1000);
+ if ( ($msgcount % $i) == 0 and $msgcount) {
+ sleep 1;
+ } elsif ($msgsize > $j) {
+ sleep 1;
+ $msgsize -= $j;
}
- $conn->privmsg($nick, $msg);
+ } else {
+ $msgcount = 0;
+ $msgtime = $t;
+ $msgsize = length $msg;
}
+
+ $conn->privmsg($nick, $msg);
}
# Usage: &action(nick || chan, txt);
# Usage: &performReply($reply);
sub performReply {
my ($reply) = @_;
+
+ if (!defined $reply or $reply =~ /^\s*$/) {
+ &DEBUG("performReply: reply == NULL.");
+ return;
+ }
+
$reply =~ /([\.\?\s]+)$/;
&checkMsgType($reply);
$reply = "$reply, ".$orig{who};
}
&say($reply);
+
} elsif ($msgType eq 'private') {
- if (rand() < 0.5) {
- $reply = $reply;
- } else {
+ if (rand() > 0.5) {
$reply = "$reply, ".$orig{who};
}
&msg($who, $reply);
+
} elsif ($msgType eq 'chat') {
if (!exists $dcc{'CHAT'}{$who}) {
&VERB("pSR: dcc{'CHAT'}{$who} does not exist.",2);
return;
}
$conn->privmsg($dcc{'CHAT'}{$who}, $reply);
+
} else {
&ERROR("PR: msgType invalid? ($msgType).");
}
if (defined $ident and $nick eq $ident) {
&WARN("nick: nick == ident == '$ident'.");
+ return;
}
my $bad = 0;
}
if ($nick =~ /^$mask{nick}$/) {
- rawout("NICK ".$nick);
+ &rawout("NICK ".$nick);
if (defined $ident) {
&status("nick: Changing nick to $nick (from $ident)");
$chan =~ tr/A-Z/a-z/; # not lowercase unfortunately.
+ if ($chan =~ /^$/) {
+ &DEBUG("INIC: chan == NULL.");
+ return 0;
+ }
+
if (&validChan($chan) == 0) {
&ERROR("INIC: invalid channel $chan.");
return 0;
}
sub clearIRCVars {
- &DEBUG("clearIRCVars() called!");
undef %channels;
undef %floodjoin;
my $time;
foreach (keys %{ $floodjoin{$c} }) {
- $time += $floodjoin{$c}{$_}{Time};
+ my $t = $floodjoin{$c}{$_}{Time};
+ next unless (defined $t);
+
+ $time += $t;
}
&DEBUG("joinflood: time => $time");
$time /= $count;