2 ### Question.pl: Kevin Lenzo (c) 1997
6 ## if ($query == query) {
14 if (&IsParam("useStrict")) { use strict; }
16 use vars qw($query $reply $finalQMark $nuh $result $talkok $who $nuh);
17 use vars qw(%bots %forked);
20 # my doesn't allow variables to be inherinted, local does.
21 # following is used in math()...
24 local $finalQMark = $query =~ s/\?+\s*$//;
25 $finalQMark += $query =~ s/\?\s*$//;
27 if (!defined $query or $query =~ /^\s*$/) {
28 &FIXME("doQ: query == NULL");
32 my $origQuery = $query;
34 my $questionWord = "";
37 return '' unless ($finalQMark);
39 if (&IsParam("minVolunteerLength") == 0 or
40 length($query) < $param{'minVolunteerLength'})
45 ### TODO: this should be caught in Process.pl?
46 return '' unless ($talkok);
49 # dangerous; common preambles should be stripped before here
50 if ($query =~ /^forget /i or $query =~ /^no, /) {
51 return $noreply if (exists $bots{$nuh});
54 # convert to canonical reference form
55 $query = &normquery($query);
56 $query = &switchPerson($query);
58 $query =~ s/\s+at\s*(\?*)$/$1/; # where is x at?
59 $query =~ s/^explain\s*(\?*)/$1/i; # explain x
60 $query = " $query "; # side whitespaces.
62 my $qregex = join '|', keys %{$lang{'qWord'}};
64 # what's whats => what is; who'?s => who is, etc
65 $query =~ s/ ($qregex)\'?s / $1 is /i;
66 if ($query =~ s/\s+($qregex)\s+//i) { # check for question word
67 $questionWord = lc($1);
70 if ($questionWord eq "" and $finalQMark and $addressed) {
71 $questionWord = "where";
74 $query =~ s/^\s+|\s+$//g;
77 if (defined( $result = &getReply($query) )) {
78 # 'see also' factoid redirection support.
79 if ($result =~ /^see( also)? (.*?)\.?$/) {
80 my $newr = &getReply($2);
81 $result = $newr if ($newr ne "");
84 return $result if ($result ne "");
86 ### TODO: Use &Forker(); move function to Freshmeat.pl.
87 if (&IsParam("freshmeatForFactoid")) {
88 &loadMyModule($myModules{'freshmeat'});
89 $result = &Freshmeat::showPackage($query);
90 return $result unless ($result eq $noreply);
93 &DEBUG("Question: hrm... result => '$result'.");
96 if ($questionWord ne "" or $finalQMark) {
97 # if it has not been explicitly marked as a question
98 if ($addressed and $reply eq "") {
99 if ($origQuery eq $query) {
100 &status("notfound: <$who> $origQuery");
102 &status("notfound: <$who> $origQuery :: $query");
105 return '' unless (&IsParam("friendlyBots"));
107 foreach (split /\s+/, $param{'friendlyBots'}) {
108 &msg($_, ":INFOBOT:QUERY <$who> $query");