From ab817c7c909abba1654f3b8691961ec8694e8169 Mon Sep 17 00:00:00 2001 From: djmcgrath Date: Sat, 10 May 2008 08:53:31 +0000 Subject: [PATCH] * New maxVolunteerLength to govern max size of non addressed replies * Cleaned up some of the regex code for what the bot considers a question * Fixed an obscure and undocumented variable that was disabling "query?" questions in non addressed mode git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@1817 c11ca15a-4712-0410-83d8-924469b57eb5 --- ChangeLog | 10 ++++++++++ files/sample/infobot.chan | 3 ++- src/Factoids/Core.pl | 16 +++++++++------- src/Factoids/Question.pl | 13 ++++++++++--- src/Factoids/Statement.pl | 18 ++++++++++++++++++ 5 files changed, 49 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4864c93..b0b7472 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +1.5.3 +===== + +* New maxVolunteerLength to govern max size of non addressed replies + +* Cleaned up some of the regex code for what the bot considers a question + +* Fixed an obscure and undocumented variable that was disabling "query?" +questions in non addressed mode + 1.5.2 ===== diff --git a/files/sample/infobot.chan b/files/sample/infobot.chan index adb5dc1..40ea9fa 100644 --- a/files/sample/infobot.chan +++ b/files/sample/infobot.chan @@ -76,7 +76,8 @@ _default maxListReplyCount 15 maxListReplyLength 400 +md5 - minVolunteerLength 50 + minVolunteerLength 2 + maxVolunteerLength 512 +nickometer +pager +piglatin diff --git a/src/Factoids/Core.pl b/src/Factoids/Core.pl index bb814dc..847f7e2 100644 --- a/src/Factoids/Core.pl +++ b/src/Factoids/Core.pl @@ -20,7 +20,7 @@ sub validFactoid { # allow the following only if they have been made on purpose. if ( $rhs ne '' and $rhs !~ /^ 0; - return '' if ( length $query < &::getChanConf('minVolunteerLength') ); + return '' + if ( + length $query < + &::getChanConfDefault( 'minVolunteerLength', 2, $chan ) or + $param{'addressing'} =~ m/require/i ); + return '' + if ( + length $query > + &::getChanConfDefault( 'maxVolunteerLength', 512, $chan ) or + $param{'addressing'} =~ m/require/i ); } else { ### TODO: this should be caught in Process.pl? diff --git a/src/Factoids/Statement.pl b/src/Factoids/Statement.pl index 2c5a8e2..48b10cb 100644 --- a/src/Factoids/Statement.pl +++ b/src/Factoids/Statement.pl @@ -58,6 +58,24 @@ sub doStatement { if ( $in =~ /(^|\s)(is|are)(\s|$)/i ) { my ( $lhs, $mhs, $rhs ) = ( $`, $&, $' ); + # Quit if they are over the limits. Check done here since Core.pl calls + # this mid sub and Question.pl needs its own check as well. NOTE: $in is + # used in this place since lhs and rhs are really undefined for unwanted + # teaching. Mainly, the "is" could be anywhere within a 510 byte or so + # block of text, so the total size was choosen since the sole purpose of + # this logic is to not hammer the db with pointless factoids that were + # only meant to be general conversation. + return '' + if ( + length $in < + &::getChanConfDefault( 'minVolunteerLength', 2, $chan ) or + $param{'addressing'} =~ m/require/i ) and not $addressed; + return '' + if ( + length $in > + &::getChanConfDefault( 'maxVolunteerLength', 512, $chan ) or + $param{'addressing'} =~ m/require/i ) and not $addressed; + # allows factoid arguments to be updated. -lear. $lhs =~ s/^(cmd: )?(.*)/$1||'' . lc $2/e; -- 2.39.2