3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00
pbot/modules/acronym.pl

58 lines
1.0 KiB
Perl
Raw Normal View History

#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
2007-05-20 22:44:44 +02:00
# quick and dirty by :pragma
use LWP::UserAgent;
my ($result, $acro, $entries, $text);
if ($#ARGV <0)
{
print "What is the acronym you'd like to know about?\n";
die;
}
$acro = join("+", @ARGV);
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0");
my $response = $ua->post("http://www.acronymsearch.com/index.php",
[ acronym => $acro, act => 'search' ]);
if (not $response->is_success)
{
print "Couldn't get acronym information.\n";
die;
}
$text = $response->content;
$acro =~ s/\+/ /g;
if($text =~ m/No result found/)
{
print "Sorry, couldn't figure out what '$acro' stood for.\n";
die;
}
$entries = 1;
$entries = $1 if($text =~ m/"2">(.*?) results? found/gi);
print "$acro ($entries entries): ";
$acro="";
while($text =~ m/<td width=.*?>(.*?)<\/td>/gsi)
{
$acro = "$acro$1; ";
2007-05-20 22:44:44 +02:00
}
$acro =~ s/\s+\[slang\]//gi;
$acro =~ s/\s+\[joke\]//gi;
$acro =~ s/\s+/ /g;
$acro =~ s/<.*?>//g;
$acro =~ s/&nbsp;//g;
$acro =~ s/; ; $//;
2007-05-20 22:44:44 +02:00
print "$acro\n";