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*$/) {
32 my $questionWord = "";
35 return '' unless ($finalQMark);
36 return '' if (&IsParam("minVolunteerLength") == 0);
37 return '' if (length $query < $param{'minVolunteerLength'});
39 ### TODO: this should be caught in Process.pl?
40 return '' unless ($talkok);
43 # dangerous; common preambles should be stripped before here
44 if ($query =~ /^forget /i or $query =~ /^no, /) {
45 return if (exists $bots{$nuh});
48 # convert to canonical reference form
52 push(@query, $query); # 1: push original.
55 if ($query =~ s/[!.]$//) {
59 $x = &normquery($query);
60 push(@query, $x) if ($x ne $query);
63 $x = &switchPerson($query);
64 push(@query, $x) if ($x ne $query);
67 $query =~ s/\s+at\s*(\?*)$/$1/; # where is x at?
68 $query =~ s/^explain\s*(\?*)/$1/i; # explain x
69 $query = " $query "; # side whitespaces.
71 my $qregex = join '|', keys %{ $lang{'qWord'} };
73 # what's whats => what is; who'?s => who is, etc
74 $query =~ s/ ($qregex)\'?s / $1 is /i;
75 if ($query =~ s/\s+($qregex)\s+//i) { # check for question word
76 $questionWord = lc($1);
79 if ($questionWord eq "" and $finalQMark and $addressed) {
80 $questionWord = "where";
84 for (my$i=0; $i<scalar @query; $i++) {
86 $result = &getReply($query);
87 next if (!defined $result or $result eq "");
89 # 'see also' factoid redirection support.
91 while ($result =~ /^see( also)? (.*?)\.?$/) {
94 if (grep /^$link$/i, @link) {
95 &status("recursive link found; bailing out.");
99 if (scalar @link >= 5) {
100 &status("recursive link limit reached.");
105 my $newr = &getReply($link);
106 last if (!defined $newr or $newr eq "");
111 &status("'$query' linked to: ".join(" => ", @link) );
115 &VERB("Question.pl: '$query[0]' did not exist; '$query[$i]' ($i) did",2);
121 ### TODO: Use &Forker(); move function to Freshmeat.pl.
122 if (&IsChanConf("freshmeatForFactoid")) {
123 &loadMyModule($myModules{'freshmeat'});
124 $result = &Freshmeat::showPackage($query);
125 return $result if (defined $result);
128 ### TODO: Use &Forker(); move function to Debian.pl
129 if (&IsChanConf("debianForFactoid")) {
130 &loadMyModule($myModules{'debian'});
131 $result = &Debian::DebianFind($query); # ???
132 ### TODO: debian module should tell, through shm, that it went
134 ### return $result if (defined $result);
137 if ($questionWord ne "" or $finalQMark) {
138 # if it has not been explicitly marked as a question
139 if ($addressed and $reply eq "") {
140 &status("notfound: <$who> ".join(' :: ', @query))
143 return '' unless (&IsParam("friendlyBots"));
145 foreach (split /\s+/, $param{'friendlyBots'}) {
146 &msg($_, ":INFOBOT:QUERY <$who> $query");