mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-07 14:43:30 +01:00
prevent inject on auto-execute
This commit is contained in:
parent
473326b3fb
commit
70d6e6d37f
@ -28,7 +28,7 @@ export class AutoExecuteHandler {
|
|||||||
for (const qr of qrList) {
|
for (const qr of qrList) {
|
||||||
this.preventAutoExecuteStack.push(qr.preventAutoExecute);
|
this.preventAutoExecuteStack.push(qr.preventAutoExecute);
|
||||||
try {
|
try {
|
||||||
await qr.onExecute();
|
await qr.execute({ isAutoExecute:true });
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
warn(ex);
|
warn(ex);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -464,7 +464,7 @@ export class QuickReply {
|
|||||||
const message = this.message.replace(/\{\{arg::([^}]+)\}\}/g, (_, key) => {
|
const message = this.message.replace(/\{\{arg::([^}]+)\}\}/g, (_, key) => {
|
||||||
return args[key] ?? '';
|
return args[key] ?? '';
|
||||||
});
|
});
|
||||||
this.onExecute(this, message);
|
this.onExecute(this, message, args.isAutoExecute ?? false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,12 +103,12 @@ export class QuickReplySet {
|
|||||||
* @param {QuickReply} qr
|
* @param {QuickReply} qr
|
||||||
* @param {String} [message] - optional altered message to be used
|
* @param {String} [message] - optional altered message to be used
|
||||||
*/
|
*/
|
||||||
async execute(qr, message = null) {
|
async execute(qr, message = null, isAutoExecute = false) {
|
||||||
/**@type {HTMLTextAreaElement}*/
|
/**@type {HTMLTextAreaElement}*/
|
||||||
const ta = document.querySelector('#send_textarea');
|
const ta = document.querySelector('#send_textarea');
|
||||||
const finalMessage = message ?? qr.message;
|
const finalMessage = message ?? qr.message;
|
||||||
let input = ta.value;
|
let input = ta.value;
|
||||||
if (this.injectInput && input.length > 0) {
|
if (!isAutoExecute && this.injectInput && input.length > 0) {
|
||||||
if (this.placeBeforeInput) {
|
if (this.placeBeforeInput) {
|
||||||
input = `${finalMessage} ${input}`;
|
input = `${finalMessage} ${input}`;
|
||||||
} else {
|
} else {
|
||||||
@ -152,7 +152,7 @@ export class QuickReplySet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hookQuickReply(qr) {
|
hookQuickReply(qr) {
|
||||||
qr.onExecute = (_, message)=>this.execute(qr, message);
|
qr.onExecute = (_, message, isAutoExecute)=>this.execute(qr, message, isAutoExecute);
|
||||||
qr.onDelete = ()=>this.removeQuickReply(qr);
|
qr.onDelete = ()=>this.removeQuickReply(qr);
|
||||||
qr.onUpdate = ()=>this.save();
|
qr.onUpdate = ()=>this.save();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user