Skip to content

Commit

Permalink
Merge pull request #4384 from harrellbm/develop
Browse files Browse the repository at this point in the history
Option to set interval of announcement
  • Loading branch information
harrellbm authored Oct 12, 2022
2 parents d59282e + 1a46844 commit fa2d114
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Projects/Social-Bots/TS/Bot-Modules/Announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit fa2d114

Please sign in to comment.