X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2FFactoids%2FStatement.pl;h=b02a4daf1bf4412c2de24009bc237a7797863c26;hb=b28802c40e8775f2a9457b833e2014ccc2f4161c;hp=903a4f857d717380efdb031e136940012e54f808;hpb=84a40e626e1568d056200b47a6f7dae44111b7c8;p=infobot.git diff --git a/src/Factoids/Statement.pl b/src/Factoids/Statement.pl index 903a4f8..b02a4da 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) = @_; @@ -55,8 +55,11 @@ sub doStatement { if ($in =~ /(^|\s)(is|are)(\s|$)/i) { my($lhs, $mhs, $rhs) = ($`, $&, $'); - $lhs =~ tr/A-Z/a-z/; - $lhs =~ s/^(the|da|an?)\s+//i; # discard article + # allows factoid arguments to be updated. -lear. + $lhs =~ s/^(CMD: )?(.*)/$1||"" . lc $2/e; + + # discard article. + $lhs =~ s/^(the|da|an?)\s+//i; # remove excessive initial and final whitespaces. $lhs =~ s/^\s+|\s+$//g; @@ -65,14 +68,14 @@ sub doStatement { # break if either lhs or rhs is NULL. if ($lhs eq "" or $rhs eq "") { - return; + return "NOT-A-STATEMENT"; } # lets check if it failed. if (&validFactoid($lhs,$rhs) == 0) { if ($addressed) { &status("IGNORE statement: <$who> $message"); - &performReply( &getRandom(keys %{$lang{'confused'}}) ); + &performReply( &getRandom(keys %{ $lang{'confused'} }) ); } return; } @@ -99,9 +102,8 @@ sub doStatement { } } - if (&update($lhs, $mhs, $rhs)) { - return; # success. - } + # success. + return if (&update($lhs, $mhs, $rhs)); } return "CONTINUE";