Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wikipedia: fix urlparse usage & handle Special: namespace #2575

Merged
merged 2 commits into from
Dec 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
wikipedia: special-case pages in Special:* namespace
Co-authored-by: dgw <dgw@technobabbl.es>
SnoopJ and dgw committed Dec 3, 2023
commit 43b56a42f86f24a888648c701bf7f5dd367f27a6
11 changes: 11 additions & 0 deletions sopel/builtins/wikipedia.py
Original file line number Diff line number Diff line change
@@ -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 section snippet if cite-note is linked
@@ -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: