Skip to content

Commit

Permalink
Merge pull request #2254 from sopel-irc/search-multisite-warnings
Browse files Browse the repository at this point in the history
search: consistently warn about excessive "site:" operators if no results
  • Loading branch information
dgw authored Feb 16, 2022
2 parents 4322aa4 + 7791f18 commit f7f2006
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions sopel/modules/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -149,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:
Expand Down

0 comments on commit f7f2006

Please sign in to comment.