]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/IrcHooks.pl
fix unsetting autojoin when trying to join invite-only channel
[infobot.git] / src / IRC / IrcHooks.pl
index af96470589624f5854bdf4d98501566ae5a73045..bcb6fcabe9146d4da5f50e0cae074ebc49b667fd 100644 (file)
@@ -150,7 +150,7 @@ sub on_ison {
     &DEBUG("on_ison: x1 = '$x1', x2 => '$x2'");
 }
 
-sub on_endofmotd {
+sub on_connected {
     $conn = shift(@_);
 
     # update IRCStats.
@@ -170,12 +170,9 @@ sub on_endofmotd {
 
     if ( scalar keys %users < 2 ) {
         &status( '!' x 40 );
-        &status(
-"!!! Ok.  Now type '/msg $ident PASS <pass>' to get master access through DCC CHAT."
-        );
+        &status("!!! Ok.  Now type '/msg $ident PASS <pass>' to get master access through DCC CHAT.");
         &status( '!' x 40 );
     }
-
     # end of first time run.
 
     if ( &IsChanConf('Wingate') > 0 ) {
@@ -213,12 +210,10 @@ sub on_endofmotd {
     # Q, as on quakenet.org.
     if ( &IsParam('Q_pass') ) {
         &status('Authing to Q...');
-        &rawout(
-"PRIVMSG Q\@CServe.quakenet.org :AUTH $param{'Q_user'} $param{'Q_pass'}"
-        );
+        &rawout("PRIVMSG Q\@CServe.quakenet.org :AUTH $param{'Q_user'} $param{'Q_pass'}");
     }
 
-    &status('End of motd. Now lets join some channels...');
+    &status("$ident End of motd. Now lets join some channels...");
 
     #&joinNextChan();
 }
@@ -468,8 +463,10 @@ sub on_endofnames {
 
     &chanServCheck($chan);
 
+    # FIXME: scheduler is b0rken! flood join for now
     # schedule used to solve ircu (OPN) 'target too fast' problems.
-    $conn->schedule( 5, sub { &joinNextChan(); } );
+    #$conn->schedule( 5, sub { &joinNextChan(); } );
+    &joinNextChan();
 }
 
 sub on_init {
@@ -625,7 +622,8 @@ sub on_join {
     ### ROOTWARN:
     &rootWarn( $who, $user, $host, $chan )
       if ( &IsChanConf('RootWarn') > 0
-        && $user =~ /^~?r(oo|ew|00)t$/i );
+        && $user eq 'root' );
+        #&& $user =~ /^~?r(oo|ew|00)t$/i );
 
     ### emit a message based on who just joined
     &onjoin( $who, $user, $host, $chan ) if ( &IsChanConf('OnJoin') > 0 );
@@ -816,24 +814,25 @@ sub on_notice {
     my $nick    = $event->nick();
     my $chan    = ( $event->to )[0];
     my $args    = ( $event->args )[0];
+    my $mynick  = $conn->nick();
 
     if ( $nick =~ /^NickServ$/i ) {    # nickserv.
-        &status("NickServ: <== '$args'");
+        &status("NickServ: $mynick <== '$args'");
 
         my $check = 0;
         $check++ if ( $args =~ /^This nickname is registered/i );
         $check++ if ( $args =~ /nickname.*owned/i );
 
         if ($check) {
-            &status('nickserv told us to register; doing it.');
+            &status("nickserv told $mynick to register; doing it.");
 
             if ( &IsParam('nickServ_pass') ) {
-                &status('NickServ: ==> Identifying.');
+                &status("NickServ: ==> Identifying as $mynick.");
                 &rawout("PRIVMSG NickServ :IDENTIFY $param{'nickServ_pass'}");
                 return;
             }
             else {
-                &status("We can't tell nickserv a passwd ;(");
+                &status("$mynick can't tell nickserv a passwd ;(");
             }
         }
 
@@ -844,8 +843,7 @@ sub on_notice {
             foreach ( &ChanConfList('chanServ_ops') ) {
                 next unless &chanServCheck($_);
                 next if ($done);
-                &DEBUG(
-                    'nickserv activated or restarted; doing chanserv check.');
+                &DEBUG('nickserv activated or restarted; doing chanserv check.');
                 $done++;
             }
 
@@ -1092,7 +1090,7 @@ sub on_quit {
     # 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);
+        &nick($nick);
     }
 }
 
@@ -1201,11 +1199,17 @@ sub on_crversion {
     }
     push( @vernick, $nick );
 
+    &DEBUG("on_crversion: Got '$ver' from $nick");
+
     if ( $ver =~ /bitchx/i ) {
         $ver{bitchx}{$nick} = $ver;
 
     }
-    elsif ( $ver =~ /xc\!|xchat/i ) {
+    elsif ( $ver =~ /infobot/i ) {
+        $ver{infobot}{$nick} = $ver;
+
+    }
+    elsif ( $ver =~ /(xc\!|xchat)/i ) {
         $ver{xchat}{$nick} = $ver;
 
     }
@@ -1213,20 +1217,19 @@ sub on_crversion {
         $ver{irssi}{$nick} = $ver;
 
     }
-    elsif ( $ver =~ /epic|(Third Eye)/i ) {
+    elsif ( $ver =~ /(epic|Third Eye)/i ) {
         $ver{epic}{$nick} = $ver;
 
     }
-    elsif ( $ver =~ /ircII|PhoEniX/i ) {
+    elsif ( $ver =~ /(ircII|PhoEniX)/i ) {
         $ver{ircII}{$nick} = $ver;
 
     }
     elsif ( $ver =~ /mirc/i ) {
-
-        #      &DEBUG("verstats: mirc: $nick => '$ver'.");
+        # Apparently, mIRC gets the reply as "VERSION " and doesnt like the
+        # space, so mirc matching is considered bugged.
         $ver{mirc}{$nick} = $ver;
 
-        # ok... then we get to the lesser known/used clients.
     }
     elsif ( $ver =~ /ircle/i ) {
         $ver{ircle}{$nick} = $ver;
@@ -1327,8 +1330,8 @@ sub on_chanfull {
     my ($event) = @_;
     my @args = $event->args;
 
-    &status(">>> chanfull/$b_blue$args[1]$ob");
-
+    &status(">>> chanfull/$b_blue$args[1]$ob, removing autojoin");
+    delete $chanconf{$chan}{autojoin};
     &joinNextChan();
 }
 
@@ -1336,9 +1339,10 @@ sub on_inviteonly {
     $conn = shift(@_);
     my ($event) = @_;
     my @args = $event->args;
+    my $chan = $args[1];
 
-    &status(">>> inviteonly/$b_cyan$args[1]$ob");
-
+    &status(">>> inviteonly/$b_cyan$chan$ob, removing autojoin");
+    delete $chanconf{$chan}{autojoin};
     &joinNextChan();
 }