feat!: updated rest of the code to use new API system

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2024-01-18 18:35:17 +01:00
parent abd17b3256
commit 894e03c9c6
Signed by: moonleay
GPG key ID: 82667543CCD715FB
3 changed files with 13 additions and 21 deletions

View file

@ -32,9 +32,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import net.moonleay.lilJudd.buttons.component.EditButtonManager
import net.moonleay.lilJudd.data.CredentialManager
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3Api
import net.moonleay.lilJudd.data.database.DB
import net.moonleay.lilJudd.extensions.*
import net.moonleay.lilJudd.features.AvailabilityManager
@ -173,7 +171,7 @@ object Bot {
}
// Update the Splatoon 3 api data and make sure it stays up-to-date
Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_CREATION_AT_STARTUP)
Splatoon3Api.updateSchedule()
JobManager.addJob(Splatoon3ApiScheduleUpdateScheduler)
/*
Other caches will be added when implemented
@ -183,10 +181,6 @@ object Bot {
// Had to disable bc of an error.
// Will fix when I have time
//JobManager.addJob(Splatoon3ApiFestivalAndCoopUpdateScheduler)
//JobManager.addJob(Splatoon3ApiSplatnetGearUpdateScheduler)
//Start the bot
bot.start()
}

View file

@ -20,9 +20,7 @@ package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3Api
import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
import net.moonleay.lilJudd.util.Logger
@ -40,8 +38,8 @@ object Splatoon3ApiScheduleUpdateScheduler : ICronjob {
override lateinit var scheduler: KronScheduler
override suspend fun jobFunction() {
Logger.out("Running Splatoon3ApiScheduleUpdateScheduler.")
Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_UPDATE)
Logger.out("Splatoon3ApiScheduleUpdateScheduler finished.")
Logger.out("Updating Schedules...")
Splatoon3Api.updateSchedule()
Logger.out("Updating finished.")
}
}

View file

@ -1,6 +1,6 @@
/*
* lilJudd
* Copyright (C) 2023 moonleay
* Copyright (C) 2024 moonleay
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,7 +22,7 @@ import dev.inmo.krontab.KronScheduler
import dev.kord.common.entity.PresenceStatus
import kotlinx.coroutines.Job
import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.data.api.Splatoon3Api
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiDataGrabber
import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
@ -56,11 +56,11 @@ object StatusUpdater : ICronjob {
private fun refreshStatusList(timestamp: Long) {
statusList = listOf(
Splatoon3Api.getRotationTime(timestamp),
Splatoon3Api.getRegularMapsFormatted(timestamp),
Splatoon3Api.getOpenMapFormatted(timestamp),
Splatoon3Api.getSeriesMapsFormatted(timestamp),
Splatoon3Api.getXMapFormatted(timestamp)
Splatoon3ApiDataGrabber.getRotationTime(timestamp),
Splatoon3ApiDataGrabber.getRegularMapsFormatted(timestamp),
Splatoon3ApiDataGrabber.getOpenMapFormatted(timestamp),
Splatoon3ApiDataGrabber.getSeriesMapsFormatted(timestamp),
Splatoon3ApiDataGrabber.getXMapFormatted(timestamp)
)
}
}