diff --git a/sopel/modules/pronouns.py b/sopel/modules/pronouns.py index 6662b4012..e8a73927d 100644 --- a/sopel/modules/pronouns.py +++ b/sopel/modules/pronouns.py @@ -15,7 +15,6 @@ from sopel.config import types -BACKEND = 'https://pronouns.sopel.chat' LOGGER = logging.getLogger(__name__) @@ -23,21 +22,34 @@ class PronounsSection(types.StaticSection): fetch_complete_list = types.BooleanAttribute('fetch_complete_list', default=True) """Whether to attempt fetching the complete list the web backend uses, at bot startup.""" + link_base_url = types.ValidatedAttribute( + 'link_base_url', default='https://pronouns.sopel.chat') + """Base URL for links to pronoun info. + + Defaults to an instance of https://github.com/sopel-irc/pronoun-service + hosted by the Sopel project, but it's easy to make your own instance + available at a custom domain using one of many free static site hosts. + """ + def configure(settings): """ | name | example | purpose | | ---- | ------- | ------- | | fetch_complete_list | True | Whether to attempt fetching the complete pronoun list from the web backend at startup. | + | link_base_url | https://pronouns.sopel.chat | Base URL for pronoun info links. | """ settings.define_section('pronouns', PronounsSection) settings.pronouns.configure_setting( 'fetch_complete_list', 'Fetch the most current list of pronoun sets at startup?') + settings.pronouns.configure_setting( + 'link_base_url', + 'Base URL for pronoun info links:') def setup(bot): - bot.config.define_section('pronouns', PronounsSection) + bot.settings.define_section('pronouns', PronounsSection) # Copied from svelte-pronounisland, leaving a *lot* out. # If ambiguous, the earlier one will be used. @@ -56,7 +68,7 @@ def setup(bot): 'ey/em': 'ey/em/eir/eirs/eirself', } - if not bot.config.pronouns.fetch_complete_list: + if not bot.settings.pronouns.fetch_complete_list: return # and now try to get the current list our fork of the backend uses @@ -142,7 +154,7 @@ def pronouns(bot, trigger): say_pronouns(bot, trigger.nick, pronouns) else: bot.reply("I don't know your pronouns! You can set them with " - "{}setpronouns".format(bot.config.core.help_prefix)) + "{}setpronouns".format(bot.settings.core.help_prefix)) else: pronouns = bot.db.get_nick_value(trigger.group(3), 'pronouns') if pronouns: @@ -152,12 +164,12 @@ def pronouns(bot, trigger): # gender, but likeā€¦ it's a bot. bot.say( "I am a bot. Beep boop. My pronouns are it/it/its/its/itself. " - "See {}/it for examples.".format(BACKEND) + "See {}/it for examples.".format(bot.settings.pronouns.link_base_url) ) else: bot.reply("I don't know {}'s pronouns. They can set them with " "{}setpronouns".format(trigger.group(3), - bot.config.core.help_prefix)) + bot.settings.core.help_prefix)) def say_pronouns(bot, nick, pronouns): @@ -167,11 +179,11 @@ def say_pronouns(bot, nick, pronouns): short = pronouns bot.say( - "{nick}'s pronouns are {pronouns}. See {BACKEND}/{short} for examples." + "{nick}'s pronouns are {pronouns}. See {base_url}/{short} for examples." .format( nick=nick, pronouns=pronouns, - BACKEND=BACKEND, + base_url=bot.settings.pronouns.link_base_url, short=short, ) )