diff --git a/evennia/commands/command.py b/evennia/commands/command.py index 8931442bb4..08711b377e 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -507,6 +507,7 @@ Command \"{cmdname}\" has no defined `func()` method. Available properties on th ("self.locks", self.locks), ("self.help_category", self.help_category), ("self.cmdset", self.cmdset), + ("self.client_live_report_typing", self.client_live_report_typing), ) ] output = output_string.format(cmdname=self.key, variables="\n ".join(variables)) diff --git a/evennia/commands/default/general.py b/evennia/commands/default/general.py index c5af73af79..094ce2975e 100644 --- a/evennia/commands/default/general.py +++ b/evennia/commands/default/general.py @@ -655,6 +655,8 @@ class CmdSay(COMMAND_DEFAULT_CLASS): # don't require a space after `say/'/"` arg_regex = None + client_live_report_typing = True + def func(self): """Run the say command""" @@ -745,6 +747,8 @@ class CmdPose(COMMAND_DEFAULT_CLASS): # the command/alias and the pose (e.g. :pose) arg_regex = None + client_live_report_typing = True + def parse(self): """ Custom parse the cases where the emote diff --git a/evennia/server/is_typing.py b/evennia/server/is_typing.py index ca06c174df..d39c90e4de 100644 --- a/evennia/server/is_typing.py +++ b/evennia/server/is_typing.py @@ -22,13 +22,24 @@ def is_typing_setup(session, *args, **kwargs): options = session.protocol_flags is_typing = options.get("ISTYPING", True) + live_report_commands = [ + cmd for cmd in session.puppet.cmdset.current if hasattr(cmd, "client_live_report_typing") + ] + commands_and_aliases = [] + for cmd in live_report_commands: + commands_and_aliases.append(cmd.key) + commands_and_aliases += cmd.aliases + if not is_typing: return session.msg( is_typing={ "type": "setup", - "payload": {"say_aliases": CmdSay.aliases, "talking_timeout": _IS_TYPING_TIMEOUT}, + "payload": { + "live_report_commands": commands_and_aliases, + "typing_timeout": _IS_TYPING_TIMEOUT, + }, } ) diff --git a/evennia/web/static/webclient/js/plugins/is_typing.js b/evennia/web/static/webclient/js/plugins/is_typing.js index 44ac96131c..54bcc8555f 100644 --- a/evennia/web/static/webclient/js/plugins/is_typing.js +++ b/evennia/web/static/webclient/js/plugins/is_typing.js @@ -9,7 +9,7 @@ let is_typing = (function (){ cleanup_callback: null, } - const sayCommands = ['say'] + const liveReportCommandss = [] /** * Create the containers that house our typing users @@ -89,8 +89,8 @@ let is_typing = (function (){ const cmd = escapeRegExp(alias); // Is it already present? - if (sayCommands.indexOf(cmd) === -1){ - sayCommands.push(escapeRegExp(alias)); // Nope! + if (liveReportCommandss.indexOf(cmd) === -1){ + liveReportCommandss.push(escapeRegExp(alias)); // Nope! } }) } @@ -114,7 +114,7 @@ let is_typing = (function (){ * @param {KeyboardEvent} event - The typing state, e.g., "typing" or "idle". */ const onKeydown = function (event) { - const regex = new RegExp(`^\W*(${sayCommands.reduce((acc, cur)=> acc + "|" + cur, "").substring(1)})`) + const regex = new RegExp(`^\W*(${liveReportCommandss.reduce((acc, cur)=> acc + "|" + cur, "").substring(1)})`) const inputfield = $(".inputfield:focus"); // A 'say' command is being used. @@ -193,9 +193,9 @@ let is_typing = (function (){ if ('type' in kwargs) { switch (kwargs.type) { case 'setup': - const {say_aliases, talking_timeout } = kwargs.payload - timeout = talking_timeout - setSayAliases(say_aliases) + const {live_report_commands, typing_timeout } = kwargs.payload + timeout = typing_timeout + setSayAliases(live_report_commands) break; case 'typing': @@ -249,7 +249,7 @@ let is_typing = (function (){ createDialog(); - console.log('Is Typing plugin initialized'); + console.log(`Is Typing plugin initialized`); } return {