vantaMOO/lib/pronounsub/commands.py

226 lines
7.8 KiB
Python
Raw Normal View History

2023-01-17 23:51:04 +01:00
from .common import *
from .character import object_init
2023-01-14 00:37:53 +01:00
class PronounAdminCommand(Command):
"""
2023-01-14 01:00:40 +01:00
Manages the list of known server-wide pronouns.
Usage:
2023-01-14 00:37:53 +01:00
@pronounadmin help
@pronounadmin list_known
@pronounadmin spec <specific>
@pronounadmin unspec <specific>
2023-01-14 01:00:40 +01:00
On each character and the server are stored character pronouns and specific
2023-01-14 00:37:53 +01:00
pronouns. The character pronouns specify what pronouns should actually be
2023-01-14 01:00:40 +01:00
used for your character, and the specific pronouns define all the
grammatical forms of a pronoun so the character pronouns can be used in
text substitution.
2023-01-14 00:37:53 +01:00
The specific format is: <subjective>,<objective>,<possessive>,<absolute>
subjective: *They* went to the store.
objective: You took *them* to the store.
possessive: You took *their* friend to the store.
absolute: The sandwich in the fridge was *theirs*.
2023-01-14 00:37:53 +01:00
The `list_known` command lists all specific pronouns known by the server.
The `spec` command adds a new specific pronoun.
The `unspec` command removes an existing specific pronoun.
2023-01-14 00:37:53 +01:00
Examples:
@pronounadmin spec they,them,their,theirs
"""
key = "pronounadmin"
2023-01-14 00:37:53 +01:00
locks = "cmd:id(1) or perm(Admin)"
def parse(self):
caller = self.caller
args = self.args.strip().lower().split()
2023-01-14 00:37:53 +01:00
if len(args) == 0:
caller.msg(self.get_help(caller, self.cmdset))
raise InterruptCommand()
command = args[0]
2023-01-14 00:37:53 +01:00
if command == "list_known" and len(args) == 1:
self.args = tuple([command])
return
if len(args) != 2:
caller.msg(self.get_help(caller, self.cmdset))
raise InterruptCommand()
if not command in [ "spec", "unspec" ] or command == "help":
caller.msg(self.get_help(caller, self.cmdset))
raise InterruptCommand()
pronoun = parse_specific_pronoun(args[1])
if pronoun == None:
caller.msg(self.get_help(caller, self.cmdset))
raise InterruptCommand()
self.args = ( command, pronoun )
def func(self):
caller = self.caller
2023-01-14 00:37:53 +01:00
command = self.args[0]
if command == "list_known":
caller.msg("Known server-defined pronouns:")
for spec in get_pronoun_list():
caller.msg(f" {stringify_specific_pronoun(spec)}")
return
2023-01-11 11:14:04 +01:00
2023-01-14 00:37:53 +01:00
_, pronoun = self.args
pronoun_list = get_pronoun_list()
2023-01-14 00:37:53 +01:00
if command == "spec":
if not pronoun in pronoun_list:
pronoun_list.append(pronoun)
2023-01-14 00:37:53 +01:00
self.caller.msg(f"Added the pronoun {stringify_specific_pronoun(pronoun)}.")
elif command == "unspec":
if pronoun in pronoun_list:
pronoun_list.remove(pronoun)
2023-01-14 00:37:53 +01:00
self.caller.msg(f"Removed the pronoun {stringify_specific_pronoun(pronoun)}.")
2023-01-14 01:02:40 +01:00
class PronounsCommand(Command):
2023-01-11 11:14:04 +01:00
"""
2023-01-14 01:00:40 +01:00
Manages your pronouns.
2023-01-11 11:14:04 +01:00
Usage:
2023-01-14 00:37:53 +01:00
@pronouns help
@pronouns set <pronouns>
@pronouns get
2023-01-14 00:37:53 +01:00
@pronouns list_known
@pronouns spec <specific>
@pronouns unspec <specific>
2023-01-11 11:14:04 +01:00
2023-01-14 01:00:40 +01:00
On each character and the server are stored character pronouns and specific
2023-01-14 00:37:53 +01:00
pronouns. The character pronouns specify what pronouns should actually be
2023-01-14 01:00:40 +01:00
used for your character, and the specific pronouns define all the
grammatical forms of a pronoun so the character pronouns can be used in
text substitution.
2023-01-11 11:14:04 +01:00
2023-01-14 00:37:53 +01:00
The server already has some specific pronouns defined, so it's likely you
2023-01-14 01:00:40 +01:00
can just give your character pronouns and be done. If the server doesn't
know about your pronouns already then you'll have to tell the server how to
use them with the `spec` command.
2023-01-11 11:14:04 +01:00
The specific format is: <subjective>,<objective>,<possessive>,<absolute>
subjective: *They* went to the store.
objective: You took *them* to the store.
possessive: You took *their* friend to the store.
absolute: The sandwich in the fridge was *theirs*.
2023-01-14 00:37:53 +01:00
The `set` command:
Sets your current character pronouns. Pronouns look the same as how you'd
2023-01-14 01:00:40 +01:00
write them anywhere online. They're separated by a slash ("/"), like
"she/they/it", or "he/him". Each pronoun should match to the grammatical
form of a specific pronoun. When multiple pronouns are given, like both
"she" and "they", a random one will be used in each text substitution.
2023-01-11 11:14:04 +01:00
2023-01-14 01:00:40 +01:00
The `get` command prints your current configured character pronouns.
2023-01-14 00:37:53 +01:00
The `list_known` command lists all specific pronouns known by the
server and specified for your acount.
The `spec` command adds a new specific pronoun.
The `unspec` command removes an existing specific pronoun.
2023-01-11 11:14:04 +01:00
Examples:
@pronouns set he/him
2023-01-11 11:14:04 +01:00
@pronouns set she/they/it
2023-01-11 11:14:04 +01:00
2023-01-14 00:37:53 +01:00
@pronouns spec fae,faer,faer,faers
2023-01-11 11:14:04 +01:00
"""
key = "pronouns"
def parse(self):
caller = self.caller
2023-01-17 23:51:04 +01:00
object_init(caller)
2023-01-11 11:14:04 +01:00
args = self.args.strip().lower().split()
if len(args) == 1:
command = args[0]
2023-01-14 00:37:53 +01:00
if not command in [ "get", "list_known" ] or command == "help":
caller.msg(self.get_help(caller, self.cmdset))
raise InterruptCommand()
2023-01-11 11:14:04 +01:00
self.args = tuple([command])
2023-01-11 11:14:04 +01:00
return
if len(args) != 2:
caller.msg(self.get_help(caller, self.cmdset))
raise InterruptCommand()
command = args[0]
2023-01-11 11:14:04 +01:00
2023-01-14 00:37:53 +01:00
if command == "spec" or command == "unspec":
new = parse_specific_pronoun(args[1])
if new == None:
caller.msg(self.get_help(caller, self.cmdset))
raise InterruptCommand()
2023-01-11 11:14:04 +01:00
else:
2023-01-14 00:37:53 +01:00
res = new
2023-01-11 11:14:04 +01:00
2023-01-14 00:37:53 +01:00
elif command == "set":
res = args[1].split('/')
self.args = (command, res)
2023-01-11 11:14:04 +01:00
def func(self):
caller = self.caller
2023-01-17 23:51:04 +01:00
object_init(caller)
2023-01-11 11:14:04 +01:00
command = self.args[0]
2023-01-11 11:14:04 +01:00
2023-01-14 00:37:53 +01:00
match self.args[0]:
case "set":
_, pronouns = self.args
has_unmatched = False
for pronoun in pronouns:
if not specific_pronoun_from_character(pronoun, caller):
has_unmatched = True
caller.msg(f"Warning: The character pronoun \"{pronoun}\" is "
"not in any list of specific pronouns. It will "
"be ignored. |/")
if has_unmatched:
caller.msg("You have unkown pronouns set! If you want to "
"actually use them, you'll need to specify their "
"specific form. Type `pronouns help` for "
"details. |/")
caller.db.pronouns = pronouns
2023-01-17 23:51:04 +01:00
caller.msg(f"Your pronouns have been set to {stringify_pronouns(caller)}.")
2023-01-14 00:37:53 +01:00
case "get":
2023-01-17 23:51:04 +01:00
caller.msg(f"Your pronouns are {stringify_pronouns(caller)}.")
2023-01-14 00:37:53 +01:00
case "list_known":
caller.msg("Known user-defined pronouns:")
for spec in caller.db.pronoun_specs:
caller.msg(f" {stringify_specific_pronoun(spec)}")
caller.msg("Known server-defined pronouns:")
for spec in get_pronoun_list():
caller.msg(f" {stringify_specific_pronoun(spec)}")
case "spec":
_, pronoun = self.args
if not pronoun in caller.db.pronoun_specs:
caller.db.pronoun_specs.append(pronoun)
self.caller.msg(f"Added the pronoun {stringify_specific_pronoun(pronoun)}.")
case "unspec":
_, pronoun = self.args
if pronoun in caller.db.pronoun_specs:
caller.db.pronoun_specs.remove(pronoun)
self.caller.msg(f"Remobed the pronoun {stringify_specific_pronoun(pronoun)}.")