From f23ca2246eac3da08ac29c983300f9e9e12d9050 Mon Sep 17 00:00:00 2001
From: Alexandre Morignot <erdnaxeli@gmail.com>
Date: Mon, 19 Aug 2013 19:34:39 +0200
Subject: [PATCH] we add the tags in lib::site::parser before the context

---
 PlayBot.pl          | 9 ++-------
 lib/sites/parser.pm | 4 ++++
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/PlayBot.pl b/PlayBot.pl
index affb21a..b556d7e 100755
--- a/PlayBot.pl
+++ b/PlayBot.pl
@@ -279,13 +279,8 @@ sub on_speak
         # if not, maybe there is an url we can parse
 	    my $id = sites::parser::parse(@args);
 
-        if ($id) {
-            # if yes, we need to save the new content's id
-	        $lastID{$chan->[0]} = $id;
-
-	        # we insert the potiential tags
-            commands::parser::tag($msg, $chan);
-        }
+        # if there is a new content, there is a new id to save
+        $lastID{$chan->[0]} = $id if ($id);
     }	
 }
 
diff --git a/lib/sites/parser.pm b/lib/sites/parser.pm
index 29eb1fb..e34a689 100644
--- a/lib/sites/parser.pm
+++ b/lib/sites/parser.pm
@@ -11,6 +11,7 @@ use mixcloud;
 use zippy;
 
 use lib "$FindBin::Bin/lib/";
+use commands::parser;
 use commands::tag;
 
 our $irc;
@@ -98,6 +99,9 @@ sub parse {
         $sth->execute($id, $chan->[0])
             or $log->error("Couldn't finish transaction: " . $dbh->errstr);
 
+	    # we insert the potiential tags
+        commands::parser::tag($msg, $chan);
+
         if (defined $content{'context'}) {
             commands::tag::addContext($id, $content{'context'});
         }
-- 
GitLab