Fix bug in say to command

Also, if you say without ending in punctuation, the "say" command
output is reversed. Just to keep everyone on their toes.
This commit is contained in:
Howard Abrams 2026-03-13 22:18:46 -07:00
parent bef4d35f36
commit 92b6c9973b
2 changed files with 36 additions and 12 deletions

View file

@ -4,7 +4,7 @@ from random import random
from re import match, split, sub, MULTILINE
from evennia.contrib.rpg.rpsystem import send_emote
from evennia.utils import logger
from evennia.utils import logger, delay
from evennia.utils.verb_conjugation.pronouns import PRONOUN_MAPPING
from commands.command import Command
@ -154,6 +154,7 @@ class CmdSay(Command):
def parse(self):
"""Parse the input into speech parts."""
self.phrase = self.args.strip()
self.reverse = False
m = match(r".+\?.*", self.phrase)
if m:
@ -161,6 +162,9 @@ class CmdSay(Command):
m = match(r".+!.*", self.phrase)
if m:
self.verb = "exclaim"
m = match(r'.+\w$', self.phrase)
if m:
self.reverse = True
m = match(r'.*".+".*', self.phrase)
if not m:
@ -236,10 +240,16 @@ class CmdSay(Command):
verb = " " + verb
adverb = " " + self.adverb if self.adverb else ""
if adverb.endswith("ly") and random() < 0.5:
full_speech = f"You{adverb}{verb}{to_who}, \"{phrase}\""
if self.reverse:
if adverb.endswith("ly") and random() < 0.5:
full_speech = f"\"{phrase},\" you{adverb}{verb}{to_who}."
else:
full_speech = f"\"{phrase},\" you{verb}{adverb}{to_who}."
else:
full_speech = f"You{verb}{adverb}{to_who}, \"{phrase}\""
if adverb.endswith("ly") and random() < 0.5:
full_speech = f"You{adverb}{verb}{to_who}, \"{phrase}\""
else:
full_speech = f"You{verb}{adverb}{to_who}, \"{phrase}\""
speaker.msg(full_speech, from_obj=speaker)
def to_others(self, speaker, verb, phrase):
@ -254,23 +264,35 @@ class CmdSay(Command):
whom = PRONOUN_MAPPING['3rd person']['reflexive pronoun'][self.caller.db.gender]
else:
who = self.target.get_display_name(speaker)
whom = f"/{self.target.key}"
if self.target.sdesc:
whom = f"the /{self.target.sdesc.get()}"
else:
whom = f"the /{self.target.name}"
if verb == "ask":
to_whom = " " + whom
else:
to_whom = " to " + whom
# English is weird...
# english is weird...
verb = ' replie' if verb == 'reply' else " " + verb
adverb = " " + self.adverb if self.adverb else ""
targets = [item for item in speaker.location.contents
if item != speaker]
if adverb.endswith("ly") and random() < 0.5:
full_speech = f"/me{adverb}{verb}s{to_whom}, \"{phrase}\""
if self.reverse:
if adverb.endswith("ly") and random() < 0.5:
full_speech = f"\"{phrase},\" /me{adverb}{verb}s{to_whom}."
else:
full_speech = f"\"{phrase},\" /me{verb}s{adverb}{to_whom}."
else:
full_speech = f"/me{verb}s{adverb}{to_whom}, \"{phrase}\""
if adverb.endswith("ly") and random() < 0.5:
full_speech = f"/me{adverb}{verb}s{to_whom}, \"{phrase}\""
else:
full_speech = f"/me{verb}s{adverb}{to_whom}, \"{phrase}\""
logger.info(f"Full speech: {full_speech}")
# Full speech: /me asks /Trampoli, "How are you?"
send_emote(speaker, targets, full_speech, msg_type="say",
anonymous_add=None)
@ -283,8 +305,9 @@ class CmdSay(Command):
if not target:
for char in speaker.location.contents:
if hasattr(char, 'other_say') and callable(char.other_say):
char.other_say(speaker, phrase)
logger.info(f"to_puppets: all: {char}")
delay(1, char.other_say, speaker, phrase)
else:
if hasattr(target, 'other_sayto') and callable(target.other_sayto):
logger.info(f"Found {target.key}: {phrase}")
target.other_sayto(speaker, phrase)
delay(1, target.other_sayto, speaker, phrase)

View file

@ -122,7 +122,8 @@ class KnockScript(Script):
gnome = search_object("Dabbler").first()
if gnome:
gnome.msg(f"With your seer stone, you see the knocker is {knocker.key}, {knocker.db._sdesc}.")
delay(3, gnome.msg,
f"With your seer stone, you see the knocker is {knocker.key}, the {knocker.db._sdesc}.")
def at_repeat(self, **kwargs):
waker = self.attributes.get("waker")