mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Quick Replies: Add auto-execute on new chat
This commit is contained in:
@ -83,6 +83,15 @@ export class AutoExecuteHandler {
|
||||
await this.performAutoExecute(qrList);
|
||||
}
|
||||
|
||||
async handleNewChat() {
|
||||
if (!this.checkExecute()) return;
|
||||
const qrList = [
|
||||
...this.settings.config.setList.map(link=>link.set.qrList.filter(qr=>qr.executeOnNewChat)).flat(),
|
||||
...(this.settings.chatConfig?.setList?.map(link=>link.set.qrList.filter(qr=>qr.executeOnNewChat))?.flat() ?? []),
|
||||
];
|
||||
await this.performAutoExecute(qrList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any[]} entries Set of activated entries
|
||||
*/
|
||||
|
@ -44,6 +44,7 @@ export class QuickReply {
|
||||
/**@type {boolean}*/ executeOnAi = false;
|
||||
/**@type {boolean}*/ executeOnChatChange = false;
|
||||
/**@type {boolean}*/ executeOnGroupMemberDraft = false;
|
||||
/**@type {boolean}*/ executeOnNewChat = false;
|
||||
/**@type {string}*/ automationId = '';
|
||||
|
||||
/**@type {function}*/ onExecute;
|
||||
@ -1061,6 +1062,13 @@ export class QuickReply {
|
||||
this.updateContext();
|
||||
});
|
||||
/**@type {HTMLInputElement}*/
|
||||
const executeOnNewChat = dom.querySelector('#qr--executeOnNewChat');
|
||||
executeOnNewChat.checked = this.executeOnNewChat;
|
||||
executeOnNewChat.addEventListener('click', ()=>{
|
||||
this.executeOnNewChat = executeOnNewChat.checked;
|
||||
this.updateContext();
|
||||
});
|
||||
/**@type {HTMLInputElement}*/
|
||||
const automationId = dom.querySelector('#qr--automationId');
|
||||
automationId.value = this.automationId;
|
||||
automationId.addEventListener('input', () => {
|
||||
|
Reference in New Issue
Block a user