]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/Irc.pl
ws
[infobot.git] / src / IRC / Irc.pl
index a82aa7f9c2be09ac1a2a6128b2b57920a323d510..ad557ae6cc9dd8ec75037aedc794193fada20894 100644 (file)
@@ -17,15 +17,6 @@ use vars qw($notcount $nottime $notsize $msgcount $msgtime $msgsize
 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 {
@@ -111,7 +102,11 @@ sub irc {
     $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;
     }
 
@@ -244,39 +239,31 @@ sub msg {
        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);
@@ -838,7 +825,7 @@ sub closeDCC {
 
     foreach $type (keys %dcc) {
        next if ($type ne uc($type));
+
        my $nick;
        foreach $nick (keys %{ $dcc{$type} }) {
            next unless (defined $nick);