Revert "Getting rid of tabs."

This reverts commit cc1c8fd5bc.
Failed.
This commit is contained in:
Elijah Perrault committed 2011-02-20 20:47:09 -07:00
1 parent cc1c8fd5bc
commit 92c9a64793
20 files changed
+1277 -1279

No files matched your search

+44 -44
View File
@@ -12,69 +12,69 @@ use XML::Simple;
# Initialization subroutine.
sub _init
{
ssss# Create the Weather command.
sssscmd_add("WEATHER", 0, 0, \%M::Weather::HELP_WEATHER, \&M::Weather::weather) or return 0;
# Create the Weather command.
cmd_add("WEATHER", 0, 0, \%M::Weather::HELP_WEATHER, \&M::Weather::weather) or return 0;
ssss# Success.
ssssreturn 1;
# Success.
return 1;
}
# Void subroutine.
sub _void
{
ssss# Delete the Weather command.
sssscmd_del("WEATHER") or return 0;
# Delete the Weather command.
cmd_del("WEATHER") or return 0;
ssss# Success.
ssssreturn 1;
# Success.
return 1;
}
# Help hashes.
our %HELP_WEATHER = (
ssss'en' => "This command will retrieve the weather via Wunderground for the specified location. \002Syntax:\002 WEATHER <location>",
'en' => "This command will retrieve the weather via Wunderground for the specified location. \002Syntax:\002 WEATHER <location>",
);
# Callback for Weather command.
sub weather
{
ssssmy ($src, @args) = @_;
my ($src, @args) = @_;
ssss# Create an instance of LWP::UserAgent.
ssssmy $ua = LWP::UserAgent->new();
ssss$ua->agent('Auto IRC Bot');
ssss$ua->timeout(2);
ssss# Put together the call to the Wunderground API.
ssssif (!defined $args[0]) {
ssss notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
ssss return 0;
ssss}
ssssmy $loc = join(' ', @args);
ssss$loc =~ s/ /%20/g;
ssssmy $url = "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=".$loc;
ssss# Get the response via HTTP.
ssssmy $response = $ua->get($url);
# Create an instance of LWP::UserAgent.
my $ua = LWP::UserAgent->new();
$ua->agent('Auto IRC Bot');
$ua->timeout(2);
# Put together the call to the Wunderground API.
if (!defined $args[0]) {
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
return 0;
}
my $loc = join(' ', @args);
$loc =~ s/ /%20/g;
my $url = "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=".$loc;
# Get the response via HTTP.
my $response = $ua->get($url);
ssssif ($response->is_success) {
ssss# If successful, decode the content.
ssss my $d = XMLin($response->decoded_content);
ssss# And send to channel
ssss if (!ref($d->{observation_location}->{country})) {
ssss my $windc = $d->{wind_string};
ssss if (substr($windc, length($windc) - 1, 1) eq " ") { $windc = substr($windc, 0, length($windc) - 1); }
ssss privmsg($src->{svr}, $src->{chan}, "Results for \2".$d->{observation_location}->{full}."\2 - \2Temperature:\2 ".$d->{temperature_string}." \2Wind Conditions:\2 ".$windc." \2Conditions:\2 ".$d->{weather});
ssss privmsg($src->{svr}, $src->{chan}, "\2Heat index:\2 ".$d->{heat_index_string}." \2Humidity:\2 ".$d->{relative_humidity}." \2Pressure:\2 ".$d->{pressure_string}." - ".$d->{observation_time});
ssss }
ssss else {
ssss # Otherwise, send an error message.
ssss privmsg($src->{svr}, $src->{chan}, "Location not found.");
ssss }
ssss}
sssselse {
ssss# Otherwise, send an error message.
ssss privmsg($src->{svr}, $src->{chan}, "An error occurred while retrieving your weather.");
ssss}
if ($response->is_success) {
# If successful, decode the content.
my $d = XMLin($response->decoded_content);
# And send to channel
if (!ref($d->{observation_location}->{country})) {
my $windc = $d->{wind_string};
if (substr($windc, length($windc) - 1, 1) eq " ") { $windc = substr($windc, 0, length($windc) - 1); }
privmsg($src->{svr}, $src->{chan}, "Results for \2".$d->{observation_location}->{full}."\2 - \2Temperature:\2 ".$d->{temperature_string}." \2Wind Conditions:\2 ".$windc." \2Conditions:\2 ".$d->{weather});
privmsg($src->{svr}, $src->{chan}, "\2Heat index:\2 ".$d->{heat_index_string}." \2Humidity:\2 ".$d->{relative_humidity}." \2Pressure:\2 ".$d->{pressure_string}." - ".$d->{observation_time});
}
else {
# Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "Location not found.");
}
}
else {
# Otherwise, send an error message.
privmsg($src->{svr}, $src->{chan}, "An error occurred while retrieving your weather.");
}
ssssreturn 1;
return 1;
}
# Start initialization.