From 3cfe22e5c14ee00f2e1d8a2a803b145cc40f786a Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Mon, 21 Mar 2011 14:20:19 -0600 Subject: [PATCH] More tabs = gone. --- modules/Badwords.pm | 4 ++-- modules/Bitly.pm | 12 ++++++------ modules/Calc.pm | 14 +++++++------- modules/FML.pm | 4 ++-- modules/IsItUp.pm | 14 +++++++------- modules/Weather.pm | 28 ++++++++++++++-------------- modules/unstable/UNO.pm | 10 ++++++++-- 7 files changed, 46 insertions(+), 40 deletions(-) diff --git a/modules/Badwords.pm b/modules/Badwords.pm index c8347fd..e7ebf3b 100644 --- a/modules/Badwords.pm +++ b/modules/Badwords.pm @@ -13,8 +13,8 @@ sub _init { # Check for required configuration values. if (!conf_get('badwords')) { - err(2, 'Please verify that you have a badwords block with word entries defined in your configuration file.', 0); - return; + err(2, 'Please verify that you have a badwords block with word entries defined in your configuration file.', 0); + return; } # Create the act_on_badword hook. hook_add('on_cprivmsg', 'act_on_badword', \&M::Badwords::actonbadword) or return; diff --git a/modules/Bitly.pm b/modules/Bitly.pm index a04b525..ec814aa 100644 --- a/modules/Bitly.pm +++ b/modules/Bitly.pm @@ -14,8 +14,8 @@ sub _init { # Check for required configuration values. if (!(conf_get('bitly:user'))[0][0] or !(conf_get('bitly:key'))[0][0]) { - err(2, 'Please verify that you have bitly_user and bitly_key defined in your configuration file.', 0); - return; + err(2, 'Please verify that you have bitly_user and bitly_key defined in your configuration file.', 0); + return; } # Create the SHORTEN and REVERSE commands. cmd_add('SHORTEN', 0, 0, \%M::Bitly::HELP_SHORTEN, \&M::Bitly::shorten) or return; @@ -68,9 +68,9 @@ sub shorten if ($response->is_success) { # If successful, decode the content. my $d = $response->decoded_content; - chomp $d; + chomp $d; # And send to channel. - privmsg($src->{svr}, $src->{chan}, "URL: ".$d); + privmsg($src->{svr}, $src->{chan}, "URL: ".$d); } else { # Otherwise, send an error message. @@ -104,13 +104,13 @@ sub reverse if ($response->is_success) { # If successful, decode the content. my $d = $response->decoded_content; - chomp $d; + chomp $d; # And send it to channel. privmsg($src->{svr}, $src->{chan}, "URL: ".$d); } else { # Otherwise, send an error message. - privmsg($src->{svr}, $src->{chan}, 'An error occurred while reversing your URL.'); + privmsg($src->{svr}, $src->{chan}, 'An error occurred while reversing your URL.'); } return 1; diff --git a/modules/Calc.pm b/modules/Calc.pm index 2e28787..bca221a 100644 --- a/modules/Calc.pm +++ b/modules/Calc.pm @@ -58,20 +58,20 @@ sub calc if ($response->is_success) { # If successful, decode the content. - my $d = $json->allow_nonref->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->decode($response->decoded_content); + my $d = $json->allow_nonref->relaxed->escape_slash->loose->allow_singlequote->allow_barekey->decode($response->decoded_content); - if ($d->{error} eq "" or $d->{error} == 0) { + if ($d->{error} eq "" or $d->{error} == 0) { # And send to channel privmsg($src->{svr}, $src->{chan}, "Result: ".$d->{lhs}." = ".$d->{rhs}); - } - else { + } + else { # Otherwise, send an error message. - privmsg($src->{svr}, $src->{chan}, "Google Calculator sent an error."); - } + privmsg($src->{svr}, $src->{chan}, "Google Calculator sent an error."); + } } else { # Otherwise, send an error message. - privmsg($src->{svr}, $src->{chan}, "An error occurred while sending your expression to Google Calculator."); + privmsg($src->{svr}, $src->{chan}, "An error occurred while sending your expression to Google Calculator."); } return 1; diff --git a/modules/FML.pm b/modules/FML.pm index f77ea22..17bab02 100644 --- a/modules/FML.pm +++ b/modules/FML.pm @@ -49,14 +49,14 @@ sub fml if ($rp->is_success) { # If successful, decode the content. my $d = $rp->decoded_content; - $d =~ s/(\n|\r)//g; + $d =~ s/(\n|\r)//g; # Get the FML. my (undef, $dfa) = split('Text: ', $d); my ($fml, undef) = split('Agree:', $dfa); # And send to channel. - privmsg($src->{svr}, $src->{chan}, "\002Random FML:\002 ".$fml); + privmsg($src->{svr}, $src->{chan}, "\002Random FML:\002 ".$fml); } else { # Otherwise, send an error message. diff --git a/modules/IsItUp.pm b/modules/IsItUp.pm index 0b9a6f4..30e0cff 100644 --- a/modules/IsItUp.pm +++ b/modules/IsItUp.pm @@ -44,25 +44,25 @@ sub check $ua->timeout(2); # Do we have enough parameters? if (!defined $argv[0]) { - notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.}); - return; + notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.}); + return; } my $curl = $argv[0]; # Does the URL start with http(s)? if ($curl !~ m/^http/) { - $curl = 'http://'.$curl; + $curl = 'http://'.$curl; } # Get the response via HTTP. my $response = $ua->get($curl); if ($response->is_success) { - # If successful, it's up. - privmsg($src->{svr}, $src->{chan}, $curl.' appears to be up from here.'); + # If successful, it's up. + privmsg($src->{svr}, $src->{chan}, $curl.' appears to be up from here.'); } else { - # Otherwise, it's down. - privmsg($src->{svr}, $src->{chan}, $curl.' appears to be down from here.'); + # Otherwise, it's down. + privmsg($src->{svr}, $src->{chan}, $curl.' appears to be down from here.'); } return 1; diff --git a/modules/Weather.pm b/modules/Weather.pm index 2f75daf..4262c84 100644 --- a/modules/Weather.pm +++ b/modules/Weather.pm @@ -45,8 +45,8 @@ sub weather $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; + notice($src->{svr}, $src->{nick}, trans('Not enough parameters')."."); + return; } my $loc = join(' ', @args); $loc =~ s/ /%20/g; @@ -56,22 +56,22 @@ sub weather if ($response->is_success) { # If successful, decode the content. - my $d = XMLin($response->decoded_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.'); - } + 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.'); + privmsg($src->{svr}, $src->{chan}, 'An error occurred while retrieving your weather.'); } return 1; diff --git a/modules/unstable/UNO.pm b/modules/unstable/UNO.pm index 7a8ea9d..93e022d 100644 --- a/modules/unstable/UNO.pm +++ b/modules/unstable/UNO.pm @@ -200,8 +200,8 @@ sub cmd_uno { # Check for at least two players. if (keys %PLAYERS < 2) { - notice($src->{svr}, $src->{nick}, 'Two players are required to play.'); - return; + # Not found, join the bot. + _botjoin(); } # Deal the cards. @@ -1166,6 +1166,12 @@ sub _delplyr { return 1; } +# Join the bot to a game. +sub _botjoin { + $PLAYERS{lc $src->{nick}} = []; + $NICKS{lc $src->{nick}} = $src->{nick}; +} + # For when a player has won. sub _gameover { my ($player) = @_;