]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/Factoids.pl
- Remaining files that were changed due to removal of $noreply or
[infobot.git] / src / Modules / Factoids.pl
index 5fe634bf783fac3e91a3ac8a23382d48ac397080..74992ee2a6ec4c5178ad0dbca5b236e9078a8d9c 100644 (file)
@@ -16,7 +16,7 @@ sub CmdFactInfo {
 
     if ($faqtoid eq "") {
        &help("factinfo");
-       return $noreply;
+       return;
     }
 
     my $i = 0;
@@ -30,7 +30,18 @@ sub CmdFactInfo {
     # factoid does not exist.
     if (scalar @factinfo <= 1) {
        &performReply("there's no such factoid as \002$faqtoid\002");
-       return $noreply;
+       return;
+    }
+
+    # fix for problem observed by asuffield.
+    # why did it happen though?
+    if (!$factinfo{'factoid_value'}) {
+       &performReply("there's no such factoid as \002$faqtoid\002; deleted because we don't have factoid_value!");
+       foreach (keys %factinfo) {
+           &DEBUG("factinfo{$_} => '$factinfo{$_}'.");
+       }
+###    &delFactoid($faqtoid);
+       return;
     }
 
     # created:
@@ -43,7 +54,7 @@ sub CmdFactInfo {
        my $time = $factinfo{'created_time'};
        if ($time) {
            if (time() - $time > 60*60*24*7) {
-               my $days = int( (time() - $time)*60*60*24 );
+               my $days = int( (time() - $time)/60/60/24 );
                $string .= " at \037". scalar(localtime $time). "\037" .
                                " ($days days) ";
            } else {
@@ -121,11 +132,11 @@ sub CmdFactInfo {
     # factoid was inserted not through the bot.
     if (!scalar @array) {
        &performReply("no extra info on \002$faqtoid\002");
-       return $noreply;
+       return;
     }
 
     &performStrictReply("$factinfo{'factoid_key'} -- ". join("; ", @array) .".");
-    return $noreply;
+    return;
 }
 
 sub CmdFactStats {
@@ -271,6 +282,27 @@ sub CmdFactStats {
        my $prefix = "dupe factoid ";
        return &formListReply(1, $prefix, @list);
 
+    } elsif ($type =~ /^nullfactoids$/i) {
+       my $query = "SELECT factoid_key,factoid_value FROM factoids WHERE factoid_value=''";
+       my $sth = $dbh->prepare($query);
+       &ERROR("factstats(null): => '$query'.") unless $sth->execute;
+
+       my @list;
+       while (my @row = $sth->fetchrow_array) {
+           if ($row[1] ne "") {
+               &DEBUG("row[1] != NULL for $row[0].");
+               next;
+           }
+
+           &DEBUG("row[0] => '$row[0]'.");
+           push(@list, $row[0]);
+       }
+       $sth->finish;
+
+       # parse the results.
+       my $prefix = "NULL factoids (not deleted yet) ";
+       return &formListReply(1, $prefix, @list);
+
     } elsif ($type =~ /^(2|too)short$/i) {
        # Custom select statement.
        my $query = "SELECT factoid_key,factoid_value FROM factoids WHERE length(factoid_value) <= 40";