Move macros replacement to script execution time
This commit is contained in:
parent
461e8d7929
commit
74fbc88d7d
|
@ -229,14 +229,14 @@ async function performQuickReply(prompt, index) {
|
|||
newText = `${prompt} `;
|
||||
}
|
||||
|
||||
newText = substituteParams(newText);
|
||||
|
||||
// the prompt starts with '/' - execute slash commands natively
|
||||
if (prompt.startsWith('/')) {
|
||||
await executeSlashCommands(newText);
|
||||
return;
|
||||
}
|
||||
|
||||
newText = substituteParams(newText);
|
||||
|
||||
$("#send_textarea").val(newText);
|
||||
|
||||
// Set the focus back to the textarea
|
||||
|
@ -560,20 +560,26 @@ function saveQROrder() {
|
|||
});
|
||||
}
|
||||
|
||||
async function onMessageReceived() {
|
||||
async function onMessageReceived(index) {
|
||||
for (let i = 0; i < extension_settings.quickReply.numberOfSlots; i++) {
|
||||
const qr = extension_settings.quickReply.quickReplySlots[i];
|
||||
if (qr?.autoExecute_botMessage) {
|
||||
await sendQuickReply(i);
|
||||
const message = getContext().chat[index];
|
||||
if (message?.mes && message?.mes !== '...') {
|
||||
await sendQuickReply(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function onMessageSent() {
|
||||
async function onMessageSent(index) {
|
||||
for (let i = 0; i < extension_settings.quickReply.numberOfSlots; i++) {
|
||||
const qr = extension_settings.quickReply.quickReplySlots[i];
|
||||
if (qr?.autoExecute_userMessage) {
|
||||
await sendQuickReply(i);
|
||||
const message = getContext().chat[index];
|
||||
if (message?.mes && message?.mes !== '...') {
|
||||
await sendQuickReply(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class SlashCommandParser {
|
|||
const key = match[1];
|
||||
const value = match[2];
|
||||
// Remove the quotes around the value, if any
|
||||
argObj[key] = substituteParams(value.replace(/(^")|("$)/g, ''));
|
||||
argObj[key] = value.replace(/(^")|("$)/g, '');
|
||||
}
|
||||
|
||||
// Match unnamed argument
|
||||
|
@ -1048,10 +1048,14 @@ async function executeSlashCommands(text, unescape = false) {
|
|||
console.debug('Slash command executing:', result);
|
||||
let unnamedArg = result.value || pipeResult;
|
||||
|
||||
if (pipeResult && typeof result.args === 'object') {
|
||||
if (typeof result.args === 'object') {
|
||||
for (const [key, value] of Object.entries(result.args)) {
|
||||
if (typeof value === 'string' && /{{pipe}}/i.test(value)) {
|
||||
result.args[key] = value.replace(/{{pipe}}/i, pipeResult);
|
||||
if (typeof value === 'string') {
|
||||
if (pipeResult && /{{pipe}}/i.test(value)) {
|
||||
result.args[key] = value.replace(/{{pipe}}/i, pipeResult);
|
||||
}
|
||||
|
||||
result.args[key] = substituteParams(value.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue