diff --git a/public/scripts/extensions/quick-reply/contextMenuEditor.html b/public/scripts/extensions/quick-reply/contextMenuEditor.html
index 6f993ee70..bd52fbe81 100644
--- a/public/scripts/extensions/quick-reply/contextMenuEditor.html
+++ b/public/scripts/extensions/quick-reply/contextMenuEditor.html
@@ -19,6 +19,10 @@
Auto-Execute
+
-
diff --git a/public/scripts/extensions/quick-reply/index.js b/public/scripts/extensions/quick-reply/index.js
index 7cfeff4be..180da77cf 100644
--- a/public/scripts/extensions/quick-reply/index.js
+++ b/public/scripts/extensions/quick-reply/index.js
@@ -154,6 +154,7 @@ async function onQuickReplyCtxButtonClick(id) {
$('#quickReply_autoExecute_userMessage').prop('checked', qr.autoExecute_userMessage ?? false);
$('#quickReply_autoExecute_botMessage').prop('checked', qr.autoExecute_botMessage ?? false);
+ $('#quickReply_autoExecute_chatLoad').prop('checked', qr.autoExecute_chatLoad ?? false);
$('#quickReply_hidden').prop('checked', qr.hidden ?? false);
$('#quickReply_hidden').on('input', () => {
@@ -174,6 +175,12 @@ async function onQuickReplyCtxButtonClick(id) {
saveSettingsDebounced();
});
+ $('#quickReply_autoExecute_chatLoad').on('input', () => {
+ const state = !!$('#quickReply_autoExecute_chatLoad').prop('checked');
+ qr.autoExecute_chatLoad = state;
+ saveSettingsDebounced();
+ });
+
if (await popupResult) {
qr.contextMenu = Array.from(document.querySelectorAll('#quickReply_contextMenuEditor_content > .quickReplyContextMenuEditor_item'))
.map(item => ({
@@ -569,6 +576,11 @@ function saveQROrder() {
});
}
+/**
+ * Executes quick replies on message received.
+ * @param {number} index New message index
+ * @returns {Promise}
+ */
async function onMessageReceived(index) {
if (!extension_settings.quickReply.quickReplyEnabled) return;
@@ -583,6 +595,11 @@ async function onMessageReceived(index) {
}
}
+/**
+ * Executes quick replies on message sent.
+ * @param {number} index New message index
+ * @returns {Promise}
+ */
async function onMessageSent(index) {
if (!extension_settings.quickReply.quickReplyEnabled) return;
@@ -597,6 +614,22 @@ async function onMessageSent(index) {
}
}
+/**
+ * Executes quick replies on chat changed.
+ * @param {string} chatId New chat id
+ * @returns {Promise}
+ */
+async function onChatChanged(chatId) {
+ 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_chatLoad && chatId) {
+ await sendQuickReply(i);
+ }
+ }
+}
+
jQuery(async () => {
moduleWorker();
setInterval(moduleWorker, UPDATE_INTERVAL);
@@ -680,6 +713,7 @@ jQuery(async () => {
eventSource.on(event_types.MESSAGE_RECEIVED, onMessageReceived);
eventSource.on(event_types.MESSAGE_SENT, onMessageSent);
+ eventSource.on(event_types.CHAT_CHANGED, onChatChanged);
});
jQuery(() => {