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

!later

parent 2961bd42
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -59,7 +59,8 @@ POE::Session->create( ...@@ -59,7 +59,8 @@ POE::Session->create(
irc_public => \&on_speak, irc_public => \&on_speak,
irc_msg => \&on_query, irc_msg => \&on_query,
irc_notice => \&on_notice, irc_notice => \&on_notice,
_flux => \&flux _flux => \&flux,
_later => \&later
}, },
); );
...@@ -88,6 +89,20 @@ sub flux ...@@ -88,6 +89,20 @@ sub flux
} }
sub later
{
my ($nick, $id) = @_[ARG0,ARG1];
my $sth = $dbh->prepare_cached('SELECT url FROM playbot WHERE id = ?');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth);
$sth->execute($id)
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
$irc->yield(privmsg => $nick => $sth->fetch->[0]) if ($sth->rows);
}
sub cycle sub cycle
{ {
my ($arg) = @_; my ($arg) = @_;
...@@ -227,7 +242,7 @@ sub on_speak ...@@ -227,7 +242,7 @@ sub on_speak
eval { %content = zippy($url) }; eval { %content = zippy($url) };
$site = 'zippyshare'; $site = 'zippyshare';
} }
elsif ($msg =~ /!fav ([0-9]+)/) { elsif ($msg =~ /^!fav ([0-9]+)/) {
my $sth = $dbh->prepare_cached('SELECT user FROM playbot_codes WHERE nick = ?'); my $sth = $dbh->prepare_cached('SELECT user FROM playbot_codes WHERE nick = ?');
$sth->execute($nick) $sth->execute($nick)
or $log->error("Couldn't finish transaction: " . $dbh->errstr); or $log->error("Couldn't finish transaction: " . $dbh->errstr);
...@@ -243,6 +258,14 @@ sub on_speak ...@@ -243,6 +258,14 @@ sub on_speak
return; return;
} }
elsif ($msg =~ /^!later( ([0-9]*)( in ([0-9]*)(h|m)?)?)?/) {
my ($id, $time, $unit) = ($2, $4, $5);
$time *= ($unit eq 'm') ? 60 : 3600;
$kernel->delay_set('_later', 3, $nick, $id);
return;
}
else { else {
return; return;
} }
......
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