mirror of
https://github.com/evennia/evennia.git
synced 2026-08-18 11:14:44 +00:00
Added 'client_live_report_typing' to Cmd and added it CmdSay and CmdPose. Refactored to fetch the puppets commands and relay the appropriate commands/aliases to the client + js updates.
This commit is contained in:
@ -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))
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user