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.
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) = ($`, $&, $');
58 # allows factoid arguments to be updated. -lear.
59 $lhs =~ s/^(cmd: )?(.*)/$1||"" . lc $2/e;
62 $lhs =~ s/^(the|da|an?)\s+//i;
64 # remove excessive initial and final whitespaces.
65 $lhs =~ s/^\s+|\s+$//g;
66 $mhs =~ s/^\s+|\s+$//g;
67 $rhs =~ s/^\s+|\s+$//g;
69 # break if either lhs or rhs is NULL.
70 if ($lhs eq "" or $rhs eq "") {
71 return "NOT-A-STATEMENT";
74 # lets check if it failed.
75 if (&validFactoid($lhs,$rhs) == 0) {
77 &status("IGNORE statement: <$who> $message");
78 &performReply( &getRandom(keys %{ $lang{'confused'} }) );
83 # uncomment to prevent HUNGRY learning of rhs with whitespace
84 #return if (!$addressed and $lhs =~ /\s+/);
85 &::DEBUG("doStatement: $in:$lhs:$mhs:$rhs");
87 &status("statement: <$who> $message");
89 # change "#*#" back to "*" because of '\' sar to '#blah#'.
90 $lhs =~ s/\#(\S+)\#/$1/g;
91 $rhs =~ s/\#(\S+)\#/$1/g;
93 $lhs =~ s/\?+\s*$//; # strip off '?'.
95 # verify the update statement whether there are any weird
97 ### this can be simplified.
98 foreach (split //, $lhs.$rhs) {
100 if ($ord > 170 and $ord < 220) {
101 &status("statement: illegal character '$_' $ord.");
102 &performAddressedReply("i'm not going to learn illegal characters");
108 return if (&update($lhs, $mhs, $rhs));