Skip to content

Commit f7f2006

Browse files
authored
Merge pull request #2254 from sopel-irc/search-multisite-warnings
search: consistently warn about excessive "site:" operators if no results
2 parents 4322aa4 + 7791f18 commit f7f2006

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

sopel/modules/search.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ def bing(bot, trigger):
134134
if result:
135135
bot.say(result)
136136
else:
137-
bot.reply("No results found for '%s'." % query)
137+
msg = "No results found for '%s'." % query
138+
if query.count('site:') >= 2:
139+
# This check exists because of issue #1415. The git.io link will take the user there.
140+
# (Better a sopel.chat link, but it's not set up to do that. This is shorter anyway.)
141+
msg += " Try again with at most one 'site:' operator. See https://git.io/fpKtP for why."
142+
bot.reply(msg)
138143

139144

140145
@plugin.command('search')
@@ -149,7 +154,15 @@ def search(bot, trigger):
149154
bu = bing_search(query) or '-'
150155
du = duck_search(query) or '-'
151156

152-
if bu == du:
157+
if bu == '-' and du == '-':
158+
msg = "No results found for '%s'." % query
159+
if query.count('site:') >= 2:
160+
# This check exists because of issue #1415. The git.io link will take the user there.
161+
# (Better a sopel.chat link, but it's not set up to do that. This is shorter anyway.)
162+
msg += " Try again with at most one 'site:' operator. See https://git.io/fpKtP for why."
163+
bot.reply(msg)
164+
return
165+
elif bu == du:
153166
result = '%s (b, d)' % bu
154167
else:
155168
if len(bu) > 150:

0 commit comments

Comments
 (0)