2024-01-12 12:24:01 -05:00
|
|
|
function command_loop_manager (bot, options) {
|
2023-12-17 14:55:27 -05:00
|
|
|
bot.cloop = {
|
|
|
|
list: [],
|
|
|
|
|
|
|
|
add (command, interval) {
|
2024-01-26 21:24:08 -05:00
|
|
|
|
|
|
|
this.list.push({ timer: setInterval(() => bot.core.run(command), interval), command, interval })
|
2023-12-17 14:55:27 -05:00
|
|
|
},
|
|
|
|
|
2024-01-26 21:24:08 -05:00
|
|
|
/*
|
|
|
|
if (message.startsWith('/')) {
|
|
|
|
bot.command(message.substring(1))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
bot.chat(message)
|
|
|
|
*/
|
2023-12-17 14:55:27 -05:00
|
|
|
remove (index) {
|
|
|
|
clearInterval(this.list[index].timer)
|
|
|
|
},
|
|
|
|
|
|
|
|
clear () {
|
|
|
|
for (const cloop of this.list) clearInterval(cloop.timer)
|
|
|
|
|
|
|
|
this.list = []
|
|
|
|
}
|
|
|
|
}
|
2024-01-12 12:24:01 -05:00
|
|
|
|
2023-12-17 14:55:27 -05:00
|
|
|
}
|
|
|
|
|
2024-01-12 12:24:01 -05:00
|
|
|
module.exports = command_loop_manager
|