Move macros replacement to script execution time

This commit is contained in:
Cohee
2023-11-24 01:56:43 +02:00
parent 461e8d7929
commit 74fbc88d7d
2 changed files with 20 additions and 10 deletions

View File

@ -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);
}
}
}
}