From: timriker Date: Fri, 9 Jul 2004 21:14:15 +0000 (+0000) Subject: #channelname factoid overrides factoid in a channel X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=353c46254e3de7e680a9dfd6e051a9501d41caac;p=infobot.git #channelname factoid overrides factoid in a channel git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@997 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/src/Factoids/Reply.pl b/src/Factoids/Reply.pl index 4c8a44d..780881b 100644 --- a/src/Factoids/Reply.pl +++ b/src/Factoids/Reply.pl @@ -29,17 +29,34 @@ sub getReply { $message =~ tr/A-Z/a-z/; $message =~ s/^cmd:/CMD:/; - my ($count, $fauthor, $result) = &sqlSelect("factoids", - "requested_count,created_by,factoid_value", - { factoid_key => $message } - ); + 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 ($result) { + # got channel specific reply above + $factoid="$chan $message" + } else { + # no channel specific factoid was requested / found + ($count, $fauthor, $result) = &sqlSelect("factoids", + "requested_count,created_by,factoid_value", + { factoid_key => $message } + ); + $factoid=$message if ($result); + } if ($result) { $lhs = $message; $mhs = "is"; $rhs = $result; - return "$lhs $mhs $rhs" if ($literal); + return "\"$factoid\" $mhs \"$rhs\"" if ($literal); } else { return ''; } @@ -65,7 +82,7 @@ sub getReply { ### FIXME: old mysql doesn't support ### "requested_count=requested_count+1". $count++; - &sqlSet("factoids", {'factoid_key' => $lhs}, { + &sqlSet("factoids", {'factoid_key' => $factoid}, { requested_by => $nuh, requested_time => time(), requested_count => $count