mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
#1853 Add WI/Script link by entry automation id
This commit is contained in:
@ -82,4 +82,20 @@ export class AutoExecuteHandler {
|
||||
];
|
||||
await this.performAutoExecute(qrList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any[]} entries Set of activated entries
|
||||
*/
|
||||
async handleWIActivation(entries) {
|
||||
if (!this.checkExecute() || !Array.isArray(entries) || entries.length === 0) return;
|
||||
const automationIds = entries.map(entry => entry.automationId).filter(Boolean);
|
||||
if (automationIds.length === 0) return;
|
||||
|
||||
const qrList = [
|
||||
...this.settings.config.setList.map(link=>link.set.qrList.filter(qr=>qr.automationId && automationIds.includes(qr.automationId))).flat(),
|
||||
...(this.settings.chatConfig?.setList?.map(link=>link.set.qrList.filter(qr=>qr.automationId && automationIds.includes(qr.automationId)))?.flat() ?? []),
|
||||
];
|
||||
|
||||
await this.performAutoExecute(qrList);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ export class QuickReply {
|
||||
/**@type {Boolean}*/ executeOnAi = false;
|
||||
/**@type {Boolean}*/ executeOnChatChange = false;
|
||||
/**@type {Boolean}*/ executeOnGroupMemberDraft = false;
|
||||
/**@type {String}*/ automationId = '';
|
||||
|
||||
/**@type {Function}*/ onExecute;
|
||||
/**@type {Function}*/ onDelete;
|
||||
@ -359,6 +360,13 @@ export class QuickReply {
|
||||
this.executeOnGroupMemberDraft = executeOnGroupMemberDraft.checked;
|
||||
this.updateContext();
|
||||
});
|
||||
/**@type {HTMLInputElement}*/
|
||||
const automationId = dom.querySelector('#qr--automationId');
|
||||
automationId.value = this.automationId;
|
||||
automationId.addEventListener('input', () => {
|
||||
this.automationId = automationId.value;
|
||||
this.updateContext();
|
||||
});
|
||||
|
||||
/**@type {HTMLElement}*/
|
||||
const executeErrors = dom.querySelector('#qr--modal-executeErrors');
|
||||
@ -492,6 +500,7 @@ export class QuickReply {
|
||||
executeOnAi: this.executeOnAi,
|
||||
executeOnChatChange: this.executeOnChatChange,
|
||||
executeOnGroupMemberDraft: this.executeOnGroupMemberDraft,
|
||||
automationId: this.automationId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +150,7 @@ export class SlashCommandHandler {
|
||||
executeOnAi: isTrueBoolean(args.bot),
|
||||
executeOnChatChange: isTrueBoolean(args.load),
|
||||
executeOnGroupMemberDraft: isTrueBoolean(args.group),
|
||||
automationId: args.automationId ?? '',
|
||||
},
|
||||
);
|
||||
} catch (ex) {
|
||||
@ -171,6 +172,7 @@ export class SlashCommandHandler {
|
||||
executeOnAi: args.bot === undefined ? undefined : isTrueBoolean(args.bot),
|
||||
executeOnChatChange: args.load === undefined ? undefined : isTrueBoolean(args.load),
|
||||
executeOnGroupMemberDraft: args.group === undefined ? undefined : isTrueBoolean(args.group),
|
||||
automationId: args.automationId ?? '',
|
||||
},
|
||||
);
|
||||
} catch (ex) {
|
||||
|
Reference in New Issue
Block a user