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);
38 return '' if (&IsParam("minVolunteerLength") == 0);
39 return '' if (length($query) < $param{'minVolunteerLength'});
41 ### TODO: this should be caught in Process.pl?
42 return '' unless ($talkok);
45 # dangerous; common preambles should be stripped before here
46 if ($query =~ /^forget /i or $query =~ /^no, /) {
47 return $noreply if (exists $bots{$nuh});
50 # convert to canonical reference form
51 $query = &normquery($query);
52 $query = &switchPerson($query);
54 $query =~ s/\s+at\s*(\?*)$/$1/; # where is x at?
55 $query =~ s/^explain\s*(\?*)/$1/i; # explain x
56 $query = " $query "; # side whitespaces.
58 my $qregex = join '|', keys %{$lang{'qWord'}};
60 # what's whats => what is; who'?s => who is, etc
61 $query =~ s/ ($qregex)\'?s / $1 is /i;
62 if ($query =~ s/\s+($qregex)\s+//i) { # check for question word
63 $questionWord = lc($1);
66 if ($questionWord eq "" and $finalQMark and $addressed) {
67 $questionWord = "where";
70 $query =~ s/^\s+|\s+$//g;
75 if ($query =~ s/[\!\.]$//) {
76 &DEBUG("Question: Pushing query without trailing symbols.");
80 foreach $query (@query) {
81 $result = &getReply($query);
82 next if ($result eq "");
84 # 'see also' factoid redirection support.
85 if ($result =~ /^see( also)? (.*?)\.?$/) {
86 my $newr = &getReply($2);
87 $result = $newr if ($newr ne "");
93 ### TODO: Use &Forker(); move function to Freshmeat.pl.
94 if (&IsParam("freshmeatForFactoid")) {
95 &loadMyModule($myModules{'freshmeat'});
96 $result = &Freshmeat::showPackage($query);
97 return $result unless ($result eq $noreply);
99 &DEBUG("Question: hrm... result => '$result' for '$query'.");
101 if ($questionWord ne "" or $finalQMark) {
102 # if it has not been explicitly marked as a question
103 if ($addressed and $reply eq "") {
104 if ($origQuery eq $query) {
105 &status("notfound: <$who> $origQuery");
107 &status("notfound: <$who> $origQuery :: $query");
110 return '' unless (&IsParam("friendlyBots"));
112 foreach (split /\s+/, $param{'friendlyBots'}) {
113 &msg($_, ":INFOBOT:QUERY <$who> $query");