diff --git a/Projects/Social-Bots/TS/Bot-Modules/Announcements.js b/Projects/Social-Bots/TS/Bot-Modules/Announcements.js index cac453b7ce..419fe900de 100644 --- a/Projects/Social-Bots/TS/Bot-Modules/Announcements.js +++ b/Projects/Social-Bots/TS/Bot-Modules/Announcements.js @@ -48,6 +48,21 @@ exports.newSocialBotsBotModulesAnnouncements = function (processIndex) { // set defaults, protect against empty configurations or missing values let onEnter = true let onExit = false + let intervalComplete = false + let intervalRunning = false + if (announcement.config.onInterval !== undefined) { + // Only start set interval on first run + if (intervalRunning === false) { + setInterval( + // Set to true after interval + function () { + intervalComplete = true + }, + announcement.config.onInterval + ) + intervalRunning = true + } + } if (announcement.config.onEnter !== undefined) { onEnter = announcement.config.onEnter } @@ -59,6 +74,9 @@ exports.newSocialBotsBotModulesAnnouncements = function (processIndex) { } if ((status === 'Open' && onEnter) || (status === 'Closed' && onExit)) { canAnnounce = true + } else if (intervalComplete === true) { + canAnnounce = true + intervalComplete = false // start interval over } else { canAnnounce = false }