my ($message) = @_;
my ($retval);
if ($no_BZFlag) {
- &main::status("BZFlag module requires Socket.");
+ &::status("BZFlag module requires Socket.");
return 'BZFlag module not active';
}
if ($message =~ /^bzfquery\s+([^:]*)(?::([0-9]*))?$/xi) {
my ($servernameport) = @_;
my ($servername,$port) = split(":",$servernameport);
if ($no_BZFlag) {
- &main::status("BZFlag module requires Socket.");
+ &::status("BZFlag module requires Socket.");
return 'BZFlag module not active';
}
#my @teamName = ("Rogue", "Red", "Green", "Blue", "Purple", "Observer", "Rabbit");
sub babelfishParam {
return '' if $no_babelfish;
my ($from, $to, $phrase) = @_;
- &main::DEBUG("babelfish($from, $to, $phrase)");
+ &::DEBUG("babelfish($from, $to, $phrase)");
$from = $lang_code{$from};
$to = $lang_code{$to};
sub translate {
return '' if $no_babelfish;
my ($phrase, $languagepair, $req, $ua) = @_;
- &main::DEBUG("translate($phrase, $languagepair, $req, $ua)");
+ &::DEBUG("translate($phrase, $languagepair, $req, $ua)");
my $urltext = uri_escape($phrase);
$req->content("urltext=$urltext&lp=$languagepair");
- &main::DEBUG("http://babelfish.altavista.com/babelfish/tr??urltext=$urltext&lp=$languagepair");
+ &::DEBUG("http://babelfish.altavista.com/babelfish/tr??urltext=$urltext&lp=$languagepair");
my $res = $ua->request($req);
my $translated;
$translated =~ s/<[^>]*>//sg;
$translated =~ s/ / /sg;
$translated =~ s/\s+/ /sg;
- #&main::DEBUG("$translated\n===remove <attributes>\n");
+ #&::DEBUG("$translated\n===remove <attributes>\n");
$translated =~ s/\s*Translate again.*//i;
- &main::DEBUG("$translated\n===remove after 'Translate again'\n");
+ &::DEBUG("$translated\n===remove after 'Translate again'\n");
$translated =~ s/[^:]*?:\s*(Help\s*)?//s;
- &main::DEBUG("len=" . length($translated) . " $translated\n===remove to first ':', optional Help\n");
+ &::DEBUG("len=" . length($translated) . " $translated\n===remove to first ':', optional Help\n");
$translated =~ s/\n/ /g;
# FIXME: should we do unicode->iso (no. use utf8!)
if ($dns =~ /(\d+\.\d+\.\d+\.\d+)/) {
use Socket;
- &main::status("DNS query by IP address: $dns");
+ &::status("DNS query by IP address: $dns");
$y = pack('C4', split(/\./, $dns));
$x = (gethostbyaddr($y, &AF_INET));
} else {
- &main::status("DNS query by name: $dns");
+ &::status("DNS query by name: $dns");
$x = join('.',unpack('C4',(gethostbyname($dns))[4]));
if ($x !~ /^\s*$/) {
# TODO only allow registered users?
if ($no_page) {
- &main::status('page module requires Mail::Mailer.');
+ &::status('page module requires Mail::Mailer.');
return 'page module not active';
}
my $channel = $::chan || 'infobot';
# TODO disallow use from private message? $chan="_default"
- &main::status("pager: from $from <$fromaddr>, to $to <$toaddr>, msg \"$msg\"");
+ &::status("pager: from $from <$fromaddr>, to $to <$toaddr>, msg \"$msg\"");
my %headers = (
To => "$to <$toaddr>",
From => "$from <$fromaddr>",
# $logmsg .= "$_: $headers{$_}\n";
# }
# $logmsg .= "\n$msg\n";
-# &main::status("pager:\n$logmsg");
+# &::status("pager:\n$logmsg");
my $failed;
my $mailer = new Mail::Mailer 'sendmail';
return("no binary found.");
}
- if (!&main::validExec($query)) {
+ if (!&::validExec($query)) {
return("argument appears to be fuzzy.");
}
$reply = "possible spellings for $query: @array";
last;
} elsif (/^\+/) {
- &main::DEBUG("spell: '+' found => '$_'.");
+ &::DEBUG("spell: '+' found => '$_'.");
last;
} elsif (/^# (.*?) 0$/) {
# none found.
last;
} else {
- &main::DEBUG("spell: unknown: '$_'.");
+ &::DEBUG("spell: unknown: '$_'.");
}
}
my ($phrase) = @_;
my ($reply, $valid_result) = wikipedia_lookup(@_);
if ($reply) {
- &main::pSReply($reply);
+ &::performStrictReply($reply);
} else {
- &main::pSReply("'$phrase' not found in Wikipedia. Perhaps try a different spelling or case?");
+ &::performStrictReply("'$phrase' not found in Wikipedia. Perhaps try a different spelling or case?");
}
}
return '' if $missing;
my ($reply, $valid_result) = wikipedia_lookup(@_);
if ($valid_result and $reply) {
- &main::pSReply($reply);
+ &::performStrictReply($reply);
}
}
sub wikipedia_lookup {
my ($phrase) = @_;
- &main::DEBUG("wikipedia($phrase)");
+ &::DEBUG("wikipedia($phrase)");
my $ua = new LWP::UserAgent;
$ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy"));
my $url = $wikipedia_search_url . 'search=' . $phrase . '&go=Go';
my $req = HTTP::Request->new('HEAD', $url);
$req->header('Accept-Language' => 'en');
- &main::DEBUG($url);
+ &::DEBUG($url);
my $res = $ua->request($req);
- &main::DEBUG($res->code);
+ &::DEBUG($res->code);
if (!$res->is_success) {
return("Wikipedia might be temporarily unavailable (".$res->code."). Please try again in a few minutes...",
sub wikipedia_get_text {
return '' if $missing;
my ($article) = @_;
- &main::DEBUG("wikipedia_get_text($article)");
+ &::DEBUG("wikipedia_get_text($article)");
my $ua = new LWP::UserAgent;
$ua->proxy('http', $::param{'httpProxy'}) if (&::IsParam("httpProxy"));
$ua->agent("Mozilla/5.0 " . $ua->agent);
$ua->timeout(5);
- &main::DEBUG($wikipedia_export_url . $article);
+ &::DEBUG($wikipedia_export_url . $article);
my $req = HTTP::Request->new('GET', $wikipedia_export_url .
$article);
$req->header('Accept-Language' => 'en');
my $res = $ua->request($req);
my ($title, $redirect, $text);
- &main::DEBUG($res->code);
+ &::DEBUG($res->code);
if ($res->is_success) {
if ($res->code == '200' ) {
} elsif (/#REDIRECT\s*\[\[(.*?)\]\]/i) {
$redirect = $1;
$redirect =~ tr/ /_/;
- &main::DEBUG("wiki redirect to " . $redirect);
+ &::DEBUG("wiki redirect to " . $redirect);
last;
} elsif (/<text>(.*)/) {
$text = '"' . $1;
$text = $text . " " . $_;
}
}
- &main::DEBUG("wikipedia returned text: " . $text .
+ &::DEBUG("wikipedia returned text: " . $text .
", redirect " . $redirect. "\n");
if (!$redirect and !$text) {
if ($query =~ /^$|[^\w]/){
return("usage: wtf <foo>.");
}
- if (!&main::validExec($query)) {
+ if (!&::validExec($query)) {
return("argument appears to be fuzzy.");
}
my ($query) = @_;
if ($no_zfi) {
- &main::status("zfi module requires LWP::UserAgent.");
+ &::status("zfi module requires LWP::UserAgent.");
return '';
}
my ($query) = @_;
if ($no_zsi) {
- &main::status("zsi module requires LWP::UserAgent.");
+ &::status("zsi module requires LWP::UserAgent.");
return '';
}