Skip to content

Commit

Permalink
wikipedia: special-case pages in Special:* namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
SnoopJ committed Nov 29, 2023
1 parent 4b4b118 commit 9c4c113
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sopel/builtins/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ def mw_info(bot, trigger, match=None):
article = unquote(page_info.path)[trim_offset:]
section = unquote(page_info.fragment)

if article.startswith("Special:"):
# The MediaWiki query API does not include pages in the Special:*
# namespace, so there's no point bothering when we know this will error
LOGGER.debug("Ignoring page in Special:* namespace")
return False

if section:
if section.startswith('cite_note-'):
# Don't bother trying to retrieve a snippet when cite-note is linked
Expand Down Expand Up @@ -367,6 +373,11 @@ def wikipedia(bot, trigger):
if not query:
bot.reply('What do you want me to look up?')
return plugin.NOLIMIT

if query.startswith("Special:"):
bot.reply("Sorry, the MediaWiki API doesn't support querying the Special:* namespace")
return False

server = lang + '.wikipedia.org'
query = mw_search(server, query, 1)
if not query:
Expand Down

0 comments on commit 9c4c113

Please sign in to comment.