diff --git a/PlayBot/sessions/irc.pm b/PlayBot/sessions/irc.pm index f78870b7d19f4ab4d3d8ecaff0083037a8c17a9b..2a9c21ab9f7e6b4348acb9c43654182c707c3b43 100644 --- a/PlayBot/sessions/irc.pm +++ b/PlayBot/sessions/irc.pm @@ -120,6 +120,7 @@ sub setConf $PlayBot::sites::irc = $irc; $PlayBot::sites::log = $log; + $PlayBot::sites::playbot_api_key = $conf->{'playbot_api_key'}; $PlayBot::sites::soundcloud::clientSecret = $conf->{'soundcloud_secret'}; } diff --git a/PlayBot/sites.pm b/PlayBot/sites.pm index 4e36d00fc6ce4ef69e192c041da189de1e283291..8ee207d33ac13fb764b9b19c5ea06f64db413e4f 100644 --- a/PlayBot/sites.pm +++ b/PlayBot/sites.pm @@ -4,6 +4,8 @@ use strict; use warnings; use utf8; +use LWP::UserAgent; +use JSON; use Module::Pluggable sub_name => 'sites', search_path => ['PlayBot::sites'], require => 1; use Storable qw(dclone); @@ -15,12 +17,33 @@ use PlayBot::commands::parser; our $irc; our $log; our $regex; +our $playbot_api_key; sub parse { my ($kernel, $user, $chan, $msg, $playlist) = @_; my ($nick,$mask) = split(/!/,$user); + my $ua = LWP::UserAgent->new( + timeout => 2, + env_proxy => 0, + ); + my $response = $ua->post( + "http://cloud.cervoi.se:12345/rpc", + "X-PLAYBOT-KEY" => $playbot_api_key, + Content => encode_json {"channel" => $chan, "user" => $nick, "value" => $msg}, + ); + if ($response->is_success) + { + $log->info("Handled by scala"); + $irc->yield(privmsg => $chan => $response->decoded_content); + return; + } + else + { + $log->info($response->code. " still perl job"); + } + my $chan_conf = PlayBot::utils::db::chan->new($chan); my %content; @@ -106,7 +129,7 @@ sub insert_content ); }; if ($@) { - # seems to be already present in database + # seems to be already present in database $new = 0; my $sth = $dbh->prepare(' diff --git a/README.md b/README.md index ff7c183390e58a03fc7a7b2e02763f03ba392e4e..09d5d0d836d2d6e39d880e32dc8b61fa396e14a6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # PlayBot +## DEPRECATED + +Tous les commits après le tag v1.0.0 visent à migrer progressivement les features du PlayBot en Perl vers une réécriture en Scala. + ## Description