mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 03:02:47 +01:00
73b793295b
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
119 lines
1.9 KiB
Perl
Executable File
119 lines
1.9 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::Simple;
|
|
|
|
my ($defint, $phrase, $text, $entry, $entries, $i);
|
|
|
|
if ($#ARGV < 0)
|
|
{
|
|
print "What phrase would you like to define?\n";
|
|
die;
|
|
}
|
|
|
|
$phrase = join("%20", @ARGV);
|
|
|
|
$entry = 1;
|
|
|
|
if($phrase =~ m/([0-9]+)%20(.*)/)
|
|
{
|
|
$entry = $1;
|
|
$phrase = $2;
|
|
}
|
|
|
|
$text = get("http://dictionary.reference.com/search?q=$phrase");
|
|
|
|
$phrase =~ s/\%20/ /g;
|
|
|
|
if($text =~ m/because there was not a match on/i)
|
|
{
|
|
print "No entry found for '$phrase'. ";
|
|
|
|
|
|
if($text =~ m/Dictionary suggestions:/g)
|
|
{
|
|
print "Suggestions: ";
|
|
|
|
$i = 90;
|
|
while($text =~ m/<a href="\/search\?r=2&q=.*?>(.*?)<\/a>/g && $i > 0)
|
|
{
|
|
print "$1, ";
|
|
$i--;
|
|
}
|
|
}
|
|
|
|
# if($text =~ m/Encyclopedia suggestions:/g)
|
|
# {
|
|
# print "Suggestions: ";
|
|
#
|
|
# $i = 30;
|
|
# while($text =~ m/<a href=".*?\/search\?r=13&q=.*?>(.*?)<\/a>/g
|
|
# && $i > 0)
|
|
# {
|
|
# print "$1, ";
|
|
# $i--;
|
|
# }
|
|
# }
|
|
|
|
print "\n";
|
|
exit 0;
|
|
}
|
|
|
|
if($text =~ m/- (.*?) dictionary result/g)
|
|
{
|
|
$entries = $1;
|
|
}
|
|
|
|
$entries = 1 if(not defined $entries);
|
|
|
|
if($entry > $entries)
|
|
{
|
|
print "No entry found for $phrase.\n";
|
|
exit 0;
|
|
}
|
|
|
|
print "$phrase: ";
|
|
|
|
$i = $entry;
|
|
|
|
$defint = "";
|
|
|
|
my $quote = chr(226) . chr(128) . chr(156);
|
|
my $quote2 = chr(226) . chr(128) . chr(157);
|
|
my $dash = chr(226) . chr(128) . chr(147);
|
|
|
|
while($i <= $entries)
|
|
{
|
|
if($text =~ m/<td>(.*?)<\/td>/gs)
|
|
{
|
|
$defint = $1;
|
|
}
|
|
|
|
# and now for some fugly beautifying regexps...
|
|
|
|
$defint =~ s/$quote/"/g;
|
|
$defint =~ s/$quote2/"/g;
|
|
$defint =~ s/$dash/-/g;
|
|
$defint =~ s/<b>Pronun.*?<BR>//gsi;
|
|
$defint =~ s/<.*?>//gsi;
|
|
$defint =~ s/\ \;/ /gi;
|
|
$defint =~ s/\&.*?\;//g;
|
|
$defint =~ s/\r\n//gs;
|
|
$defint =~ s/\( P \)//gs;
|
|
$defint =~ s/\s+/ /gs;
|
|
|
|
if($defint =~ /interfaceflash/) {
|
|
$i++;
|
|
next;
|
|
}
|
|
|
|
$i++ and next if $defint eq " ";
|
|
|
|
print "$i) $defint ";
|
|
|
|
$i++;
|
|
}
|
|
|
|
print "\n";
|