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*$//;
26 $query =~ s/^\s+|\s+$//g;
28 if (!defined $query or $query =~ /^\s*$/) {
29 &FIXME("doQ: query == NULL (message => $message)");
33 my $questionWord = "";
36 return '' unless ($finalQMark);
37 return '' if (&IsParam("minVolunteerLength") == 0);
38 return '' if (length $query < $param{'minVolunteerLength'});
40 ### TODO: this should be caught in Process.pl?
41 return '' unless ($talkok);
44 # dangerous; common preambles should be stripped before here
45 if ($query =~ /^forget /i or $query =~ /^no, /) {
46 return if (exists $bots{$nuh});
49 # convert to canonical reference form
53 push(@query, $query); # 1: push original.
56 if ($query =~ s/[!.]$//) {
60 $x = &normquery($query);
61 push(@query, $x) if ($x ne $query);
64 $x = &switchPerson($query);
65 push(@query, $x) if ($x ne $query);
68 $query =~ s/\s+at\s*(\?*)$/$1/; # where is x at?
69 $query =~ s/^explain\s*(\?*)/$1/i; # explain x
70 $query = " $query "; # side whitespaces.
72 my $qregex = join '|', keys %{ $lang{'qWord'} };
74 # what's whats => what is; who'?s => who is, etc
75 $query =~ s/ ($qregex)\'?s / $1 is /i;
76 if ($query =~ s/\s+($qregex)\s+//i) { # check for question word
77 $questionWord = lc($1);
80 if ($questionWord eq "" and $finalQMark and $addressed) {
81 $questionWord = "where";
85 for (my$i=0; $i<scalar @query; $i++) {
87 $result = &getReply($query);
88 next if (!defined $result or $result eq "");
90 # 'see also' factoid redirection support.
92 while ($result =~ /^see( also)? (.*?)\.?$/) {
95 if (grep /^$link$/i, @link) {
96 &status("recursive link found; bailing out.");
100 if (scalar @link >= 5) {
101 &status("recursive link limit reached.");
106 my $newr = &getReply($link);
107 last if (!defined $newr or $newr eq "");
112 &status("'$query' linked to: ".join(" => ", @link) );
116 &DEBUG("Question: '$query[0]' did not exist; '$query[$i]' ($i) did");
122 ### TODO: Use &Forker(); move function to Freshmeat.pl.
123 if (&IsChanConf("freshmeatForFactoid")) {
124 &loadMyModule($myModules{'freshmeat'});
125 $result = &Freshmeat::showPackage($query);
126 return $result if (defined $result);
129 ### TODO: Use &Forker(); move function to Debian.pl
130 if (&IsChanConf("debianForFactoid")) {
131 &loadMyModule($myModules{'debian'});
132 $result = &Debian::DebianFind($query); # ???
133 ### TODO: debian module should tell, through shm, that it went
135 ### return $result if (defined $result);
138 if ($questionWord ne "" or $finalQMark) {
139 # if it has not been explicitly marked as a question
140 if ($addressed and $reply eq "") {
141 &status("notfound: <$who> ".join(' :: ', @query))
144 return '' unless (&IsParam("friendlyBots"));
146 foreach (split /\s+/, $param{'friendlyBots'}) {
147 &msg($_, ":INFOBOT:QUERY <$who> $query");