diff --git a/PlayBot/commands/fav.pm b/PlayBot/commands/fav.pm index cc8f3a6566fbaa0978a816ada620f261afc9bedc..3eee6babb176f48d49416d0bc4a9ae6243a3871f 100644 --- a/PlayBot/commands/fav.pm +++ b/PlayBot/commands/fav.pm @@ -1,5 +1,8 @@ package PlayBot::commands::fav; +use strict; +use warnings; + our $dbh; our $log; our $irc; diff --git a/PlayBot/commands/get/query.pm b/PlayBot/commands/get/query.pm index c32989f76ef490702d17cd11e7c224b4053d51d9..40b7871a0a738e754820231d19ff0ce48e38d784 100644 --- a/PlayBot/commands/get/query.pm +++ b/PlayBot/commands/get/query.pm @@ -1,5 +1,8 @@ package PlayBot::commands::get::query; +use strict; +use warnings; + use Moose; use overload '~~' => \&_equals; use Scalar::Util qw(looks_like_number); diff --git a/PlayBot/commands/later.pm b/PlayBot/commands/later.pm index 55c088dc3ef4a3227722760b4c7ab1b344f48b5a..26eef73dcaee743c6cb9683ef09773fbb3b12af1 100644 --- a/PlayBot/commands/later.pm +++ b/PlayBot/commands/later.pm @@ -1,5 +1,8 @@ package PlayBot::commands::later; +use strict; +use warnings; + our $dbh; our $log; diff --git a/PlayBot/commands/parser.pm b/PlayBot/commands/parser.pm index e692b6482d9052a2b2ddddf3175693c7d0447180..35c97605070e262f864989610f35645594d61410 100644 --- a/PlayBot/commands/parser.pm +++ b/PlayBot/commands/parser.pm @@ -1,6 +1,7 @@ package PlayBot::commands::parser; use strict; +use warnings; use Try::Tiny; use PlayBot::commands::fav; @@ -89,8 +90,8 @@ sub exec { $irc->yield(privmsg => $chan => $insultes[rand @insultes]); }; } - elsif ($msg =~ /^( *!get)(?: +.*)?$/) { - my $query = substr $msg, (length $1) + 1; + elsif ($msg =~ /^( *!get)( +.*)?$/) { + my $query = $2; my @args = ($chan, $query); my $id = PlayBot::commands::get::exec(@args); diff --git a/PlayBot/commands/tag.pm b/PlayBot/commands/tag.pm index 719ae8779e72b7eaf3933f2672f8a4470df53c6a..0ca69b8ca25757ec878d66520975f89fdac34aa2 100644 --- a/PlayBot/commands/tag.pm +++ b/PlayBot/commands/tag.pm @@ -1,5 +1,8 @@ package PlayBot::commands::tag; +use strict; +use warnings; + our $dbh; our $log; diff --git a/PlayBot/sessions/irc.pm b/PlayBot/sessions/irc.pm index 6a3d4c192f7bb2730613dbb3d658d80bd9497b5e..5035739b3c41e5d6a145db0fdb18bb13d2933037 100644 --- a/PlayBot/sessions/irc.pm +++ b/PlayBot/sessions/irc.pm @@ -49,7 +49,7 @@ my $debug = 0; # mode debug if ($#ARGV + 1) { - @channels = qw(#hormone); + @channels = ('#hormone'); $nick = 'kikoo'; $debug = 1; } diff --git a/PlayBot/sessions/irc/later.pm b/PlayBot/sessions/irc/later.pm index 993dd6b3efdaae038ab0eef4e4dd0863591c3d4f..20f9677ea37feb25d35d2461a1b229becdaadecc 100644 --- a/PlayBot/sessions/irc/later.pm +++ b/PlayBot/sessions/irc/later.pm @@ -1,5 +1,8 @@ package PlayBot::sessions::irc::later; +use strict; +use warnings; + use PlayBot::commands::get; sub consume @@ -7,7 +10,7 @@ sub consume my ($nick, $id, $chan_src) = @_; my @args = ($nick, $id, $chan_src); - commands::get::exec(@args); + PlayBot::commands::get::exec(@args); } 1; diff --git a/PlayBot/sites/dailymotion.pm b/PlayBot/sites/dailymotion.pm index c1f0c52e8132dbb7e3c45cc3352b9cc93fd5233c..5a14fb8183dfca25e2c8f78a8aa4be7f4ac5c790 100644 --- a/PlayBot/sites/dailymotion.pm +++ b/PlayBot/sites/dailymotion.pm @@ -1,5 +1,8 @@ package PlayBot::sites::dailymotion; +use strict; +use warnings; + use Inline Python => 'DATA'; sub get { diff --git a/PlayBot/sites/mixcloud.pm b/PlayBot/sites/mixcloud.pm index 1825a68f3696dce8a7b3e0be58d995448dc82b82..0b9bdb30635320579e069aa4fe5d5945d1968ef1 100644 --- a/PlayBot/sites/mixcloud.pm +++ b/PlayBot/sites/mixcloud.pm @@ -1,5 +1,8 @@ package PlayBot::sites::mixcloud; +use strict; +use warnings; + use LWP::UserAgent; use JSON; use Encode; @@ -7,7 +10,6 @@ use Encode; sub get { my ($url) = @_; $url =~ s/www/api/; - my %infos; my $ua = LWP::UserAgent->new( timeout => 30, @@ -16,13 +18,15 @@ sub get { my $response = $ua->get($url); die($response->status_line) unless ($response->is_success); - $content = decode_json(encode('UTF-8', $response->decoded_content)); - $infos{'title'} = $content->{'name'}; - $infos{'author'} = $content->{'user'}->{'name'}; - $infos{'url'} = $content->{'url'}; - $infos{'duration'} = $content->{'audio_length'}; + my $content = decode_json(encode('UTF-8', $response->decoded_content)); + my $infos = { + title => $content->{'name'}, + author => $content->{'user'}->{'name'}, + url => $content->{'url'}, + duration => $content->{'audio_length'}, + }; - return %infos; + return %{ $infos }; } 1; diff --git a/PlayBot/sites/parser.pm b/PlayBot/sites/parser.pm index 24e9383139b6cce74f121edf56640cd8b9df9c75..f3759822ab24b7e63c48624cd3ac9d69c614d767 100644 --- a/PlayBot/sites/parser.pm +++ b/PlayBot/sites/parser.pm @@ -76,8 +76,13 @@ sub parse { '); $log->error("Couldn't prepare querie; aborting") unless (defined $sth); - $sth->execute($content{'site'}, $content{'url'}, - $content{'author'}, $content{'title'}, $content{'duration'}); + $sth->execute( + $content{'site'}, + $content{'url'}, + $content{'author'}, + $content{'title'}, + $content{'duration'} + ); }; if ($@) { # seems to be already present in database @@ -110,7 +115,7 @@ sub parse { $id = $sth->fetch->[0]; # insertion du chan - my $sth = $dbh->prepare(' + $sth = $dbh->prepare(' INSERT INTO playbot_chan (content, chan, sender_irc) VALUES (?,?,?)'); $log->error("Couldn't prepare querie; aborting") unless (defined $sth); diff --git a/PlayBot/sites/soundcloud.pm b/PlayBot/sites/soundcloud.pm index 99458725c3ce7aef0af86379334e23c26e510256..8d2e831cc53d13df5a3d2d76962cc07be509bf7b 100644 --- a/PlayBot/sites/soundcloud.pm +++ b/PlayBot/sites/soundcloud.pm @@ -1,5 +1,8 @@ package PlayBot::sites::soundcloud; +use strict; +use warnings; + use LWP::UserAgent; use JSON; use URI::Find; @@ -19,17 +22,19 @@ sub get { my $response = $ua->get($root.'/resolve.json?url='.$url.'&client_id='.$clientId); die($response->status_line) unless ($response->is_success); - $content = decode_json($response->decoded_content); - $infos{'title'} = $content->{'title'}; - $infos{'author'} = $content->{'user'}->{'username'}; - $infos{'duration'} = $content->{'duration'} / 1000; - $infos{'url'} = $url; + my $content = decode_json($response->decoded_content); + my $infos = { + title => $content->{'title'}, + author => $content->{'user'}->{'username'}, + duration => $content->{'duration'} / 1000, + url => $url, + }; if ($content->{'downloadable'}) { - $infos{'ddl'} = $content->{'download_url'}; + $infos->{'ddl'} = $content->{'download_url'}; } - return %infos; + return %{ $infos }; } 1; diff --git a/PlayBot/sites/youtube.pm b/PlayBot/sites/youtube.pm index b6cd65f6a92582160aff68334cdc2b9fed0798f3..b43744a3fce898200c46f181e906460c5f32253c 100644 --- a/PlayBot/sites/youtube.pm +++ b/PlayBot/sites/youtube.pm @@ -1,5 +1,8 @@ package PlayBot::sites::youtube; +use strict; +use warnings; + use LWP::UserAgent; use JSON; use FindBin; @@ -37,9 +40,9 @@ sub get { $video->{'contentDetails'}->{'duration'} =~ /PT((?<h>\d+)H)?((?<m>\d+)M)?((?<s>\d+)S)?/; # default values - my ($h) = ($+{'h'}, 0); - my ($m) = ($+{'m'}, 0); - my ($s) = ($+{'s'}, 0); + my ($h) = $+{'h'} || 0; + my ($m) = $+{'m'} || 0; + my ($s) = $+{'s'} || 0; # there is one more second, don't know why $infos{'duration'} = $h*3600 + $m*60 + $s - 1; diff --git a/PlayBot/sites/zippy.pm b/PlayBot/sites/zippy.pm index e6ecee6899abeef4dfb591f2a9169148443f1cce..359765cc16843b17a7a97a0cccbe56bf446483bb 100644 --- a/PlayBot/sites/zippy.pm +++ b/PlayBot/sites/zippy.pm @@ -1,5 +1,8 @@ package PlayBot::sites::zippy; +use strict; +use warnings; + use LWP::UserAgent; use HTML::Parser; use HTML::Entities; diff --git a/PlayBot/utils/db/get.pm b/PlayBot/utils/db/get.pm index 03139d42d728940e31e8bd1a279c5b38dfec0a5f..73b3568781e4102c9dd3864f129e6ad3dc7a1f09 100644 --- a/PlayBot/utils/db/get.pm +++ b/PlayBot/utils/db/get.pm @@ -1,5 +1,8 @@ package PlayBot::utils::db::get; +use strict; +use warnings; + use feature 'state'; use Moose; diff --git a/PlayBot/utils/db/stats.pm b/PlayBot/utils/db/stats.pm index 166fbc83e02dfcbbdaf5adef69271e5691274d88..2a069ee58cda6c5862c60c07051f5bed9942036e 100644 --- a/PlayBot/utils/db/stats.pm +++ b/PlayBot/utils/db/stats.pm @@ -1,5 +1,8 @@ package PlayBot::utils::db::stats; +use strict; +use warnings; + use Moose; use FindBin; use List::Util qw( reduce ); diff --git a/PlayBot/utils/id.pm b/PlayBot/utils/id.pm index e9d9d59ccf3241576881d08780fa4a85877a4cf0..465848e085156b651520639d0d23383887360ff5 100644 --- a/PlayBot/utils/id.pm +++ b/PlayBot/utils/id.pm @@ -1,6 +1,8 @@ package PlayBot::utils::id; use strict; +use warnings; + use Scalar::Util qw(looks_like_number); # Used to get a proper id from an index. diff --git a/PlayBot/utils/print.pm b/PlayBot/utils/print.pm index 4c31ecb08df658093fe8bb6bc4ba826908300013..077730ad4cac0538cd893bfa2398496ea551e4a3 100644 --- a/PlayBot/utils/print.pm +++ b/PlayBot/utils/print.pm @@ -1,6 +1,7 @@ package PlayBot::utils::print; use strict; +use warnings; use IRC::Utils qw(YELLOW ORANGE GREEN NORMAL LIGHT_BLUE GREY);