From 82387d8b0cf037de2abd3dac84c01b358dc324d3 Mon Sep 17 00:00:00 2001 From: dgw Date: Fri, 11 Feb 2022 19:34:13 -0600 Subject: [PATCH 1/2] search: warn about excessive "site:" operators if no Bing result found Parity with DuckDuckGo behavior, since both search engines can return weird (or no) results if too many such operators are combined. --- sopel/modules/search.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sopel/modules/search.py b/sopel/modules/search.py index 15f7ad1f00..6f8cb15d55 100644 --- a/sopel/modules/search.py +++ b/sopel/modules/search.py @@ -134,7 +134,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') From 7791f18c8a1eaae7da3670b05021e8907cbe784b Mon Sep 17 00:00:00 2001 From: dgw Date: Fri, 11 Feb 2022 19:36:57 -0600 Subject: [PATCH 2/2] search: warn for no results w/multiple "site:" operators in combo search Just seems best to be consistent across all commands. --- sopel/modules/search.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sopel/modules/search.py b/sopel/modules/search.py index 6f8cb15d55..a63caa5070 100644 --- a/sopel/modules/search.py +++ b/sopel/modules/search.py @@ -154,7 +154,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: