From c5ff2de0bd2309743c2acac477f94c0274de8dca Mon Sep 17 00:00:00 2001 From: Griatch Date: Wed, 4 Mar 2020 22:28:43 +0100 Subject: [PATCH] Fix account.msg, which didn't properly handle tuple input --- evennia/accounts/accounts.py | 13 +++++++++++-- evennia/commands/default/help.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index f3217e88ea..af0050ec9d 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -828,7 +828,10 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase): server. Args: - text (str, optional): text data to send + text (str or tuple, optional): The message to send. This + is treated internally like any send-command, so its + value can be a tuple if sending multiple arguments to + the `text` oob command. from_obj (Object or Account or list, optional): Object sending. If given, its at_msg_send() hook will be called. If iterable, call on all entities. session (Session or list, optional): Session object or a list of @@ -859,7 +862,13 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase): kwargs["options"] = options if text is not None: - kwargs["text"] = to_str(text) + if not (isinstance(text, str) or isinstance(text, tuple)): + # sanitize text before sending across the wire + try: + text = to_str(text) + except Exception: + text = repr(text) + kwargs["text"] = text # session relay sessions = make_iter(session) if session else self.sessions.all() diff --git a/evennia/commands/default/help.py b/evennia/commands/default/help.py index 96ad641c1a..9e1b45c2c6 100644 --- a/evennia/commands/default/help.py +++ b/evennia/commands/default/help.py @@ -79,7 +79,7 @@ class CmdHelp(Command): evmore.msg(self.caller, text, session=self.session) return - self.msg((text, {"type": "help"})) + self.msg(text=(text, {"type": "help"})) @staticmethod def format_help_entry(title, help_text, aliases=None, suggested=None):