From 7f4afc4a0de952d51850381d63803739f1c26097 Mon Sep 17 00:00:00 2001
From: Alexandre Morignot <erdnaxeli@cervoi.se>
Date: Thu, 14 May 2015 13:31:53 +0200
Subject: [PATCH] Fixes #18: we save last command ONLY if it's actually a
 command

---
 lib/commands/parser.pm | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/commands/parser.pm b/lib/commands/parser.pm
index 341cd1b..0d3638c 100644
--- a/lib/commands/parser.pm
+++ b/lib/commands/parser.pm
@@ -48,9 +48,6 @@ sub exec {
     if ($msg eq '!' and $command{lc $chan->[0]}) {
         $msg = $command{lc $chan->[0]};
     }
-    else {
-        $command{lc $chan->[0]} = $msg;
-    }
 
     if ($msg =~ /^ *!fav(?: (\S+))? *$/) {
         my $index = $1;
@@ -75,24 +72,25 @@ sub exec {
     elsif ($msg =~ /^( *!tag)(?:( +)(-?\d+))?/) {
         my $index = $3;
         my $id;
+        my $tags;
 
         if ($3) {
-            $msg = substr $msg, (length $1) + (length $2) + (length $3);
+            $tags = substr $msg, (length $1) + (length $2) + (length $3);
         }
         else {
-            $msg = substr $msg, (length $1) + (length $2);
+            $tags = substr $msg, (length $1) + (length $2);
         }
 
         try {
             $id = utils::id::get($chan->[0], $index);
-            commands::tag::exec($id, $msg);
+            commands::tag::exec($id, $tags);
         } catch {
             $irc->yield(privmsg => $chan->[0] => $insultes[rand @insultes]);
         };
     }
     elsif ($msg =~ /^( *!get)(?: +.*)?$/) {
-        $msg = substr $msg, (length $1) + 1;
-        my @args = ($chan, $msg);
+        my $query = substr $msg, (length $1) + 1;
+        my @args = ($chan, $query);
         my $id = commands::get::exec(@args);
 
         if ($id) {
@@ -119,6 +117,7 @@ sub exec {
         return 0;
     }
 
+    $command{lc $chan->[0]} = $msg;
     return 1;
 }
 
-- 
GitLab