From c9dd730f52c2c1008032fc979df0b87b2edf9b42 Mon Sep 17 00:00:00 2001 From: dgw Date: Wed, 16 Feb 2022 15:18:05 -0600 Subject: [PATCH] Backport pull request #2254 search: consistently warn about excessive "site:" operators if no results --- sopel/modules/search.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sopel/modules/search.py b/sopel/modules/search.py index 91804328ef..847c71b171 100644 --- a/sopel/modules/search.py +++ b/sopel/modules/search.py @@ -135,7 +135,12 @@ def bing(bot, trigger): if result: bot.say(result) else: - bot.reply("No results found for '%s'." % query) + msg = "No results found for '%s'." % query + if query.count('site:') >= 2: + # This check exists because of issue #1415. The git.io link will take the user there. + # (Better a sopel.chat link, but it's not set up to do that. This is shorter anyway.) + msg += " Try again with at most one 'site:' operator. See https://git.io/fpKtP for why." + bot.reply(msg) @plugin.command('search') @@ -150,7 +155,15 @@ def search(bot, trigger): bu = bing_search(query) or '-' du = duck_search(query) or '-' - if bu == du: + if bu == '-' and du == '-': + msg = "No results found for '%s'." % query + if query.count('site:') >= 2: + # This check exists because of issue #1415. The git.io link will take the user there. + # (Better a sopel.chat link, but it's not set up to do that. This is shorter anyway.) + msg += " Try again with at most one 'site:' operator. See https://git.io/fpKtP for why." + bot.reply(msg) + return + elif bu == du: result = '%s (b, d)' % bu else: if len(bu) > 150: