mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add QR auto-exec on app startup
This commit is contained in:
@ -285,6 +285,7 @@ window["SillyTavern"] = {};
|
|||||||
|
|
||||||
// Event source init
|
// Event source init
|
||||||
export const event_types = {
|
export const event_types = {
|
||||||
|
APP_READY: 'app_ready',
|
||||||
EXTRAS_CONNECTED: 'extras_connected',
|
EXTRAS_CONNECTED: 'extras_connected',
|
||||||
MESSAGE_SWIPED: 'message_swiped',
|
MESSAGE_SWIPED: 'message_swiped',
|
||||||
MESSAGE_SENT: 'message_sent',
|
MESSAGE_SENT: 'message_sent',
|
||||||
@ -744,6 +745,7 @@ async function firstLoadInit() {
|
|||||||
initCfg();
|
initCfg();
|
||||||
doDailyExtensionUpdatesCheck();
|
doDailyExtensionUpdatesCheck();
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
await eventSource.emit(event_types.APP_READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelStatusCheck() {
|
function cancelStatusCheck() {
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
<input type="checkbox" id="quickReply_hidden" >
|
<input type="checkbox" id="quickReply_hidden" >
|
||||||
<span><i class="fa-solid fa-fw fa-eye-slash"></i> Invisible (auto-execute only)</span>
|
<span><i class="fa-solid fa-fw fa-eye-slash"></i> Invisible (auto-execute only)</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="checkbox_label" for="quickReply_autoExecute_appStartup">
|
||||||
|
<input type="checkbox" id="quickReply_autoExecute_appStartup" >
|
||||||
|
<span><i class="fa-solid fa-fw fa-rocket"></i> Execute on app startup</span>
|
||||||
|
</label>
|
||||||
<label class="checkbox_label" for="quickReply_autoExecute_userMessage">
|
<label class="checkbox_label" for="quickReply_autoExecute_userMessage">
|
||||||
<input type="checkbox" id="quickReply_autoExecute_userMessage" >
|
<input type="checkbox" id="quickReply_autoExecute_userMessage" >
|
||||||
<span><i class="fa-solid fa-fw fa-user"></i> Execute on user message</span>
|
<span><i class="fa-solid fa-fw fa-user"></i> Execute on user message</span>
|
||||||
|
@ -155,6 +155,7 @@ async function onQuickReplyCtxButtonClick(id) {
|
|||||||
$('#quickReply_autoExecute_userMessage').prop('checked', qr.autoExecute_userMessage ?? false);
|
$('#quickReply_autoExecute_userMessage').prop('checked', qr.autoExecute_userMessage ?? false);
|
||||||
$('#quickReply_autoExecute_botMessage').prop('checked', qr.autoExecute_botMessage ?? false);
|
$('#quickReply_autoExecute_botMessage').prop('checked', qr.autoExecute_botMessage ?? false);
|
||||||
$('#quickReply_autoExecute_chatLoad').prop('checked', qr.autoExecute_chatLoad ?? false);
|
$('#quickReply_autoExecute_chatLoad').prop('checked', qr.autoExecute_chatLoad ?? false);
|
||||||
|
$('#quickReply_autoExecute_appStartup').prop('checked', qr.autoExecute_appStartup ?? false);
|
||||||
$('#quickReply_hidden').prop('checked', qr.hidden ?? false);
|
$('#quickReply_hidden').prop('checked', qr.hidden ?? false);
|
||||||
|
|
||||||
$('#quickReply_hidden').on('input', () => {
|
$('#quickReply_hidden').on('input', () => {
|
||||||
@ -163,6 +164,12 @@ async function onQuickReplyCtxButtonClick(id) {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#quickReply_autoExecute_appStartup').on('input', () => {
|
||||||
|
const state = !!$('#quickReply_autoExecute_appStartup').prop('checked');
|
||||||
|
qr.autoExecute_appStartup = state;
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
|
||||||
$('#quickReply_autoExecute_userMessage').on('input', () => {
|
$('#quickReply_autoExecute_userMessage').on('input', () => {
|
||||||
const state = !!$('#quickReply_autoExecute_userMessage').prop('checked');
|
const state = !!$('#quickReply_autoExecute_userMessage').prop('checked');
|
||||||
qr.autoExecute_userMessage = state;
|
qr.autoExecute_userMessage = state;
|
||||||
@ -647,6 +654,21 @@ async function onChatChanged(chatId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes quick replies on app ready.
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function onAppReady() {
|
||||||
|
if (!extension_settings.quickReply.quickReplyEnabled) return;
|
||||||
|
|
||||||
|
for (let i = 0; i < extension_settings.quickReply.numberOfSlots; i++) {
|
||||||
|
const qr = extension_settings.quickReply.quickReplySlots[i];
|
||||||
|
if (qr?.autoExecute_appStartup) {
|
||||||
|
await sendQuickReply(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jQuery(async () => {
|
jQuery(async () => {
|
||||||
moduleWorker();
|
moduleWorker();
|
||||||
setInterval(moduleWorker, UPDATE_INTERVAL);
|
setInterval(moduleWorker, UPDATE_INTERVAL);
|
||||||
@ -731,6 +753,7 @@ jQuery(async () => {
|
|||||||
eventSource.on(event_types.MESSAGE_RECEIVED, onMessageReceived);
|
eventSource.on(event_types.MESSAGE_RECEIVED, onMessageReceived);
|
||||||
eventSource.on(event_types.MESSAGE_SENT, onMessageSent);
|
eventSource.on(event_types.MESSAGE_SENT, onMessageSent);
|
||||||
eventSource.on(event_types.CHAT_CHANGED, onChatChanged);
|
eventSource.on(event_types.CHAT_CHANGED, onChatChanged);
|
||||||
|
eventSource.on(event_types.APP_READY, onAppReady);
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery(() => {
|
jQuery(() => {
|
||||||
|
Reference in New Issue
Block a user