feat: improved feature / cronjob system
Changes by silenium-dev Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
72670d4dd4
commit
15d2aec85e
3 changed files with 6 additions and 10 deletions
|
@ -44,6 +44,8 @@ object Bot {
|
||||||
//The kord object gets set at app launch
|
//The kord object gets set at app launch
|
||||||
lateinit var bot: ExtensibleBot
|
lateinit var bot: ExtensibleBot
|
||||||
|
|
||||||
|
private val jobs = mutableListOf<Job>()
|
||||||
|
|
||||||
@OptIn(PrivilegedIntent::class)
|
@OptIn(PrivilegedIntent::class)
|
||||||
suspend fun start() {
|
suspend fun start() {
|
||||||
Logger.out("Starting Bot...")
|
Logger.out("Starting Bot...")
|
||||||
|
@ -77,12 +79,6 @@ object Bot {
|
||||||
//PlanningNotifier.registerThread()
|
//PlanningNotifier.registerThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a shutdown hook to cancel the coroutine when the application is terminated
|
|
||||||
Runtime.getRuntime().addShutdownHook(Thread {
|
|
||||||
coroutineJob.cancel()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Add bot token to kord
|
// Add bot token to kord
|
||||||
bot = ExtensibleBot(CredentialManager.token) {
|
bot = ExtensibleBot(CredentialManager.token) {
|
||||||
applicationCommands {
|
applicationCommands {
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.jetbrains.exposed.sql.selectAll
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import java.time.ZonedDateTime
|
import java.time.ZonedDateTime
|
||||||
|
|
||||||
object AvailabilityManager {
|
object AvailabilityManager : IFeature {
|
||||||
|
|
||||||
// This runs during the cronjob.
|
// This runs during the cronjob.
|
||||||
@OptIn(PrivilegedIntent::class)
|
@OptIn(PrivilegedIntent::class)
|
||||||
|
@ -134,7 +134,7 @@ object AvailabilityManager {
|
||||||
Logger.out("Done! Until tomorrow! <3 ")
|
Logger.out("Done! Until tomorrow! <3 ")
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun registerThread() {
|
override suspend fun registerThread() {
|
||||||
Logger.out("Adding availability scheduler...")
|
Logger.out("Adding availability scheduler...")
|
||||||
val scheduler = buildSchedule("0 0 5 * * * 0o *w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
val scheduler = buildSchedule("0 0 5 * * * 0o *w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
||||||
scheduler.doInfinity {
|
scheduler.doInfinity {
|
||||||
|
|
|
@ -42,7 +42,7 @@ import java.time.ZoneId
|
||||||
import java.time.ZonedDateTime
|
import java.time.ZonedDateTime
|
||||||
|
|
||||||
|
|
||||||
object TimeManager {
|
object TimeManager : IFeature {
|
||||||
/* /--------------- Seconds
|
/* /--------------- Seconds
|
||||||
| /------------- Minutes
|
| /------------- Minutes
|
||||||
| | /----------- Hours
|
| | /----------- Hours
|
||||||
|
@ -53,7 +53,7 @@ object TimeManager {
|
||||||
| | | | | | | / (optional) Week days
|
| | | | | | | / (optional) Week days
|
||||||
* * * * * * 0o *w*/
|
* * * * * * 0o *w*/
|
||||||
|
|
||||||
suspend fun registerThread() {
|
override suspend fun registerThread() {
|
||||||
Logger.out("Adding message scheduler...")
|
Logger.out("Adding message scheduler...")
|
||||||
val scheduler = buildSchedule("0 0 4 * * * 0o 1w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
val scheduler = buildSchedule("0 0 4 * * * 0o 1w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
||||||
scheduler.doInfinity {
|
scheduler.doInfinity {
|
||||||
|
|
Loading…
Reference in a new issue