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.
14 ## - NOREPLY not to respond.
17 if (&IsParam("useStrict")) { use strict; }
22 $in =~ s/\\(\S+)/\#$1\#/g; # fix the backslash.
23 $in =~ s/^no([, ]+)//i; # 'no, '.
25 # check if we need to be addressed and if we are
26 return $noreply unless ($learnok);
30 # prefix www with http:// and ftp with ftp://
31 $in =~ s/ www\./ http:\/\/www\./ig;
32 $in =~ s/ ftp\./ ftp:\/\/ftp\./ig;
34 $urlType = "about" if ($in =~ /\babout:/i);
35 $urlType = 'afp' if ($in =~ /\bafp:/);
36 $urlType = 'file' if ($in =~ /\bfile:/);
37 $urlType = 'palace' if ($in =~ /\bpalace:/);
38 $urlType = 'phoneto' if ($in =~ /\bphone(to)?:/);
39 if ($in =~ /\b(news|http|ftp|gopher|telnet):\s*\/\/[\-\w]+(\.[\-\w]+)+/) {
44 if (&IsParam("acceptUrl")) {
45 if ($param{'acceptUrl'} eq 'REQUIRE') { # require url type.
46 return $noreply if ($urlType eq "");
47 } elsif ($param{'acceptUrl'} eq 'REJECT') {
48 &status("REJECTED URL entry") if (&IsParam("VERBOSITY"));
49 return $noreply unless ($urlType eq "");
55 # learn statement. '$lhs is|are $rhs'
56 if ($in =~ /(^|\s)(is|are)(\s|$)/i) {
57 my($lhs, $mhs, $rhs) = ($`, $&, $');
60 $lhs =~ s/^(the|da|an?)\s+//i; # discard article
62 # remove excessive initial and final whitespaces.
63 $lhs =~ s/^\s+|\s+$//g;
64 $mhs =~ s/^\s+|\s+$//g;
65 $rhs =~ s/^\s+|\s+$//g;
67 # break if either lhs or rhs is NULL.
68 if ($lhs eq "" or $rhs eq "") {
72 # lets check if it failed.
73 if (&validFactoid($lhs,$rhs) == 0) {
75 &status("IGNORE statement: <$who> $message");
76 &performReply( &getRandom(keys %{$lang{'confused'}}) );
81 return $noreply if (!$addressed and $lhs =~ /\s+/);
83 &status("statement: <$who> $message");
85 # change "#*#" back to "*" because of '\' sar to '#blah#'.
86 $lhs =~ s/\#(\S+)\#/$1/g;
87 $rhs =~ s/\#(\S+)\#/$1/g;
89 $lhs =~ s/\?+\s*$//; # strip off '?'.
91 # verify the update statement whether there are any weird
93 ### this chan be simplified.
94 foreach (split //, $lhs.$rhs) {
96 if ($ord > 170 and $ord < 220) {
97 &status("statement: illegal character '$_' $ord.");
98 &performAddressedReply("i'm not going to learn illegal characters");
103 return &update($lhs, $mhs, $rhs);