forked from sopel-irc/sopel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If witch-house/pronoun.is#40 gets merged, it's probably worth porting to use that, since there are a *lot* of pronoun sets. Yes, this should probably support other languages. Sopel's i18n is horrible and I know it.
- Loading branch information
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# coding=utf-8 | ||
""" | ||
pronouns.py - Sopel Pronouns Module | ||
Copyright © 2016, Elsie Powell | ||
Licensed under the Eiffel Forum License 2. | ||
http://sopel.chat | ||
""" | ||
from __future__ import unicode_literals, absolute_import, print_function, division | ||
|
||
from sopel.logger import get_logger | ||
from sopel.module import commands, example | ||
|
||
logger = get_logger(__name__) | ||
# Copied from pronoun.is, leaving a *lot* out. If | ||
# https://github.com/witch-house/pronoun.is/pull/40 gets merged, using that | ||
# would be a lot easier. | ||
KNOWN_SETS = { | ||
'ze': 'ze/hir/hir/hirs/hirself', | ||
'ze/hir': 'ze/hir/hir/hirs/hirself', | ||
'ze/zir': 'ze/zir/zir/zirs/zirself', | ||
'they': 'they/them/their/theirs/themselves', | ||
'they/.../themselves': 'they/them/their/theirs/themselves', | ||
'they/.../themself': 'they/them/their/theirs/themself', | ||
'she': 'she/her/her/hers/herself', | ||
'he': 'he/him/his/his/himself', | ||
'xey': 'xey/xem/xyr/xyrs/xemself', | ||
'sie': 'sie/hir/hir/hirs/hirself', | ||
'it': 'it/it/its/its/itself', | ||
'ey': 'ey/em/eir/eirs/eirslef', | ||
} | ||
|
||
|
||
@commands('pronouns') | ||
@example('.pronouns Embolalia') | ||
def pronouns(bot, trigger): | ||
if not trigger.group(2): | ||
pronouns = bot.db.get_nick_value(trigger.nick, 'pronouns') | ||
if pronouns: | ||
say_pronouns(bot, trigger.nick, pronouns) | ||
else: | ||
bot.reply("I don't know your pronouns! You can set them with " | ||
".setpronouns") | ||
else: | ||
pronouns = bot.db.get_nick_value(trigger.group(2), 'pronouns') | ||
if pronouns: | ||
say_pronouns(bot, trigger.nick, pronouns) | ||
else: | ||
bot.say("I don't know {}'s pronouns. They can set them with " | ||
".setpronouns") | ||
|
||
|
||
def say_pronouns(bot, nick, pronouns): | ||
for short, set_ in KNOWN_SETS.items(): | ||
if pronouns == set_: | ||
break | ||
short = pronouns | ||
|
||
bot.say("{}'s pronouns are {}. See http://pronoun.is/{} for " | ||
"examples.".format(nick, pronouns, short)) | ||
|
||
|
||
@commands('setpronouns') | ||
@example('.setpronouns they/them/their/theirs/themselves') | ||
def set_pronouns(bot, trigger): | ||
pronouns = trigger.group(2) | ||
disambig = '' | ||
if pronouns == 'they': | ||
disambig = ' You can also use they/.../themself, if you prefer.' | ||
pronouns = KNOWN_SETS.get(pronouns) | ||
elif pronouns == 'ze': | ||
disambig = ' I have ze/hir. If you meant ze/zir, you can use that instead.' | ||
pronouns = KNOWN_SETS.get(pronouns) | ||
elif len(pronouns.split('/')) != 5: | ||
pronouns = KNOWN_SETS.get(pronouns) | ||
if not pronouns: | ||
bot.say( | ||
"I'm sorry, I don't know those pronouns. You can give me a set " | ||
"I don't know by formatting it " | ||
"subject/object/possessive-determiner/posessive-pronoun/" | ||
"reflexive, as in they/them/their/theirs/themselves" | ||
) | ||
return | ||
bot.db.set_nick_value(trigger.nick, 'pronouns', pronouns) | ||
bot.reply("Thanks for telling me!" + disambig) |