diff --git a/commands/everyone.py b/commands/everyone.py index 879481c..07e8604 100755 --- a/commands/everyone.py +++ b/commands/everyone.py @@ -10,6 +10,7 @@ from evennia.contrib.rpg.rpsystem import send_emote from evennia.utils import iter_to_str, logger from typeclasses.readables import find_book +from typeclasses.characters import Character from utils.word_list import routput, paragraph, choices def speech_effect(speech, verb, target, effects): @@ -185,13 +186,21 @@ class CmdSay(MuxCommand): # Send the message to 'puppets' that have the special 'other_sayto' # method (if they are the object of the message): targets = split(r" *, *", self.lhs) - to_chars = [speaker.search(c, quiet=True)[0] for c in targets] + to_chars = [speaker.search(c, quiet=True) for c in targets] + to_chars = [c[0] for c in to_chars if len(c) > 0] + + if to_chars == []: + speaker.msg(f"No match for {', '.join(targets)}") + return + for char in to_chars: if hasattr(char, 'other_sayto') and callable(char.other_sayto): logger.info(f"Found {char.key}: {for_others}") char.other_sayto(speaker, for_others) - who = iter_to_str([c.get_display_name(speaker) for c in to_chars]) + who = iter_to_str([c.get_display_name(speaker) + if isinstance(c, Character) else c + for c in to_chars]) whom = iter_to_str([f"/{c}" for c in targets]) if verb == "ask":