]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/IrcHooks.pl
really DCC
[infobot.git] / src / IRC / IrcHooks.pl
index a62e0ea3b42504b3abb0af97b3712cbc07891cb7..2153c52a3932e7fa75aa20025c19ce56da8ae5de 100644 (file)
@@ -4,6 +4,7 @@
 #     Version: 20000126
 #        NOTE: Based on code by Kevin Lenzo & Patrick Cole  (c) 1997
 #
+use vars qw(%chanconf);
 
 # GENERIC. TO COPY.
 sub on_generic {
@@ -114,7 +115,7 @@ sub on_chat {
 
     if ($message =~ s/^\.//) { # dcc chat commands.
        ### TODO: make use of &Forker(); here?
-       &loadMyModule( $myModules{'ircdcc'} );
+       &loadMyModule('UserDCC');
 
        &DCCBroadcast("#$who# $message","m");
 
@@ -159,7 +160,7 @@ sub on_endofmotd {
     # first time run.
     if (!exists $users{_default}) {
        &status("!!! First time run... adding _default user.");
-       $users{_default}{FLAGS} = "mrt";
+       $users{_default}{FLAGS} = "amrt";
        $users{_default}{HOSTS}{"*!*@*"} = 1;
     }
 
@@ -170,7 +171,7 @@ sub on_endofmotd {
     }
     # end of first time run.
 
-    if (&IsChanConf("wingate")) {
+    if (&IsChanConf('Wingate')) {
        my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
        open(IN, $file);
        while (<IN>) {
@@ -230,6 +231,8 @@ sub on_dcc {
     my $type = uc( ($event->args)[1] );
     my $nick = lc $event->nick();
 
+    &status("on_dcc type=$type nick=$nick sock=$sock");
+
     # pity Net::IRC doesn't store nuh. Here's a hack :)
     if (!exists $nuh{lc $nick}) {
        $conn->whois($nick);
@@ -240,12 +243,16 @@ sub on_dcc {
     if ($type eq 'SEND') {     # GET for us.
        # incoming DCC SEND. we're receiving a file.
        my $get = ($event->args)[2];
-       open(DCCGET,">$get");
-
-       $conn->new_get($event, \*DCCGET);
+       &status("DCC: not Initializing GET from $nick to '$param{tempDir}/$get'");
+       # FIXME: do we want to get anything?
+       return;
+       #open(DCCGET,">$param{tempDir}/$get");
+       #$conn->new_get($event, \*DCCGET);
 
     } elsif ($type eq 'GET') { # SEND for us?
-       &status("DCC: Initializing SEND for $nick.");
+       &status("DCC: not Initializing SEND for $nick.");
+       # FIXME: do we want to do anything?
+       return;
        $conn->new_send($event->args);
 
     } elsif ($type eq 'CHAT') {
@@ -273,7 +280,7 @@ sub on_dcc_close {
     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");
+       &status("dcc_close: purging DCC send $nick.txt");
        unlink "$param{tempDir}/$nick.txt";
 
        delete $dcc{'SEND'}{$nick};
@@ -293,6 +300,8 @@ sub on_dcc_open {
     my $nick = lc $event->nick();
     my $sock = ($event->to)[0];
 
+    &status("on_dcc_open type=$type nick=$nick sock=$sock");
+
     $msgType = 'chat';
     $type ||= "???";
     ### BUG: who is set to bot's nick?
@@ -312,9 +321,9 @@ sub on_dcc_open {
        }
 
     } elsif ($type eq 'SEND') {
-       &DEBUG("Starting DCC receive.");
+       &status("Starting DCC receive.");
        foreach ($event->args) {
-           &DEBUG("  => '$_'.");
+           &status("  => '$_'.");
        }
 
     } else {
@@ -337,7 +346,7 @@ sub on_dcc_open_chat {
     &verifyUser($nick, $nuh{lc $nick});
 
     if (!exists $users{$userHandle}{HOSTS}) {
-       &pSReply("you have no hosts defined in my user file; rejecting.");
+       &performStrictReply("you have no hosts defined in my user file; rejecting.");
        $sock->close();
        return;
     }
@@ -571,21 +580,21 @@ sub on_join {
 
     ### ROOTWARN:
     &rootWarn($who,$user,$host,$chan) if (
-               &IsChanConf("rootWarn") &&
+               &IsChanConf('RootWarn') &&
                $user =~ /^~?r(oo|ew|00)t$/i
     );
 
     ### NEWS:
-    if (&IsChanConf("news") && &IsChanConf("newsKeepRead")) {
-       if (!&loadMyModule("news")) {   # just in case.
-           &DEBUG("could not load news.");
+    if (&IsChanConf('News') && &IsChanConf('newsKeepRead')) {
+       if (!&loadMyModule('News')) {   # just in case.
+           &DEBUG('could not load news.');
        } else {
            &News::latest($chan);
        }
     }
 
     ### botmail:
-    if (&IsChanConf("botmail")) {
+    if (&IsChanConf('botmail')) {
        &botmail::check(lc $who);
     }
 
@@ -733,10 +742,10 @@ sub on_nick_taken {
     &status("nick taken ($nick); preparing nick change.");
 
     $conn->whois($nick);
-    $conn->schedule(5, sub {
+    #$conn->schedule(5, sub {
        &status("nick taken; changing to temporary nick ($nick -> $newnick).");
        &nick($newnick);
-    } );
+    #} );
 }
 
 sub on_notice {
@@ -861,7 +870,7 @@ sub on_ping_reply {
 sub on_public {
     $conn = shift(@_);
     my ($event) = @_;
-    my $msg    = ($event->args)[0];
+    my $msg    = ($event->args)[0];
     $chan      = lc( ($event->to)[0] );        # CASING.
     my $nick   = $event->nick;
     $who       = $nick;
@@ -977,9 +986,6 @@ sub on_quit {
 
     my $chans = join(' ', &getNickInChans($nick) );
     &status(">>> $b_cyan$nick$ob has signed off IRC $b_red($ob$reason$b_red)$ob [$chans]");
-    if ($nick =~ /^\Q$ident\E$/) {
-       &ERROR("^^^ THIS SHOULD NEVER HAPPEN (10).");
-    }
 
     ###
     ### ok... lets clear out the cache
@@ -995,12 +1001,12 @@ sub on_quit {
     delete $chanstats{lc $nick};
     ###
 
-    # FIXME: broken for multiple connects
-    #my $mynick = $conn->nick();
-    #if ($nick !~ /^\Q$ident\E$/ and $nick =~ /^\Q$mynick\E$/i) {
-       #&status("nickchange: own nickname became free; changing.");
-       #&nick($mynick);
-    #}
+    # if we have a temp nick, and whoever is camping on our main nick leaves
+    # revert to main nick. Note that Net::IRC only knows our main nick
+    if ($nick eq $conn->nick()) {
+       &status("nickchange: own nick \"$nick\" became free; changing.");
+       &nick($mynick);
+    }
 }
 
 sub on_targettoofast {
@@ -1060,7 +1066,7 @@ sub on_topic {
        &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic");
     } else {                                           # join.
        my ($nick, $chan, $topic) = $event->args;
-       if (&IsChanConf("topic")) {
+       if (&IsChanConf('Topic')) {
            $topic{$chan}{'Current'}    = $topic;
            &topicAddHistory($chan,$topic);
        }
@@ -1237,8 +1243,8 @@ sub on_banned {
     my @args   = $event->args;
     my $chan   = $args[1];
 
-    &status(">>> banned/$b_blue$chan$ob $b_cyan$args[0]$ob");
-    #FIXME if $args[0] == me then kill autojoin!
+    &status(">>> banned/$b_blue$chan$ob $b_cyan$args[0]$ob, removing autojoin for $chan");
+    delete $chanconf{$chan}{autojoin};
     &joinNextChan();
 }
 
@@ -1246,8 +1252,10 @@ sub on_badchankey {
     $conn = shift(@_);
     my ($event) = @_;
     my @args   = $event->args;
+    my $chan   = $args[1];
 
-    &DEBUG("on_badchankey: args => @args");
+    &DEBUG("on_badchankey: args => @args, removing autojoin for $chan");
+    delete $chanconf{$chan}{autojoin};
     &joinNextChan();
 }
 
@@ -1260,4 +1268,11 @@ sub on_useronchan {
     &joinNextChan();
 }
 
+# TODO not used yet
+sub on_stdin {
+    my $line = <STDIN>;
+    chomp($line);
+    &FIXME("on_stdin: line => \"$line\"");
+}
+
 1;