1 # infobot :: Kevin Lenzo (c) 1997
4 ## if ($query == query) {
12 if (&IsParam("useStrict")) { use strict; }
14 use vars qw($query $reply $finalQMark $nuh $result $talkok $who $nuh);
15 use vars qw(%infobots %forked);
18 # my doesn't allow variables to be inherinted, local does.
19 # following is used in math()...
22 local $finalQMark = $query =~ s/\?+\s*$//;
23 $finalQMark += $query =~ s/\?\s*$//;
25 if (!defined $query or $query =~ /^\s*$/) {
26 &FIXME("doQ: query == NULL");
30 my $origQuery = $query;
32 my $questionWord = "";
35 return '' unless ($finalQMark);
37 if (&IsParam("minVolunteerLength") == 0 or
38 length($query) < $param{'minVolunteerLength'})
43 ### TODO: this should be caught in Process.pl?
44 return '' unless ($talkok);
47 # dangerous; common preambles should be stripped before here
48 if ($query =~ /^forget /i or $query =~ /^no, /) {
49 return 'NOREPLY' if (exists $infobots{$nuh});
52 # convert to canonical reference form
53 $query = &normquery($query);
54 $query = &switchPerson($query);
56 $query =~ s/\s+at\s*(\?*)$/$1/; # where is x at?
57 $query =~ s/^explain\s*(\?*)/$1/i; # explain x
58 $query = " $query "; # side whitespaces.
60 my $qregex = join '|', keys %{$lang{'qWord'}};
62 # what's whats => what is; who'?s => who is, etc
63 $query =~ s/ ($qregex)\'?s / $1 is /i;
64 if ($query =~ s/\s+($qregex)\s+//i) { # check for question word
65 $questionWord = lc($1);
68 if ($questionWord eq "" and $finalQMark and $addressed) {
69 $questionWord = "where";
72 $query =~ s/^\s+|\s+$//g;
75 if (defined( $result = &getReply($query) )) {
76 # 'see also' factoid redirection support.
77 if ($result =~ /^see( also)? (.*?)\.?$/) {
78 my $newr = &getReply($2);
79 $result = $newr if ($newr ne "");
82 return $result if ($result ne "");
84 ### TODO: Use &Forker(); move function to Freshmeat.pl.
85 if (&IsParam("freshmeatForFactoid")) {
86 &loadMyModule($myModules{'freshmeat'});
87 $result = &Freshmeat::showPackage($query);
88 return $result unless ($result eq 'NOREPLY');
91 &DEBUG("Question: hrm... result => '$result'.");
94 if ($questionWord ne "" or $finalQMark) {
95 # if it has not been explicitly marked as a question
96 if ($addressed and $reply eq "") {
97 if ($origQuery eq $query) {
98 &status("notfound: <$who> $origQuery");
100 &status("notfound: <$who> $origQuery :: $query");
103 return '' unless (&IsParam("friendlyBots"));
105 foreach (split /\s+/, $param{'friendlyBots'}) {
106 &msg($_, ":INFOBOT:QUERY <$who> $query");