From 950aa6efb84d1fa699242f337f828923a692b13f Mon Sep 17 00:00:00 2001
From: Alexandre Morignot <erdnaxeli@cervoi.se>
Date: Wed, 11 Feb 2015 18:21:09 +0100
Subject: [PATCH] !get suggets (or not) a global query if there is no local
 results

---
 lib/commands/get.pm | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/commands/get.pm b/lib/commands/get.pm
index 87dcdbe..b7ec425 100644
--- a/lib/commands/get.pm
+++ b/lib/commands/get.pm
@@ -31,7 +31,27 @@ sub exec {
             $irc->yield(privmsg => $chan => "Tu tournes en rond, Jack !");
         }
         elsif (@{$query->words} or @{$query->tags}) {
-            $irc->yield(privmsg => $chan => "Je n'ai rien dans ce registre.");
+            $msg = "Je n'ai rien dans ce registre.";
+
+            if (not $query->is_global) {
+                # we check is there is result with global
+                my $q = commands::get::query->new(
+                    chan => $query->chan,
+                    query  => $query->query . ' -a'
+                );
+
+                my $rows = $db_query->get_rows($q);
+                if ($rows > 0) {
+                    $msg .= ' ' . $rows . ' résultat';
+                    $msg .= 's' if ($rows > 1);
+                    $msg .= ' trouvé';
+                    $msg .= 's' if ($rows > 1);
+                    $msg .= ' avec une recherche globale.';
+                }
+
+            }
+
+            $irc->yield(privmsg => $chan => $msg);
         }
         else {
             $irc->yield(privmsg => $chan => "Poste d'abord du contenu, n00b.");
-- 
GitLab