]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Process.pl
final cruft from old static configuration file fixed... found by irq
[infobot.git] / src / Process.pl
index d699c234d06e387062a110a508ae09f226d024e4..93a3a32d25782417a8cf60d57bb1e79f138cac7c 100644 (file)
@@ -50,7 +50,7 @@ sub process {
 
        $2 =~ /^($mask{chan})(,(\S+))?/;
        my($thischan, $key) = (lc $1, $3);
-       my $chankey     = $thischan;
+       my $chankey     = lc $thischan;
        $chankey        .= " $key"      if (defined $key);
 
        if ($thischan eq "") {
@@ -58,18 +58,16 @@ sub process {
            return;
        }
 
-       # Thanks to Eden Li (tile) for the channel key patch
-       my @chans = split(/[\s\t]+/, $param{'join_channels'});
-       if (!grep /^$thischan$/i, @chans) {
-           if (&IsFlag("o") ne "o") {
+       if (&IsFlag("o") ne "o") {
+           if (!exists $chanconf{$thischan}) {
                &msg($who, "I am not allowed to join $thischan.");
                return;
            }
-       }
 
-       if (&validChan($thischan) and &IsFlag("o") ne "o") {
-           &msg($who,"I'm already on $thischan...");
-           return;
+           if (&validChan($thischan)) {
+               &msg($who,"I'm already on $thischan...");
+               return;
+           }
        }
        $joinverb{$thischan} = $who;    # used for on_join self.
 
@@ -80,33 +78,6 @@ sub process {
        return;
     }
 
-    # allowOutsiders.
-    if (&IsParam("disallowOutsiders") and $msgType =~ /private/i) {
-       my $found = 0;
-
-       foreach (keys %channels) {
-           next unless (&IsNickInChan($who,$_));
-
-           $found++;
-           last;
-       }
-
-       if (!$found and scalar(keys %channels)) {
-           &status("OUTSIDER <$who> $message");
-           return 'OUTSIDER';
-       }
-    }
-
-    # User Processing, for all users.
-    if ($addressed) {
-       my $retval;
-       return 'returned from pCH'   if &parseCmdHook("main",$message);
-
-       $retval = &userCommands();
-       return unless (defined $retval);
-       return if ($retval eq $noreply);
-    }
-
     # 'identify'
     if ($msgType =~ /private/ and $message =~ s/^identify//) {
        $message =~ s/^\s+|\s+$//g;
@@ -135,7 +106,7 @@ sub process {
            return;
        }
 
-       if (!&ckpass($array[0], $crypt)) {
+       if (!&ckpasswd($array[0], $crypt)) {
            &pSReply("invalid passwd for $do_nick.");
            return;
        }
@@ -149,6 +120,33 @@ sub process {
        return;
     }
 
+    # allowOutsiders.
+    if (&IsParam("disallowOutsiders") and $msgType =~ /private/i) {
+       my $found = 0;
+
+       foreach (keys %channels) {
+           next unless (&IsNickInChan($who,$_));
+
+           $found++;
+           last;
+       }
+
+       if (!$found and scalar(keys %channels)) {
+           &status("OUTSIDER <$who> $message");
+           return 'OUTSIDER';
+       }
+    }
+
+    # User Processing, for all users.
+    if ($addressed) {
+       my $retval;
+       return 'returned from pCH'   if &parseCmdHook("main",$message);
+
+       $retval = &userCommands();
+       return unless (defined $retval);
+       return if ($retval eq $noreply);
+    }
+
     ###
     # once useless messages have been parsed out, we match them.
     ###
@@ -205,7 +203,6 @@ sub process {
 
     # thanks.
     if ($message =~ /^than(ks?|x)( you)?( \S+)?/i) {
-       &DEBUG("thanks: talkok => '$talkok', addressed => '$addressed'.");
        return 'thank: no addr' unless ($message =~ /$ident/ or $talkok);
 
        &performReply( &getRandom(keys %{$lang{'welcome'}}) );
@@ -560,7 +557,7 @@ sub FactoidStuff {
        return 'result from doQ undef.';
     }
 
-    if (defined $result and $result ne "") {           # question.
+    if (defined $result and $result !~ /^0?$/) {       # question.
        &status("question: <$who> $message");
        $count{'Question'}++;
     } elsif (&IsChanConf("perlMath") > 0 and $addressed) { # perl math.
@@ -573,33 +570,33 @@ sub FactoidStuff {
        }
     }
 
-    if ($result ne "") {
+    if ($result !~ /^0?$/) {
        &performStrictReply($result);
        return;
-    } else {
-       # why would a friendly bot get passed here?
-       if (&IsParam("friendlyBots")) {
-           return if (grep lc($_) eq lc($who), split(/\s+/, $param{'friendlyBots'}));
-       }
+    }
 
-       # do the statement.
-       if (defined &doStatement($message)) {
-           return;
-       }
+    # why would a friendly bot get passed here?
+    if (&IsParam("friendlyBots")) {
+       return if (grep lc($_) eq lc($who), split(/\s+/, $param{'friendlyBots'}));
+    }
 
-       return unless ($addressed);
+    # do the statement.
+    if (!defined &doStatement($message)) {
+       return;
+    }
 
-       if (length $message > 64) {
-           &status("unparseable-moron: $message");
-           &performReply( &getRandom(keys %{$lang{'moron'}}) );
-           $count{'Moron'}++;
-           return;
-       }
+    return unless ($addressed);
 
-       &status("unparseable: $message");
-       &performReply( &getRandom(keys %{$lang{'dunno'}}) );
-       $count{'Dunno'}++;
+    if (length $message > 64) {
+       &status("unparseable-moron: $message");
+       &performReply( &getRandom(keys %{$lang{'moron'}}) );
+       $count{'Moron'}++;
+       return;
     }
+
+    &status("unparseable: $message");
+    &performReply( &getRandom(keys %{$lang{'dunno'}}) );
+    $count{'Dunno'}++;
 }
 
 1;