]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/IrcHooks.pl
- add 'days' to created_time output.
[infobot.git] / src / IRC / IrcHooks.pl
index 7f0b811517f1a5b6c6767cb4ed90803fc686eb73..8be2723da9f2dfe39238a57a771a6027229afaa3 100644 (file)
@@ -58,8 +58,8 @@ sub on_chat {
        $msgType        = 'chat';
     }
 
-    if (!exists $dcc{'CHAT'}{$nick}) {
-       my $userHandle  = &verifyUser($who, $nuh);
+    if (!exists $dcc{'CHATvrfy'}{$nick}) {
+       $userHandle     = &verifyUser($who, $nuh);
        my $crypto      = $userList{$userHandle}{'pass'};
        my $success     = 0;
 
@@ -77,21 +77,24 @@ sub on_chat {
        } else {
            &status("DCC CHAT: incorrect pass; closing connection.");
            &DEBUG("chat: sock => '$sock'.");
-###        $sock->close();
+           $sock->close();
+           delete $dcc{'CHAT'}{$nick};
            &DEBUG("chat: after closing sock. FIXME");
            ### BUG: close seizes bot. why?
        }
 
        if ($success) {
            &status("DCC CHAT: user $nick is here!");
-           $dcc{'CHAT'}{$nick} = $sock;
            &DCCBroadcast("$nick ($uh) has joined the chat arena.");
+           $dcc{'CHATvrfy'}{$nick} = 1;
+           if ($userHandle ne "default") {
+               &dccsay($nick,"Flags: $userList{$userHandle}{'flags'}");
+           }
        }
 
        return;
     }
 
-
     $userHandle = &verifyUser($who, $nuh);
     &status("$b_red=$b_cyan$who$b_red=$ob $message");
     if ($message =~ s/^\.//) { # dcc chat commands.
@@ -112,6 +115,12 @@ sub on_chat {
 sub on_endofmotd {
     my ($self) = @_;
 
+    # what's the following for?
+    $ident                     = $param{'ircNick'};
+    # update IRCStats.
+    $ircstats{'ConnectTime'}   = time();
+    $ircstats{'ConnectCount'}++;
+
     if (&IsParam("wingate")) {
        my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
        open(IN, $file);
@@ -124,7 +133,6 @@ sub on_endofmotd {
     }
 
     if ($firsttime) {
-       &DEBUG("on_EOM: calling sS in 60s.");
        $conn->schedule(60, \&setupSchedulers, "");
        $firsttime = 0;
     }
@@ -150,6 +158,7 @@ sub on_dcc {
 
     # pity Net::IRC doesn't store nuh. Here's a hack :)
     $self->whois($nick);
+    $type ||= "???";
 
     if ($type eq 'SEND') {     # GET for us.
        # incoming DCC SEND. we're receiving a file.
@@ -170,7 +179,7 @@ sub on_dcc {
        &DEBUG("starting chat.");
        $self->new_chat($event);
     } else {
-       &status("${b_green}DCC $type$ob unknown ...");
+       &WARN("${b_green}DCC $type$ob (1)");
     }
 }
 
@@ -184,18 +193,18 @@ sub on_dcc_close {
 
     &DEBUG("dcc_close: nick => '$nick'.");
 
-    if (exists $dcc{'SEND'}{$nick} and -f "temp/$nick.txt") {
+    if (exists $dcc{'SEND'}{$nick} and -f "$param{tempDir}/$nick.txt") {
        &status("${b_green}DCC SEND$ob close from $b_cyan$nick$ob");
 
        &status("dcc_close: purging $nick.txt from Debian.pl");
-       unlink "temp/$nick.txt";
+       unlink "$param{tempDir}/$nick.txt";
 
        delete $dcc{'SEND'}{$nick};
     } elsif (exists $dcc{'CHAT'}{$nick} and $dcc{'CHAT'}{$nick} eq $sock) {
        &status("${b_green}DCC CHAT$ob close from $b_cyan$nick$ob");
        delete $dcc{'CHAT'}{$nick};
     } else {
-       &status("${b_green}DCC$ob UNKNOWN close from $b_cyan$nick$ob");
+       &status("${b_green}DCC$ob UNKNOWN close from $b_cyan$nick$ob (2)");
     }
 }
 
@@ -206,16 +215,20 @@ sub on_dcc_open {
     my $sock = ($event->to)[0];
     $msgType = 'chat';
 
+    $type ||= "???";
+
     if ($type eq 'SEND') {
        &status("${b_green}DCC lGET$ob established with $b_cyan$nick$ob");
     } elsif ($type eq 'CHAT') {
-       &status("${b_green}DCC CHAT$ob established with $b_cyan$nick$ob ($nuh{$nick})");
-       my $userHandle  = &verifyUser($nick, $nuh{lc $nick});
+       &status("${b_green}DCC CHAT$ob established with $b_cyan$nick$ob $b_yellow($ob$nuh{$nick}$b_yellow)$ob");
+       $userHandle     = &verifyUser($nick, $nuh{lc $nick});
        my $crypto      = $userList{$userHandle}{'pass'};
+       $dcc{'CHAT'}{$nick} = $sock;
+
        if (defined $crypto) {
-           $self->privmsg($sock,"Enter Password, $userHandle.");
+           &dccsay($nick,"Enter Password, $userHandle.");
        } else {
-           $self->privmsg($sock,"Welcome to blootbot DCC CHAT interface, $userHandle.");
+           &dccsay($nick,"Welcome to blootbot DCC CHAT interface, $userHandle.");
        }
     } elsif ($type eq 'SEND') {
        &DEBUG("Starting DCC receive.");
@@ -223,7 +236,7 @@ sub on_dcc_open {
            &DEBUG("  => '$_'.");
        }
     } else {
-       &status("${b_green}DCC $type$ob unknown ...");
+       &WARN("${b_green}DCC $type$ob (3)");
     }
 }
 
@@ -342,6 +355,8 @@ sub on_join {
     $chanstats{$chan}{'Join'}++;
     $userstats{lc $who}{'Join'} = time() if (&IsParam("seenStats"));
 
+    &joinfloodCheck($who, $chan, $event->userhost);
+
     # netjoin detection.
     my $netsplit = 0;
     if (exists $netsplit{lc $who}) {
@@ -349,6 +364,16 @@ sub on_join {
        $netsplit = 1;
     }
 
+    if ($netsplit and !$netsplittime) {
+       &status("ok.... re-running chanlimitCheck in 60.");
+       $conn->schedule(60, sub {
+               &chanlimitCheck();
+               $netsplittime = undef;
+       } );
+
+       $netsplittime = time();
+    }
+
     # how to tell if there's a netjoin???
 
     my $netsplitstr = "";
@@ -390,6 +415,7 @@ sub on_kick {
 
     &status(">>> kick/$b_blue$chan$ob [$b$kickee!$uh$ob] by $b_cyan$kicker$ob $b_yellow($ob$reason$b_yellow)$ob");
 
+    $chan = lc $chan;  # forgot about this, found by xsdg, 20001229.
     $chanstats{$chan}{'Kick'}++;
 
     if ($kickee eq $ident) {
@@ -544,6 +570,12 @@ sub on_part {
     my $nick = $event->nick;
     my $userhost = $event->userhost;
 
+    if (!exists $floodjoin{$chan}{$nick}{Time}) {
+       &WARN("on_part: $nick/$chan not in floodjoin hash?");
+    } else {
+       delete $floodjoin{$chan}{$nick};
+    }
+
     $chanstats{$chan}{'Part'}++;
     &DeleteUserInfo($nick,$chan);
     &clearChanVars($chan) if ($nick eq $ident);