2 ### Statement.pl: Kevin Lenzo (c) 1997
8 ## decide if $in is a statement, and if so,
10 ## - return feedback statement
13 ## - null for confused.
16 if (&IsParam("useStrict")) { use strict; }
21 $in =~ s/\\(\S+)/\#$1\#/g; # fix the backslash.
22 $in =~ s/^no([, ]+)//i; # 'no, '.
24 # check if we need to be addressed and if we are
25 return unless ($learnok);
29 # prefix www with http:// and ftp with ftp://
30 $in =~ s/ www\./ http:\/\/www\./ig;
31 $in =~ s/ ftp\./ ftp:\/\/ftp\./ig;
33 $urlType = "about" if ($in =~ /\babout:/i);
34 $urlType = 'afp' if ($in =~ /\bafp:/);
35 $urlType = 'file' if ($in =~ /\bfile:/);
36 $urlType = 'palace' if ($in =~ /\bpalace:/);
37 $urlType = 'phoneto' if ($in =~ /\bphone(to)?:/);
38 if ($in =~ /\b(news|http|ftp|gopher|telnet):\s*\/\/[\-\w]+(\.[\-\w]+)+/) {
43 if (&IsParam("acceptUrl")) {
44 if ($param{'acceptUrl'} eq 'REQUIRE') { # require url type.
45 return if ($urlType eq "");
46 } elsif ($param{'acceptUrl'} eq 'REJECT') {
47 &status("REJECTED URL entry") if (&IsParam("VERBOSITY"));
48 return unless ($urlType eq "");
54 # learn statement. '$lhs is|are $rhs'
55 if ($in =~ /(^|\s)(is|are)(\s|$)/i) {
56 my($lhs, $mhs, $rhs) = ($`, $&, $');
59 $lhs =~ s/^(the|da|an?)\s+//i; # discard article
61 # remove excessive initial and final whitespaces.
62 $lhs =~ s/^\s+|\s+$//g;
63 $mhs =~ s/^\s+|\s+$//g;
64 $rhs =~ s/^\s+|\s+$//g;
66 # break if either lhs or rhs is NULL.
67 if ($lhs eq "" or $rhs eq "") {
68 return "NOT-A-STATEMENT";
71 # lets check if it failed.
72 if (&validFactoid($lhs,$rhs) == 0) {
74 &status("IGNORE statement: <$who> $message");
75 &performReply( &getRandom(keys %{ $lang{'confused'} }) );
80 return if (!$addressed and $lhs =~ /\s+/);
82 &status("statement: <$who> $message");
84 # change "#*#" back to "*" because of '\' sar to '#blah#'.
85 $lhs =~ s/\#(\S+)\#/$1/g;
86 $rhs =~ s/\#(\S+)\#/$1/g;
88 $lhs =~ s/\?+\s*$//; # strip off '?'.
90 # verify the update statement whether there are any weird
92 ### this chan be simplified.
93 foreach (split //, $lhs.$rhs) {
95 if ($ord > 170 and $ord < 220) {
96 &status("statement: illegal character '$_' $ord.");
97 &performAddressedReply("i'm not going to learn illegal characters");
103 return if (&update($lhs, $mhs, $rhs));