Skip to content

Commit

Permalink
Merge pull request #2142 from sopel-irc/remove-old-wikipedia-lang
Browse files Browse the repository at this point in the history
wikipedia: remove deprecated `lang_per_channel` config setting
  • Loading branch information
dgw authored Aug 24, 2021
2 parents f76d771 + debf64d commit 5d9b1c3
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions sopel/modules/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,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 @@ -143,12 +138,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 @@ -317,12 +306,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 @@ -333,6 +323,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 @@ -343,9 +334,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))
)

0 comments on commit 5d9b1c3

Please sign in to comment.