X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FFactoids%2FStatement.pl;h=0df491860dd34fd62e73f832000e19af853c138a;hb=cb81fea9939f349b36e3b5a0cdc0343a6b781da1;hp=aec268c0b98bcce4fde9c43513be228e41a4d786;hpb=884b215a800302006deeb627317334a73f5ea741;p=infobot.git diff --git a/src/Factoids/Statement.pl b/src/Factoids/Statement.pl index aec268c..0df4918 100644 --- a/src/Factoids/Statement.pl +++ b/src/Factoids/Statement.pl @@ -6,14 +6,14 @@ ## doStatement -- ## ## decide if $in is a statement, and if so, -## - update the dbm +## - update the db ## - return feedback statement ## ## otherwise return ## - null for confused. ## -if (&IsParam("useStrict")) { use strict; } +# use strict; # TODO sub doStatement { my($in) = @_; @@ -24,13 +24,13 @@ sub doStatement { # check if we need to be addressed and if we are return unless ($learnok); - my($urlType) = ""; + my($urlType) = ''; # prefix www with http:// and ftp with ftp:// $in =~ s/ www\./ http:\/\/www\./ig; $in =~ s/ ftp\./ ftp:\/\/ftp\./ig; - $urlType = "about" if ($in =~ /\babout:/i); + $urlType = 'about' if ($in =~ /\babout:/i); $urlType = 'afp' if ($in =~ /\bafp:/); $urlType = 'file' if ($in =~ /\bfile:/); $urlType = 'palace' if ($in =~ /\bpalace:/); @@ -40,12 +40,12 @@ sub doStatement { } # acceptUrl. - if (&IsParam("acceptUrl")) { + if (&IsParam('acceptUrl')) { if ($param{'acceptUrl'} eq 'REQUIRE') { # require url type. - return if ($urlType eq ""); + return if ($urlType eq ''); } elsif ($param{'acceptUrl'} eq 'REJECT') { - &status("REJECTED URL entry") if (&IsParam("VERBOSITY")); - return unless ($urlType eq ""); + &status("REJECTED URL entry") if (&IsParam('VERBOSITY')); + return unless ($urlType eq ''); } else { # OPTIONAL } @@ -56,7 +56,7 @@ sub doStatement { my($lhs, $mhs, $rhs) = ($`, $&, $'); # allows factoid arguments to be updated. -lear. - $lhs =~ s/^(CMD: )?(.*)/$1||"" . lc $2/e; + $lhs =~ s/^(cmd: )?(.*)/$1||'' . lc $2/e; # discard article. $lhs =~ s/^(the|da|an?)\s+//i; @@ -67,7 +67,7 @@ sub doStatement { $rhs =~ s/^\s+|\s+$//g; # break if either lhs or rhs is NULL. - if ($lhs eq "" or $rhs eq "") { + if ($lhs eq '' or $rhs eq '') { return "NOT-A-STATEMENT"; } @@ -80,11 +80,13 @@ sub doStatement { return; } - return if (!$addressed and $lhs =~ /\s+/); + # uncomment to prevent HUNGRY learning of rhs with whitespace + #return if (!$addressed and $lhs =~ /\s+/); + &::DEBUG("doStatement: $in:$lhs:$mhs:$rhs"); &status("statement: <$who> $message"); - # change "#*#" back to "*" because of '\' sar to '#blah#'. + # change "#*#" back to '*' because of '\' sar to '#blah#'. $lhs =~ s/\#(\S+)\#/$1/g; $rhs =~ s/\#(\S+)\#/$1/g; @@ -92,7 +94,7 @@ sub doStatement { # verify the update statement whether there are any weird # characters. - ### this chan be simplified. + ### this can be simplified. foreach (split //, $lhs.$rhs) { my $ord = ord $_; if ($ord > 170 and $ord < 220) { @@ -106,7 +108,9 @@ sub doStatement { return if (&update($lhs, $mhs, $rhs)); } - return "CONTINUE"; + return 'CONTINUE'; } 1; + +# vim:ts=4:sw=4:expandtab:tw=80