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 '' );
47 elsif ( $param{'acceptUrl'} eq 'REJECT' ) {
48 &status("REJECTED URL entry") if ( &IsParam('VERBOSITY') );
49 return unless ( $urlType eq '' );
57 # learn statement. '$lhs is|are $rhs'
58 if ( $in =~ /(^|\s)(is|are)(\s|$)/i ) {
59 my ( $lhs, $mhs, $rhs ) = ( $`, $&, $' );
61 # Quit if they are over the limits. Check done here since Core.pl calls
62 # this mid sub and Question.pl needs its own check as well. NOTE: $in is
63 # used in this place since lhs and rhs are really undefined for unwanted
64 # teaching. Mainly, the "is" could be anywhere within a 510 byte or so
65 # block of text, so the total size was choosen since the sole purpose of
66 # this logic is to not hammer the db with pointless factoids that were
67 # only meant to be general conversation.
71 &::getChanConfDefault( 'minVolunteerLength', 2, $chan ) or
72 $param{'addressing'} =~ m/require/i ) and not $addressed;
76 &::getChanConfDefault( 'maxVolunteerLength', 512, $chan ) or
77 $param{'addressing'} =~ m/require/i ) and not $addressed;
79 # allows factoid arguments to be updated. -lear.
80 $lhs =~ s/^(cmd: )?(.*)/$1||'' . lc $2/e;
83 $lhs =~ s/^(the|da|an?)\s+//i;
85 # remove excessive initial and final whitespaces.
86 $lhs =~ s/^\s+|\s+$//g;
87 $mhs =~ s/^\s+|\s+$//g;
88 $rhs =~ s/^\s+|\s+$//g;
90 # break if either lhs or rhs is NULL.
91 if ( $lhs eq '' or $rhs eq '' ) {
92 return "NOT-A-STATEMENT";
95 # lets check if it failed.
96 if ( &validFactoid( $lhs, $rhs ) == 0 ) {
98 &status("IGNORE statement: <$who> $message");
99 &performReply( &getRandom( keys %{ $lang{'confused'} } ) );
104 # uncomment to prevent HUNGRY learning of rhs with whitespace
105 #return if (!$addressed and $lhs =~ /\s+/);
106 &::DEBUG("doStatement: $in:$lhs:$mhs:$rhs");
108 &status("statement: <$who> $message");
110 # change "#*#" back to '*' because of '\' sar to '#blah#'.
111 $lhs =~ s/\#(\S+)\#/$1/g;
112 $rhs =~ s/\#(\S+)\#/$1/g;
114 $lhs =~ s/\?+\s*$//; # strip off '?'.
116 # verify the update statement whether there are any weird
118 ### this can be simplified.
119 for my $temp ($lhs,$rhs ) {
120 if ($temp =~ /([^[:print:]])/) {
121 &status("statement: illegal character '$1' ".ord($1).".");
122 &performAddressedReply(
123 "i'm not going to learn illegal characters");
128 return if ( &update( $lhs, $mhs, $rhs ) );
136 # vim:ts=4:sw=4:expandtab:tw=80