diff --git a/evennia/commands/default/account.py b/evennia/commands/default/account.py index c0296a43dc..c836a51dc1 100644 --- a/evennia/commands/default/account.py +++ b/evennia/commands/default/account.py @@ -672,6 +672,7 @@ class CmdOption(COMMAND_DEFAULT_CLASS): "FORCEDENDLINE": validate_bool, "LOCALECHO": validate_bool, "TRUECOLOR": validate_bool, + "ISTYPING": validate_bool } name = self.lhs.upper() diff --git a/evennia/server/inputfuncs.py b/evennia/server/inputfuncs.py index 02611530e0..81ddb75c5b 100644 --- a/evennia/server/inputfuncs.py +++ b/evennia/server/inputfuncs.py @@ -25,10 +25,9 @@ from codecs import lookup as codecs_lookup from django.conf import settings -from evennia import DefaultCharacter, TASK_HANDLER +from evennia import DefaultCharacter from evennia.commands.cmdhandler import cmdhandler from evennia.commands.default.general import CmdSay -from evennia.utils.ansi import strip_mxp from evennia.utils.logger import log_err from evennia.utils.utils import to_str, delay from evennia.scripts.tickerhandler import TICKER_HANDLER @@ -188,6 +187,7 @@ _CLIENT_OPTIONS = ( "NOCOLOR", "NOGOAHEAD", "LOCALECHO", + "ISTYPING" ) @@ -214,6 +214,7 @@ def client_options(session, *args, **kwargs): nocolor (bool): Strip color raw (bool): Turn off parsing localecho (bool): Turn on server-side echo (for clients not supporting it) + istyping (bool): Turn off OOB typing notifications (currently only used by the webclient) """ old_flags = session.protocol_flags @@ -277,6 +278,8 @@ def client_options(session, *args, **kwargs): flags["NOGOAHEAD"] = validate_bool(value) elif key == "localecho": flags["LOCALECHO"] = validate_bool(value) + elif key == "istyping": + flags["ISTYPING"] = validate_bool(value) elif key in ( "Char 1", "Char.Skills 1", @@ -671,8 +674,7 @@ def is_typing_send_update(): payload = [] # Get potentials - # TODO: exclude the speaking character - potentials = DefaultCharacter.objects.filter_family(db_location=_IS_TYPING_PARTICIPANTS[participant]["session"].puppet.location) + potentials = DefaultCharacter.objects.filter_family(db_location=_IS_TYPING_PARTICIPANTS[participant]["session"].puppet.location).exclude(db_key=_IS_TYPING_PARTICIPANTS[participant]["session"].puppet.key) # if len(potentials) > 0: for puppet in potentials: @@ -708,6 +710,12 @@ def is_typing_get_aliases(session, *args, **kwargs): Returns: """ + options = session.protocol_flags + istyping = options.get("ISTYPING", True) + + if not istyping: + return + # Add the participant to the list. _IS_TYPING_PARTICIPANTS[str(session.sessid)] = { "state": False, @@ -732,6 +740,13 @@ def is_typing_update_participant(session, *args, **kwargs): Returns: """ + options = session.protocol_flags + istyping = options.get("ISTYPING", True) + + if not istyping: + is_typing_remove_participant(session) + return + # If the session isn't found then server restarted if _IS_TYPING_PARTICIPANTS.get(session.sessid) is None: _IS_TYPING_PARTICIPANTS[str(session.sessid)] = { @@ -756,7 +771,8 @@ def is_typing_remove_participant(session, *args, **kwargs): Returns: """ - del _IS_TYPING_PARTICIPANTS[str(session.sessid)] + if _IS_TYPING_PARTICIPANTS.get(str(session.sessid)) is not None: + del _IS_TYPING_PARTICIPANTS[str(session.sessid)] # client specific diff --git a/evennia/server/portal/webclient.py b/evennia/server/portal/webclient.py index 1f35d473ee..e2380bcce4 100644 --- a/evennia/server/portal/webclient.py +++ b/evennia/server/portal/webclient.py @@ -138,6 +138,7 @@ class WebSocketClient(WebSocketServerProtocol, _BASE_SESSION_CLASS): self.protocol_flags["TRUECOLOR"] = True self.protocol_flags["XTERM256"] = True self.protocol_flags["ANSI"] = True + self.protocol_flags["ISTYPING"] = True # watch for dead links self.transport.setTcpKeepAlive(1) diff --git a/evennia/web/static/webclient/js/plugins/is_typing.js b/evennia/web/static/webclient/js/plugins/is_typing.js index d037546e30..22480702d1 100644 --- a/evennia/web/static/webclient/js/plugins/is_typing.js +++ b/evennia/web/static/webclient/js/plugins/is_typing.js @@ -124,7 +124,7 @@ let is_typing = (function () { state.typing_players.forEach((player, index) => { if (player.timeout < now) { timedOut.push(index); - $(`#istyping-${player}`).remove(); + $(`#istyping-${player.name}`).remove(); } }); @@ -208,7 +208,6 @@ let is_typing = (function () { Evennia.emitter.on("is_typing", is_typing); createDialog(); - console.log("Is Typing plugin initialized"); };