#
use strict;
+no strict 'refs';
use vars qw(%floodjoin %nuh %dcc %cache %channels %param %mask
%chanconf %orig %ircPort %ircstats %last %netsplit);
use vars qw($b_blue $ob);
use vars qw(@joinchan @ircServers);
-# static scalar variables.
-$mask{ip} = '(\d+)\.(\d+)\.(\d+)\.(\d+)';
-$mask{host} = '[\d\w\_\-\/]+\.[\.\d\w\_\-\/]+';
-$mask{chan} = '[\#\&]\S*|_default';
-my $isnick1 = 'a-zA-Z\[\]\{\}\_\`\^\|\\\\';
-my $isnick2 = '0-9\-';
-$mask{nick} = "[$isnick1]{1}[$isnick1$isnick2]*";
-$mask{nuh} = '\S*!\S*\@\S*';
-
$nickserv = 0;
sub ircloop {
$conn = $irc->newconn(%args);
if (!defined $conn) {
- &ERROR("internal: perl IRC connection object does not exist.");
+ &ERROR("IRC: connection failed.");
+ &ERROR("add \"set ircHost 0.0.0.0\" to your config. If that does not work");
+ &ERROR("Please check /etc/hosts to see if you have a localhost line like:");
+ &ERROR("127.0.0.1 localhost localhost");
+ &ERROR("If this is still a problem, please contact the maintainer.");
return 1;
}
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;
+ 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;
- }
-
- } 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 ($bad) {
&WARN("Nick: not going to try and get my nick back. [".
- scalar(localtime). "]");
+ scalar(gmtime). "]");
# hrm... over time we lose track of our own nick.
# return;
}
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;
foreach $type (keys %dcc) {
next if ($type ne uc($type));
-
+
my $nick;
foreach $nick (keys %{ $dcc{$type} }) {
next unless (defined $nick);
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;