]> git.donarmstrong.com Git - infobot.git/commitdiff
channelFactoids -> factoidSearch
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 14 Jul 2004 18:56:14 +0000 (18:56 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 14 Jul 2004 18:56:14 +0000 (18:56 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1003 c11ca15a-4712-0410-83d8-924469b57eb5

TODO
src/Factoids/Reply.pl

diff --git a/TODO b/TODO
index 322a1a76a971d5146cb6f8c0ac76281c48dbbc03..e5bd1ff52b99f43bed04ba7147de823292a62543 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,7 @@
 DONE:
        - add handling for channel specific factoids:
          "#botpark logs" -> http://ibot.rikers.org/botpark
+         factoidSearch is a space delimited list of prefixes to try
 TODO:
        - let's get a release out!
        - kill SHM and and move to a pipe
index 780881b9edea806ddb99e94d51571bc25e5e88c4..36d0c11da3cf95e5fa3ba8e13e9413ceeba9a40c 100644 (file)
@@ -18,7 +18,7 @@ use vars qw(%lang %lastWho);
 sub getReply {
     my($message) = @_;
     my($lhs,$mhs,$rhs);
-    my($reply);
+    my($reply, $count, $fauthor, $result, $factoid, $search, @searches);
     $orig{message} = $message;
 
     if (!defined $message or $message =~ /^\s*$/) {
@@ -29,26 +29,24 @@ sub getReply {
     $message =~ tr/A-Z/a-z/;
     $message =~ s/^cmd:/CMD:/;
 
-    my ($count, $fauthor, $result, $factoid);
-
-    if (!$literal and &IsChanConf("channelFactoids")) {
-       # check for factoids specific to this channel
-       ($count, $fauthor, $result) = &sqlSelect("factoids",
-           "requested_count,created_by,factoid_value",
-           { factoid_key => "$chan $message" }
-       );
+    if (!$literal and &IsChanConf("factoidSearch")) {
+       @searches = split(/\s+/, &getChanConf("factoidSearch"));
+    } else {
+       @searches = ('_default');
     }
 
-    if ($result) {
-       # got channel specific reply above
-       $factoid="$chan $message"
-    } else {
-       # no channel specific factoid was requested / found
+    # check for factoids with each prefix
+    foreach $search (@searches) {
+       if ($search eq '_default') {
+           $factoid = $message;
+       } else {
+           $factoid = "$search $message";
+       }
        ($count, $fauthor, $result) = &sqlSelect("factoids",
            "requested_count,created_by,factoid_value",
-           { factoid_key => $message }
+           { factoid_key => $factoid }
        );
-       $factoid=$message if ($result);
+       last if ($result);
     }
 
     if ($result) {