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: remove deprecated lang_per_channel config setting #2142

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Changes from all commits
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
38 changes: 15 additions & 23 deletions sopel/modules/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ def get_result(self):
class WikipediaSection(types.StaticSection):
default_lang = types.ValidatedAttribute('default_lang', default='en')
"""The default language to find articles from (same as Wikipedia language subdomain)."""
lang_per_channel = types.ValidatedAttribute('lang_per_channel')
"""List of ``#channel:langcode`` pairs to define Wikipedia language per channel.

Deprecated: Will be removed in Sopel 8. Use ``.wpclang`` to manage per-channel language settings.
"""


def setup(bot):
Expand Down Expand Up @@ -119,12 +114,6 @@ def choose_lang(bot, trigger):
if channel_lang:
return channel_lang

if bot.config.wikipedia.lang_per_channel:
customlang = re.search('(' + trigger.sender + r'):(\w+)',
bot.config.wikipedia.lang_per_channel)
if customlang is not None:
return customlang.group(2)

return bot.config.wikipedia.default_lang


Expand Down Expand Up @@ -288,12 +277,13 @@ def wplang(bot, trigger):
bot.config.wikipedia.default_lang)
)
)
else:
bot.db.set_nick_value(trigger.nick, 'wikipedia_lang', trigger.group(3))
bot.reply(
"Set your Wikipedia language to: {}"
.format(trigger.group(3))
)
return

bot.db.set_nick_value(trigger.nick, 'wikipedia_lang', trigger.group(3))
bot.reply(
"Set your Wikipedia language to: {}"
.format(trigger.group(3))
)


@plugin.command('wpclang')
Expand All @@ -304,6 +294,7 @@ def wpclang(bot, trigger):
if not (trigger.admin or bot.channels[trigger.sender.lower()].privileges[trigger.nick.lower()] >= plugin.OP):
bot.reply("You don't have permission to change this channel's Wikipedia language setting.")
return plugin.NOLIMIT

if not trigger.group(3):
bot.say(
"{}'s current Wikipedia language is: {}"
Expand All @@ -314,9 +305,10 @@ def wpclang(bot, trigger):
bot.config.wikipedia.default_lang)
)
)
else:
bot.db.set_channel_value(trigger.sender, 'wikipedia_lang', trigger.group(3))
bot.say(
"Set {}'s Wikipedia language to: {}"
.format(trigger.sender, trigger.group(3))
)
return

bot.db.set_channel_value(trigger.sender, 'wikipedia_lang', trigger.group(3))
bot.say(
"Set {}'s Wikipedia language to: {}"
.format(trigger.sender, trigger.group(3))
)