#1781 Fix /len and unescape for non-string arguments
This commit is contained in:
parent
37d94a4331
commit
07677584c4
|
@ -1561,21 +1561,26 @@ async function executeSlashCommands(text, unescape = false) {
|
|||
}
|
||||
}
|
||||
|
||||
if (typeof unnamedArg === 'string' && /{{pipe}}/i.test(unnamedArg)) {
|
||||
unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult ?? '');
|
||||
if (typeof unnamedArg === 'string') {
|
||||
if (/{{pipe}}/i.test(unnamedArg)) {
|
||||
unnamedArg = unnamedArg.replace(/{{pipe}}/i, pipeResult ?? '');
|
||||
}
|
||||
|
||||
unnamedArg = unnamedArg
|
||||
?.replace(/\\\|/g, '|')
|
||||
?.replace(/\\\{/g, '{')
|
||||
?.replace(/\\\}/g, '}')
|
||||
;
|
||||
}
|
||||
|
||||
unnamedArg = unnamedArg
|
||||
?.replace(/\\\|/g, '|')
|
||||
?.replace(/\\\{/g, '{')
|
||||
?.replace(/\\\}/g, '}')
|
||||
;
|
||||
for (const [key, value] of Object.entries(result.args)) {
|
||||
result.args[key] = value
|
||||
.replace(/\\\|/g, '|')
|
||||
.replace(/\\\{/g, '{')
|
||||
.replace(/\\\}/g, '}')
|
||||
;
|
||||
if (typeof value === 'string') {
|
||||
result.args[key] = value
|
||||
.replace(/\\\|/g, '|')
|
||||
.replace(/\\\{/g, '{')
|
||||
.replace(/\\\}/g, '}')
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
pipeResult = await result.command.callback(result.args, unnamedArg);
|
||||
|
|
|
@ -649,7 +649,19 @@ function lenValuesCallback(value) {
|
|||
} catch {
|
||||
// could not parse
|
||||
}
|
||||
return parsedValue.length;
|
||||
if (Array.isArray(parsedValue)) {
|
||||
return parsedValue.length;
|
||||
}
|
||||
switch (typeof parsedValue) {
|
||||
case 'string':
|
||||
return parsedValue.length;
|
||||
case 'object':
|
||||
return Object.keys(parsedValue).length;
|
||||
case 'number':
|
||||
return String(parsedValue).length;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function randValuesCallback(from, to, args) {
|
||||
|
|
Loading…
Reference in New Issue