From c44537fa97a79142bce0975aa97eec0ef268dad2 Mon Sep 17 00:00:00 2001 From: timriker Date: Wed, 14 Jul 2004 18:56:14 +0000 Subject: [PATCH] channelFactoids -> factoidSearch git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1003 c11ca15a-4712-0410-83d8-924469b57eb5 --- TODO | 1 + src/Factoids/Reply.pl | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 322a1a7..e5bd1ff 100644 --- 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 diff --git a/src/Factoids/Reply.pl b/src/Factoids/Reply.pl index 780881b..36d0c11 100644 --- a/src/Factoids/Reply.pl +++ b/src/Factoids/Reply.pl @@ -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) { -- 2.39.5