Skip to content

Commit

Permalink
pronouns: add killswitch for startup fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed May 10, 2022
1 parent 7a4ec45 commit 41b7a13
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions sopel/modules/pronouns.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,32 @@
import requests

from sopel import plugin
from sopel.config import types


LOGGER = logging.getLogger(__name__)


class PronounsSection(types.StaticSection):
fetch_complete_list = types.BooleanAttribute('fetch_complete_list', default=True)
"""Whether to attempt fetching the complete list pronoun.is uses, at bot startup."""


def configure(settings):
"""
| name | example | purpose |
| ---- | ------- | ------- |
| fetch_complete_list | True | Whether to attempt fetching the complete pronoun list from pronoun.is at startup. |
"""
settings.define_section('pronouns', PronounsSection)
settings.pronouns.configure_setting(
'fetch_complete_list',
'Fetch the current pronoun.is list at startup?')


def setup(bot):
bot.config.define_section('pronouns', PronounsSection)

# Copied from pronoun.is, leaving a *lot* out.
# If ambiguous, the earlier one will be used.
# This basic set is hard-coded to guarantee that the ten most(ish) common sets
Expand All @@ -35,6 +55,9 @@ def setup(bot):
'ey/em': 'ey/em/eir/eirs/eirself',
}

if not bot.config.pronouns.fetch_complete_list:
return

# and now try to get the current one
# who needs an API that might never exist?
# (https://github.com/witch-house/pronoun.is/pull/96)
Expand Down

0 comments on commit 41b7a13

Please sign in to comment.