From 2961bd42dd9fefd1da74cf56b3d6602e4147597e Mon Sep 17 00:00:00 2001
From: Alexandre Morignot <erdnaxeli@gmail.com>
Date: Thu, 8 Nov 2012 12:52:44 +0100
Subject: [PATCH] Tag : support des majuscules, du tiret et du tiret bas

---
 PlayBot.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/PlayBot.pl b/PlayBot.pl
index 991e018..64d0a5f 100755
--- a/PlayBot.pl
+++ b/PlayBot.pl
@@ -256,6 +256,8 @@ sub on_speak
 		$log->debug($content{'url'});
 	}
 	else {
+		# insertion de la vidéo dans la bdd
+
 		my $sth = $dbh->prepare_cached('INSERT INTO playbot (date, type, url, sender_irc, sender, title, chan) VALUES (NOW(),?,?,?,?,?,?)');
 		$log->error("Couldn't prepare querie; aborting") unless (defined $sth);
 
@@ -275,6 +277,18 @@ sub on_speak
 		$id = $sth->fetch->[0];
 	}
 
+
+	# insertion des éventuels tags
+	while ($msg =~ /#([a-zA-Z_-]*)/g) {
+		next if (!$1);
+		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);
+	}
+
+
 	# message sur irc
 	if (defined $content{'author'}) {
 		$irc->yield(privmsg => $chan => '['.$id.'] '.$content{'title'}.' | '.$content{'author'}) ;
-- 
GitLab