Expand the 'say' command to be personable again
This commit is contained in:
parent
ddddfe4b7b
commit
a9e0c24ad9
2 changed files with 28 additions and 15 deletions
|
|
@ -36,18 +36,28 @@ class CmdSay(MuxCommand):
|
|||
"""
|
||||
|
||||
key = "say"
|
||||
aliases = ["speak", "yell", "scream", "ask"]
|
||||
aliases = ["speak", "yell", "scream", "ask", "\""]
|
||||
priority = 0
|
||||
locks = "cmd:all()"
|
||||
rhs_split = (",", "=")
|
||||
rhs_split = ("=")
|
||||
|
||||
def func(self):
|
||||
"""
|
||||
Implements the new 'say' command with switches.
|
||||
"""
|
||||
def characters(chars):
|
||||
def chars_for_self(chars):
|
||||
return [self.caller.search(c).get_display_name(self) for c in split(r"[ ,]+", chars)]
|
||||
|
||||
def chars_for_others(chars):
|
||||
return [c if c.startswith('/') else '/'+c for c in split(r"[ ,]+", chars)]
|
||||
|
||||
def chars_list(chars, verb, for_rp=True):
|
||||
char_lst = chars_for_others(chars) if for_rp else chars_for_self(chars)
|
||||
return (' to ' if verb == 'say' else ' ') + \
|
||||
iter_to_str(char_lst, endsep='and')
|
||||
|
||||
logger.info(f"CmdSayIt: {self.cmdstring} lhs={self.lhs} switches={self.switches}")
|
||||
|
||||
if not self.args:
|
||||
self.caller.msg("Say what?")
|
||||
return
|
||||
|
|
@ -61,29 +71,31 @@ class CmdSay(MuxCommand):
|
|||
if not self.caller.at_pre_say(speech):
|
||||
return
|
||||
|
||||
logger.info(f"CmdSayIt: {self.cmdstring}")
|
||||
adverb = ''
|
||||
for switch in self.switches:
|
||||
if switch.endswith('ly'):
|
||||
adverb = switch + ' '
|
||||
|
||||
if 'yell' in self.switches or self.cmdstring == 'yell' or speech.endswith('!'):
|
||||
omsg_type = adverb + 'yells'
|
||||
verb = 'yell'
|
||||
elif 'scream' in self.switches or self.cmdstring == 'scream':
|
||||
omsg_type = adverb + 'screams'
|
||||
verb = 'scream'
|
||||
elif 'ask' in self.switches or self.cmdstring == 'ask' or speech.endswith('?'):
|
||||
omsg_type = adverb + 'asks'
|
||||
verb = 'ask'
|
||||
else:
|
||||
omsg_type = adverb + "says"
|
||||
verb = "say"
|
||||
|
||||
if 'to' in self.switches:
|
||||
to_whom = ' to ' if omsg_type.endswith('says') else ' ' + \
|
||||
iter_to_str(characters(self.lhs), endsep='and')
|
||||
else:
|
||||
to_whom = ''
|
||||
# The `send_emote` is _global_, so if we want to say to 'Bob',
|
||||
# 'You say ...', we have to both send him a message with the
|
||||
# 'You' as well as everyone else with the 'send_emote'.
|
||||
|
||||
full_speech = f"/Me {omsg_type}{to_whom}, \"{speech}\""
|
||||
targets = self.caller.location.contents
|
||||
to_whom = chars_list(self.lhs, verb, for_rp=False) if 'to' in self.switches else ''
|
||||
full_speech = f"You {adverb}{verb}{to_whom}, \"{speech}\""
|
||||
self.caller.msg(full_speech, from_obj=self.caller)
|
||||
|
||||
targets = [item for item in self.caller.location.contents if item != self.caller]
|
||||
to_whom = chars_list(self.lhs, verb) if 'to' in self.switches else ''
|
||||
full_speech = f"/Me {adverb}{verb}s{to_whom}, \"{speech}\""
|
||||
send_emote(self.caller, targets, full_speech, msg_type="say", anonymous_add=None)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ STATIC_URL = "/cozy/static/"
|
|||
SSH_ENABLED = True
|
||||
# SSL_ENABLED = True
|
||||
|
||||
FUNCPARSER_PARSE_OUTGOING_MESSAGES_ENABLED = True
|
||||
SEARCH_MULTIMATCH_REGEX = r"(?P<number>[0-9]+)-(?P<name>[^-]*)(?P<args>.*)"
|
||||
SEARCH_MULTIMATCH_TEMPLATE = " {number}-{name}{aliases}{info}\n"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue