mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-28 13:42:33 +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
99 lines
1.7 KiB
Perl
Executable File
99 lines
1.7 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
|
|
use LWP::Simple;
|
|
|
|
my ($text, $buffer, $location);
|
|
|
|
if($#ARGV < 0)
|
|
{
|
|
print "Try again. Please specify the location you would like to search for nearby cities around.\n";
|
|
die;
|
|
}
|
|
|
|
$location = join("+", @ARGV);
|
|
|
|
$location =~ s/,/%2C/;
|
|
|
|
if($location =~ m/\+-(.*)/)
|
|
{
|
|
# -arguments?
|
|
$location =~ s/\+-.*//;
|
|
}
|
|
|
|
$text = get("http://weather.yahoo.com/search/weather2?p=$location");
|
|
|
|
$location =~ s/\+/ /g;
|
|
$location =~ s/%2C/,/g;
|
|
|
|
if($text =~ m/No match found/)
|
|
{
|
|
print "$location is not a valid location for this service.\n";
|
|
die;
|
|
}
|
|
|
|
my $found = 0;
|
|
my $buf;
|
|
my $i;
|
|
|
|
if($text =~ m/location matches\:/g)
|
|
{
|
|
$buf = "Multiple locations found: ";
|
|
|
|
while($text =~ m/<a\shref="\/forecast\/(.*?)">(.*?)<\/a>/g)
|
|
{
|
|
$i = $1;
|
|
$buffer = $2;
|
|
|
|
$buffer =~ s/<b>//g;
|
|
$buffer =~ s/<\/b>//g;
|
|
$buffer =~ s/^\s+//;
|
|
|
|
$buf = $buf . "$buffer - ";
|
|
|
|
if($location =~ m/$buffer/i)
|
|
{
|
|
$text = get("http://weather.yahoo.com/forecast/$i");
|
|
$found = 1;
|
|
}
|
|
}
|
|
$buf = $buf. "please specify one of these.\n";
|
|
if (not $found)
|
|
{
|
|
print $buf;
|
|
die;
|
|
}
|
|
}
|
|
|
|
my ($country, $state, $city);
|
|
|
|
$text =~ m/<a href="\/">Weather<\/a>\s>/g;
|
|
$text =~ m/<a href=.*?>(.*?)<\/a>\s>/g;
|
|
$country = $1;
|
|
|
|
if($country eq "North America")
|
|
{
|
|
$text =~ m/<a href=.*?>(.*?)<\/a>\s>/g;
|
|
$country = $1;
|
|
}
|
|
|
|
if($country ne "Canada")
|
|
{
|
|
$text =~ m/<a href=.*?>(.*?)<\/a>\s>/g;
|
|
$state = $1;
|
|
}
|
|
|
|
$text =~ m/^(.*?)<\/b><\/font>/mg;
|
|
$city = $1;
|
|
|
|
$text =~ m/Nearby.*?Locations/sgi;
|
|
|
|
print "$country, $state, $city - Nearby Locations: ";
|
|
|
|
while($text =~ m/<a href=\"\/forecast\/.*?\.html\">(.*?)<\/a>/gi)
|
|
{
|
|
$buf = $1;
|
|
$buf =~ s/<.*?>//gi;
|
|
print "$buf, ";
|
|
}
|
|
print "\n";
|