3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-13 23:49:31 +01:00
pbot/modules/acronym.pl
Pragmatic Software 73b793295b todo! add support for admin management - needs support for adding/removing/saving!
todo! multi-channel support pathetic (note 12/08/09, fixed multi-channel for anti-flood and for ignore)
todo! most of this crap needs to be refactored (note 11/23/09, refactored execute_module)

0.4.1 (12/08/09): improved anti-flood system to be significantly more accurate and per-channel
                  added per-nick-per-channel message history using %flood_watch
                  add per-channel support to ignore system
                  automatically remove message history for nicks that haven't spoken in one day (run once per hour)
                  do not ignore !login command
0.3.16(11/23/09): refactored module execution to execute_module() subroutine
                  added trigger to execute get_title.pl module when URL is
                  detected in regular untriggered chat
0.3.15(11/20/09): replace 'me' with '$nick' in arguments
2009-12-09 01:08:12 +00:00

58 lines
1.0 KiB
Perl
Executable File

#!/usr/bin/perl -w -I /home/msmud/lib/lib/perl5/site_perl/5.10.0/
# 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; ";
}
$acro =~ s/\s+\[slang\]//gi;
$acro =~ s/\s+\[joke\]//gi;
$acro =~ s/\s+/ /g;
$acro =~ s/<.*?>//g;
$acro =~ s/&nbsp;//g;
$acro =~ s/; ; $//;
print "$acro\n";