Skip to content
Extraits de code Groupes Projets
Valider df73cf13 rédigé par Alexandre Morignot's avatar Alexandre Morignot Validation de Animation des soirees
Parcourir les fichiers

gestion des id des vidéos déjà envoyées

parent 7ebc0332
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -135,8 +135,9 @@ sub on_query ...@@ -135,8 +135,9 @@ sub on_query
{ {
my ($user,$msg) = @_[ARG0, ARG2]; my ($user,$msg) = @_[ARG0, ARG2];
my ($nick) = split (/!/,$user); my ($nick) = split (/!/,$user);
print $msg."\n";
if ($msg =~ m/^!/ && $user eq $admin) { if ($msg =~ m/^!/ && $nick eq $admin) {
my $commande = ( $msg =~ m/^!([^ ]*)/ )[0]; my $commande = ( $msg =~ m/^!([^ ]*)/ )[0];
my @params = grep {!/^\s*$/} split(/\s+/, substr($msg, length("!$commande"))); my @params = grep {!/^\s*$/} split(/\s+/, substr($msg, length("!$commande")));
...@@ -254,11 +255,24 @@ sub on_speak ...@@ -254,11 +255,24 @@ sub on_speak
or $log->error("Couldn't finish transaction: " . $dbh->errstr); or $log->error("Couldn't finish transaction: " . $dbh->errstr);
} }
# sélection de l'id de la vidéo insérée
my $id = $dbh->{mysql_insert_id};
if (!$id) {
my $sth = $dbh->prepare_cached('SELECT id FROM playbot WHERE url = ?');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth);
$sth->execute($content{'url'})
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
$id = $sth->fetch->[0];
}
# message sur irc
if (defined $content{'author'}) { if (defined $content{'author'}) {
$irc->yield(privmsg => $chan => '['.$dbh->{mysql_insertid}.'] '.$content{'title'}.' | '.$content{'author'}) ; $irc->yield(privmsg => $chan => '['.$id.'] '.$content{'title'}.' | '.$content{'author'}) ;
} }
else { else {
$irc->yield(privmsg => $chan => '['.$dbh->{mysql_insertid}.'] '.$content{'title'}) ; $irc->yield(privmsg => $chan => '['.$id.'] '.$content{'title'}) ;
} }
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter