From 216daee8ee7b2e1780220c54ab1b432ae2168ca5 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Tue, 11 Dec 2012 16:55:23 +0100 Subject: [PATCH] nouvelle fonction addTag --- PlayBot.pl | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/PlayBot.pl b/PlayBot.pl index c3d4374..0e7be2f 100755 --- a/PlayBot.pl +++ b/PlayBot.pl @@ -97,6 +97,18 @@ sub flux } +sub addTag +{ + my ($id, $tag) = @_; + + my $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag) VALUES (?, ?)'); + $log->error("Couldn't prepare querie; aborting") unless (defined $sth); + + $sth->execute($id, $tag) + or $log->error("Couldn't finish transaction: " . $dbh->errstr); +} + + sub later { my ($nick, $id) = @_[ARG0,ARG1]; @@ -328,12 +340,8 @@ sub on_speak next; } - my $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag) VALUES (?, ?)'); - $log->error("Couldn't prepare querie; aborting") unless (defined $sth); - - $sth->execute($id, $1) - or $log->error("Couldn't finish transaction: " . $dbh->errstr); - } + addTag ($lastID, $1); + } # message sur irc -- GitLab