Skip to content

Commit ce29f11

Browse files
committed
pronouns: accept they/them and they/them/theirs
Closes #2068
1 parent 6c142b1 commit ce29f11

File tree

1 file changed

+50
-25
lines changed

1 file changed

+50
-25
lines changed

sopel/modules/pronouns.py

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,19 @@
1414
# Copied from pronoun.is, leaving a *lot* out. If
1515
# https://github.com/witch-house/pronoun.is/pull/96 gets merged, using that
1616
# would be a lot easier.
17-
KNOWN_SETS = {
18-
'ze': 'ze/hir/hir/hirs/hirself',
19-
'ze/hir': 'ze/hir/hir/hirs/hirself',
20-
'ze/zir': 'ze/zir/zir/zirs/zirself',
21-
'they': 'they/them/their/theirs/themselves',
22-
'they/.../themselves': 'they/them/their/theirs/themselves',
23-
'they/.../themself': 'they/them/their/theirs/themself',
24-
'she': 'she/her/her/hers/herself',
25-
'he': 'he/him/his/his/himself',
26-
'xey': 'xey/xem/xyr/xyrs/xemself',
27-
'sie': 'sie/hir/hir/hirs/hirself',
28-
'it': 'it/it/its/its/itself',
29-
'ey': 'ey/em/eir/eirs/eirslef',
30-
}
17+
# If ambiguous, the earlier one will be used.
18+
KNOWN_SETS = [
19+
"ze/hir/hir/hirs/hirself",
20+
"ze/zir/zir/zirs/zirself",
21+
"they/them/their/theirs/themselves",
22+
"they/them/their/theirs/themself",
23+
"she/her/her/hers/herself",
24+
"he/him/his/his/himself",
25+
"xey/xem/xyr/xyrs/xemself",
26+
"sie/hir/hir/hirs/hirself",
27+
"it/it/its/its/itself",
28+
"ey/em/eir/eirs/eirself",
29+
]
3130

3231

3332
@plugin.command('pronouns')
@@ -69,7 +68,9 @@ def say_pronouns(bot, nick, pronouns):
6968

7069

7170
@plugin.command('setpronouns')
72-
@plugin.example('.setpronouns they/them/their/theirs/themselves')
71+
@plugin.example('.setpronouns they/them')
72+
@plugin.example('.setpronouns they/them/theirs')
73+
@plugin.example('.setpronouns fae/faer/faer/faers/faerself')
7374
def set_pronouns(bot, trigger):
7475
pronouns = trigger.group(2)
7576
"""Set your pronouns."""
@@ -78,21 +79,45 @@ def set_pronouns(bot, trigger):
7879
return
7980

8081
disambig = ''
81-
if pronouns == 'they':
82-
disambig = ' You can also use they/.../themself, if you prefer.'
83-
pronouns = KNOWN_SETS.get(pronouns)
84-
elif pronouns == 'ze':
85-
disambig = ' I have ze/hir. If you meant ze/zir, you can use that instead.'
86-
pronouns = KNOWN_SETS.get(pronouns)
87-
elif len(pronouns.split('/')) != 5:
88-
pronouns = KNOWN_SETS.get(pronouns)
89-
if not pronouns:
82+
requested_pronoun_split = pronouns.split("/")
83+
if len(requested_pronoun_split) < 5:
84+
matching = []
85+
for known_pronoun_set in KNOWN_SETS:
86+
known_pronoun_split = known_pronoun_set.split("/")
87+
if known_pronoun_set.startswith(pronouns + "/") or (
88+
len(requested_pronoun_split) == 3
89+
and (
90+
(
91+
# "they/.../themself"
92+
requested_pronoun_split[1] == "..."
93+
and requested_pronoun_split[0] == known_pronoun_split[0]
94+
and requested_pronoun_split[2] == known_pronoun_split[4]
95+
)
96+
or (
97+
# "they/them/theirs"
98+
requested_pronoun_split[0:2] == known_pronoun_split[0:2]
99+
and requested_pronoun_split[2] == known_pronoun_split[3]
100+
)
101+
)
102+
):
103+
matching.append(known_pronoun_set)
104+
105+
if len(matching) == 0:
90106
bot.reply(
91107
"I'm sorry, I don't know those pronouns. "
92108
"You can give me a set I don't know by formatting it "
93109
"subject/object/possessive-determiner/possessive-pronoun/"
94110
"reflexive, as in: they/them/their/theirs/themselves"
95111
)
96112
return
113+
114+
pronouns = matching[0]
115+
if len(matching) > 1:
116+
disambig = (" Or, if you meant one of these, please tell me: {}").format(
117+
", ".join(matching[1:])
118+
)
119+
97120
bot.db.set_nick_value(trigger.nick, 'pronouns', pronouns)
98-
bot.reply("Thanks for telling me!" + disambig)
121+
bot.reply(
122+
"Thanks for telling me! I'll remember you use {}.{}".format(pronouns, disambig)
123+
)

0 commit comments

Comments
 (0)