]> git.donarmstrong.com Git - infobot.git/commitdiff
* New maxVolunteerLength to govern max size of non addressed replies
authordjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 10 May 2008 08:53:31 +0000 (08:53 +0000)
committerdjmcgrath <djmcgrath@c11ca15a-4712-0410-83d8-924469b57eb5>
Sat, 10 May 2008 08:53:31 +0000 (08:53 +0000)
* 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
files/sample/infobot.chan
src/Factoids/Core.pl
src/Factoids/Question.pl
src/Factoids/Statement.pl

index 4864c93edd84be4ef1ac7e68f3fb306494008b81..b0b747237aab4ea50e47ede4516ff109312f9418 100644 (file)
--- 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
 =====
 
index adb5dc1f5dd4597314a0f812818bad689d506d07..40ea9faf78afb055741e4bd340bf945eb554507b 100644 (file)
@@ -76,7 +76,8 @@ _default
     maxListReplyCount 15
     maxListReplyLength 400
     +md5
-    minVolunteerLength 50
+    minVolunteerLength 2
+    maxVolunteerLength 512
     +nickometer
     +pager
     +piglatin
index bb814dc8a99b33a5ce4cf4a43dc9c87c61dbbd84..847f7e2d8fff4457d52244c0c2ab8e773c350b42 100644 (file)
@@ -20,7 +20,7 @@ sub validFactoid {
 
         # allow the following only if they have been made on purpose.
         if ( $rhs ne '' and $rhs !~ /^</ ) {
-            / \Q$ident$/i and last;    # someone said i'm something.
+            / \Q$ident\E$/i and last;    # someone said i'm something.
             /^i('m)? /    and last;
             /^(it|that|there|what)('s)?(\s+|$)/ and last;
             /^you('re)?(\s+|$)/                 and last;
@@ -84,7 +84,7 @@ sub validFactoid {
         $rhs =~ /( \Q$ident\E's|\Q$ident\E's )/i and last;    # ownership.
 
         # duplication.
-        $rhs =~ /^\Q$lhs /i and last;
+        $rhs =~ /^\Q$lhs\E /i and last;
         last if ( $rhs =~ /^is /i and / is$/ );
 
         $valid++;
@@ -552,12 +552,14 @@ sub FactoidStuff {
     for ($question) {
 
         # fix the string.
-        s/^hey([, ]+)where/where/i;
+        s/^where is //i;
         s/\s+\?$/?/;
-        s/^whois /who is /i
-          ;    # Must match ^, else factoids with "whois" anywhere break
-        s/where can i find/where is/i;
-        s/how about/where is/i;
+        s/^whois //i;   # Must match ^, else factoids with "whois" anywhere break
+        s/^who is //i;
+        s/^what is (a|an)?//i;
+        s/^how do i //i;
+        s/^where can i (find|get|download)//i;
+        s/^how about //i;
         s/ da / the /ig;
 
         # clear the string of useless words.
index 71ae23c171d4156d0d7fb946a92b32dc542c913e..3fdccee7aa06fe6ffaae23cce76db205828c0f26 100644 (file)
@@ -23,7 +23,6 @@ sub doQuestion {
     local ($query) = @_;
     local ($reply) = '';
     local $finalQMark = $query =~ s/\?+\s*$//;
-    $finalQMark += $query =~ s/\?\s*$//;
     $query =~ s/^\s+|\s+$//g;
 
     if ( !defined $query or $query =~ /^\s*$/ ) {
@@ -34,8 +33,16 @@ sub doQuestion {
 
     if ( !$addressed ) {
         return '' unless ($finalQMark);
-        return '' unless &IsChanConf('minVolunteerLength') > 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?
index 2c5a8e219451af9fa2fcf8f037c608c8c502b0b3..48b10cb70944afcd70ce7c6bc0b2e95c8afec48a 100644 (file)
@@ -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;