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 # look for a "type nugget". this should be externalized.
35 $urlType = "mailto" if ($in =~ /\bmailto:.+\@.+\..{2,}/i);
36 $urlType = "mailto" if ($in =~ s/\b(\S+\@\S+\.\S{2,})/mailto:$1/gi);
37 $in =~ s/(mailto:)+/mailto:/g;
39 $urlType = "about" if ($in =~ /\babout:/i);
40 $urlType = 'afp' if ($in =~ /\bafp:/);
41 $urlType = 'file' if ($in =~ /\bfile:/);
42 $urlType = 'palace' if ($in =~ /\bpalace:/);
43 $urlType = 'phoneto' if ($in =~ /\bphone(to)?:/);
44 if ($in =~ /\b(news|http|ftp|gopher|telnet):\s*\/\/[\-\w]+(\.[\-\w]+)+/) {
49 if (&IsParam("acceptUrl")) {
50 if ($param{'acceptUrl'} eq 'REQUIRE') { # require url type.
51 return $noreply if ($urlType eq "");
52 } elsif ($param{'acceptUrl'} eq 'REJECT') {
53 &status("REJECTED URL entry") if (&IsParam("VERBOSITY"));
54 return $noreply unless ($urlType eq "");
60 # learn statement. '$lhs is|are $rhs'
61 if ($in =~ /(^|\s)(is|are)(\s|$)/i) {
62 my($lhs, $mhs, $rhs) = ($`, $&, $');
65 $lhs =~ s/^(the|da|an?)\s+//i; # discard article
67 # remove excessive initial and final whitespaces.
68 $lhs =~ s/^\s+|\s+$//g;
69 $mhs =~ s/^\s+|\s+$//g;
70 $rhs =~ s/^\s+|\s+$//g;
72 # break if either lhs or rhs is NULL.
73 if ($lhs eq "" or $rhs eq "") {
77 # lets check if it failed.
78 if (&validFactoid($lhs,$rhs) == 0) {
80 &status("IGNORE statement: <$who> $message");
81 &performReply( &getRandom(keys %{$lang{'confused'}}) );
86 return $noreply if (!$addressed and $lhs =~ /\s+/);
88 &status("statement: <$who> $message");
90 # change "#*#" back to "*" because of '\' sar to '#blah#'.
91 $lhs =~ s/\#(\S+)\#/$1/g;
92 $rhs =~ s/\#(\S+)\#/$1/g;
94 $lhs =~ s/\?+\s*$//; # strip off '?'.
96 # verify the update statement whether there are any weird
98 ### this chan be simplified.
99 foreach (split //, $lhs.$rhs) {
101 if ($ord > 170 and $ord < 220) {
102 &status("statement: illegal character '$_' $ord.");
103 &performAddressedReply("i'm not going to learn illegal characters");
108 return &update($lhs, $mhs, $rhs);