]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Process.pl
ignore long unparseable messages.
[infobot.git] / src / Process.pl
index 699e00debdfaac3f6af9263b1def94422118e888..fde372c07dc85b0438ca12e28579ec5c2c85c077 100644 (file)
@@ -1,4 +1,7 @@
-# infobot :: Kevin Lenzo 1997-1999
+###
+### Process.pl: Kevin Lenzo 1997-1999
+###
+
 #
 # process the incoming message
 #
@@ -95,21 +98,12 @@ sub process {
     }
 
     # User Processing, for all users.
-    return 'NOREPLY from userC' if &userCommands() eq 'NOREPLY';
+    return '$noreply from userC' if &userCommands() eq $noreply;
 
     ###
     # once useless messages have been parsed out, we match them.
     ###
 
-    # addressed.
-    if ($message =~ /^\Q$ident\E\s*\?*$/i) {
-       &status("feedback addressing from $who");
-
-       &performReply("yes?");
-
-       return;
-    }
-
     # confused? is this for infobot communications?
     foreach (keys %{$lang{'confused'}}) {
        my $y = $_;
@@ -213,9 +207,13 @@ sub process {
     # here's where the external routines get called.
     # if they return anything but null, that's the "answer".
     if ($addressed) {
+       if (&parseCmdHook()) {
+           return 'DID SOMETHING IN PCH.';
+       }
+
        my $er = &Modules();
        if ($er =~ /\S/) {
-           &performStrictReply($er) if ($er ne 'NOREPLY');
+           &performStrictReply($er) if ($er ne $noreply);
            return 'SOMETHING 1';
        }
 
@@ -243,8 +241,8 @@ sub FactoidStuff {
     # inter-infobot.
     if ($msgType =~ /private/ and $message =~ s/^:INFOBOT://) {
        ### identification.
-       &status("infobot <$nuh> identified") unless $infobots{$nuh};
-       $infobots{$nuh} = $who;
+       &status("infobot <$nuh> identified") unless $bots{$nuh};
+       $bots{$nuh} = $who;
 
        ### communication.
 
@@ -305,8 +303,17 @@ sub FactoidStuff {
 
            return 'locked factoid' if (&IsLocked($faqtoid) == 1);
 
-           &status("forget: <$who> '$faqtoid' =is=> '$result'");
-           &delFactoid($faqtoid);
+           if (&IsParam("factoidDeleteDelay")) {
+               &status("forgot (safe delete): <$who> '$faqtoid' =is=> '$result'");
+               &setFactInfo($faqtoid, "factoid_key", $faqtoid." #DEL#");
+
+               ### delete info. modified_ isn't really used.
+               &setFactInfo($faqtoid, "modified_by", $who);
+               &setFactInfo($faqtoid, "modified_time", time());
+           } else {
+               &status("forget: <$who> '$faqtoid' =is=> '$result'");
+               &delFactoid($faqtoid);
+           }
 
            &performReply("i forgot $faqtoid");
 
@@ -318,6 +325,48 @@ sub FactoidStuff {
        return;
     }
 
+    # factoid unforget/undelete.
+    if ($message =~ s/^un(forget|delete)\s+//i) {
+       return 'unforget: no addr' unless ($addressed);
+
+       if (!&IsParam("factoidDeleteDelay")) {
+           &performReply("safe delete has been disable so what is there to undelete?");
+           return;
+       }
+
+       my $faqtoid = $message;
+       if ($faqtoid eq "") {
+           &help("undelete");
+           return;
+       }
+
+       $faqtoid =~ tr/A-Z/a-z/;
+       my $result = &getFactoid($faqtoid." #DEL#");
+       my $check  = &getFactoid($faqtoid);
+
+       if (!defined $result) {
+           &performReply("i didn't have anything ('$faqtoid') to undelete.");
+           return;
+       }
+
+       if (defined $check) {
+           &performReply("cannot undeleted '$faqtoid' because it already exists?");
+           return;
+       }
+
+       &setFactInfo($faqtoid." #DEL#", "factoid_key", $faqtoid);
+
+       ### delete info. modified_ isn't really used.
+       &setFactInfo($faqtoid, "modified_by",  "");
+       &setFactInfo($faqtoid, "modified_time", 0);
+
+       &performReply("Successfully recovered '$faqtoid'.  Have fun now.");
+
+       $count{'Undelete'}++;
+
+       return;
+    }
+
     # factoid locking.
     if ($message =~ /^((un)?lock)(\s+(.*))?\s*?$/i) {
        return 'lock: no addr 2' unless ($addressed);
@@ -368,7 +417,7 @@ sub FactoidStuff {
                my $author = &getFactInfo($from, "created_by");
                if (&IsFlag("m") and $author =~ /^\Q$who\E\!/i) {
                    &msg($who, "It's not yours to modify.");
-                   return 'NOREPLY';
+                   return $noreply;
                }
 
                if ($_ = &getFactoid($to)) {
@@ -460,7 +509,7 @@ sub FactoidStuff {
 
     my $result = &doQuestion($message);
 
-    return 'result is NOREPLY' if ($result eq 'NOREPLY');
+    return 'result is $noreply' if ($result eq $noreply);
 
     if (defined $result and $result ne "") {           # question.
        &status("question: <$who> $message");
@@ -490,8 +539,13 @@ sub FactoidStuff {
        }
 
        if ($addressed) {
-           &status("unparseable: $message");
-           &performReply( &getRandom(keys %{$lang{'dunno'}}) );
+           if (length $message < 64) {
+               &status("unparseable: $message");
+               &performReply( &getRandom(keys %{$lang{'dunno'}}) );
+           } else {
+               &status("unparse-ignore: $message");
+           }
+               
            $count{'Dunno'}++;
        }
     }