Compare commits

..

No commits in common. "5bf19e578b2c5cf1d52dfdd4dcf8d90d99e7dbf0" and "f762e18b1fb0d5e9e9781f7e565d74bc1a5e0b8d" have entirely different histories.

49 changed files with 71 additions and 1476 deletions

View file

@ -32,14 +32,14 @@ val ownerID = 372703841151614976L
group = "net.moonleay.liljudd" group = "net.moonleay.liljudd"
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
?: "2.6.4" ?: "2.5.6"
val kordver = "1.5.9-SNAPSHOT" val kordver = "1.5.9-SNAPSHOT"
val coroutinesver = "1.7.3" val coroutinesver = "1.7.3"
val ktorver = "2.3.5" val ktor_version = "2.3.4"
val exposedver = "0.43.0" val exposedver = "0.43.0"
val postgresver = "42.6.0" val postgresver = "42.6.0"
val krontabver = "2.2.1" val krontabver = "2.2.0"
val mavenArtifact = "lilJudd" val mavenArtifact = "lilJudd"
project.base.archivesName.set(mavenArtifact) project.base.archivesName.set(mavenArtifact)
@ -89,8 +89,6 @@ implementation.extendsFrom(shadow)
dependencies { dependencies {
//Discord //Discord
shadow("com.kotlindiscord.kord.extensions:kord-extensions:$kordver") shadow("com.kotlindiscord.kord.extensions:kord-extensions:$kordver")
//Coroutines
shadow("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesver") shadow("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesver")
//Logging //Logging
@ -103,10 +101,10 @@ dependencies {
shadow("org.jetbrains.exposed:exposed-jdbc:$exposedver") shadow("org.jetbrains.exposed:exposed-jdbc:$exposedver")
shadow("org.postgresql:postgresql:$postgresver") shadow("org.postgresql:postgresql:$postgresver")
//Krontab //Korntab
shadow("dev.inmo:krontab:$krontabver") shadow("dev.inmo:krontab:$krontabver")
shadow("io.ktor:ktor-client-core-jvm:2.3.5") "shadow"("io.ktor:ktor-client-core-jvm:2.3.4")
shadow("io.ktor:ktor-client-cio-jvm:2.3.5") "shadow"("io.ktor:ktor-client-cio-jvm:2.3.4")
} }
@ -118,7 +116,7 @@ val templateProps = mapOf(
"ownerID" to ownerID, "ownerID" to ownerID,
"kordversion" to kordver, "kordversion" to kordver,
"coroutinesversion" to coroutinesver, "coroutinesversion" to coroutinesver,
"ktorversion" to ktorver, "ktorversion" to ktor_version,
"exposedversion" to exposedver, "exposedversion" to exposedver,
"postgresversion" to postgresver, "postgresversion" to postgresver,
"krontabversion" to krontabver "krontabversion" to krontabver

View file

@ -33,17 +33,11 @@ import kotlinx.coroutines.launch
import net.moonleay.botendo.build.BuildConstants import net.moonleay.botendo.build.BuildConstants
import net.moonleay.lilJudd.buttons.component.EditButtonManager import net.moonleay.lilJudd.buttons.component.EditButtonManager
import net.moonleay.lilJudd.data.CredentialManager import net.moonleay.lilJudd.data.CredentialManager
import net.moonleay.lilJudd.data.api.Splatoon3ApiCache import net.moonleay.lilJudd.data.DB
import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.data.database.DB
import net.moonleay.lilJudd.extensions.* import net.moonleay.lilJudd.extensions.*
import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.AvailabilityManager
import net.moonleay.lilJudd.features.MatchManager import net.moonleay.lilJudd.features.MatchManager
import net.moonleay.lilJudd.features.TimeManager import net.moonleay.lilJudd.features.TimeManager
import net.moonleay.lilJudd.jobs.Splatoon3ApiScheduleUpdateScheduler
import net.moonleay.lilJudd.jobs.StatusUpdater
import net.moonleay.lilJudd.jobs.component.JobManager
import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.EmbedColor
import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.Logger
import net.moonleay.lilJudd.util.MessageUtil import net.moonleay.lilJudd.util.MessageUtil
@ -105,7 +99,7 @@ object Bot {
} }
extensions { extensions {
add(::InfoExtension) add(::VersionExtension)
add(::FeatureManageExtension) add(::FeatureManageExtension)
add(::SendPlannerExtension) add(::SendPlannerExtension)
add(::MatchExtension) add(::MatchExtension)
@ -126,6 +120,7 @@ object Bot {
sharding { recommended -> sharding { recommended ->
Shards(recommended) Shards(recommended)
} */ } */
// Same goes for a Database table rewrite
} }
// Register button presses // Register button presses
@ -146,6 +141,7 @@ object Bot {
} }
if (inter.componentId.startsWith("public.message.")) { if (inter.componentId.startsWith("public.message.")) {
val response = inter.deferPublicResponse() val response = inter.deferPublicResponse()
val g = this.interaction.getOriginalInteractionResponse().getGuild()
response.respond { response.respond {
this.embeds = mutableListOf( this.embeds = mutableListOf(
MessageUtil.getEmbed( MessageUtil.getEmbed(
@ -163,20 +159,8 @@ object Bot {
bot.kordRef.on<ReadyEvent> { bot.kordRef.on<ReadyEvent> {
AvailabilityManager.runThread() // Update Availabilities AvailabilityManager.runThread() // Update Availabilities
MatchManager.update() // Update Matches MatchManager.update() // Update Matches
// Make the bot update the status every 6 seconds
JobManager.addJob(StatusUpdater)
} }
// Update the Splatoon 3 api data and make sure it stays up-to-date
Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_CREATION_AT_STARTUP)
JobManager.addJob(Splatoon3ApiScheduleUpdateScheduler)
/*
Other caches will be added when implemented
its not used yet in order to reduce load on the api,
which i am using.
*/
//JobManager.addJob(Splatoon3ApiFestivalAndCoopUpdateScheduler)
//JobManager.addJob(Splatoon3ApiSplatnetGearUpdateScheduler)
//Start the bot //Start the bot
bot.start() bot.start()

View file

@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.modify.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository
import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.EmbedUtil
import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.Logger
import net.moonleay.lilJudd.util.MessageUtil import net.moonleay.lilJudd.util.MessageUtil

View file

@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.modify.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository
import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.EmbedUtil
import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.Logger

View file

@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.modify.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository
import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.EmbedUtil
import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.Logger
import net.moonleay.lilJudd.util.MessageUtil import net.moonleay.lilJudd.util.MessageUtil

View file

@ -16,13 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database package net.moonleay.lilJudd.data
import net.moonleay.lilJudd.data.database.tables.MatchPlanningData import net.moonleay.lilJudd.data.tables.MatchPlanningData
import net.moonleay.lilJudd.data.database.tables.PlanningNotifierRoles import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles
import net.moonleay.lilJudd.data.database.tables.TimePlanningChannels import net.moonleay.lilJudd.data.tables.TimePlanningChannels
import net.moonleay.lilJudd.data.database.tables.TimePlanningMessages import net.moonleay.lilJudd.data.tables.TimePlanningMessages
import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.SchemaUtils import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction

View file

@ -1,117 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api
import net.moonleay.lilJudd.data.api.entry.schedule.ModeData
import net.moonleay.lilJudd.util.TimeUtil
object Splatoon3Api {
private fun getRegularMode(timestamp: Long): ModeData {
Splatoon3ApiCache.cachedRegularModeData.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
if (timestamp in startTime..endTime) {
return modeData
}
}
throw Exception("No current mode found")
}
private fun getOpenMode(timestamp: Long): ModeData {
Splatoon3ApiCache.cachedCompetitiveOpenModeData.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
if (timestamp in startTime..endTime) {
return modeData
}
}
throw Exception("No current mode found")
}
private fun getXMode(timestamp: Long): ModeData {
Splatoon3ApiCache.cachedXModeData.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
if (timestamp in startTime..endTime) {
return modeData
}
}
throw Exception("No current mode found")
}
private fun getSeriesMode(timestamp: Long): ModeData {
Splatoon3ApiCache.cachedCompetitiveSeriesModeData.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
if (timestamp in startTime..endTime) {
return modeData
}
}
throw Exception("No current mode found")
}
fun getRegularMapsFormatted(timestamp: Long): String {
val modeData = getRegularMode(timestamp)
val map1 = modeData.map1!!.name.split(" ")[0]
val map2 = modeData.map2!!.name.split(" ")[0]
return "R: $map1 & $map2"
}
fun getOpenModeFormatted(timestamp: Long): String {
val modeData = getOpenMode(timestamp)
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime)
return "O: ${modeData.ruleSetName} $diffStamp left"
}
fun getOpenMapFormatted(timestamp: Long): String {
val modeData = getOpenMode(timestamp)
val map1 = modeData.map1!!.name.split(" ")[0]
val map2 = modeData.map2!!.name.split(" ")[0]
return "O: $map1 & $map2"
}
fun getSeriesModeFormatted(timestamp: Long): String {
val modeData = getSeriesMode(timestamp)
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime)
return "S: ${modeData.ruleSetName} $diffStamp left"
}
fun getSeriesMapsFormatted(timestamp: Long): String {
val modeData = getSeriesMode(timestamp)
val map1 = modeData.map1!!.name.split(" ")[0]
val map2 = modeData.map2!!.name.split(" ")[0]
return "S: $map1 & $map2"
}
fun getXModeFormatted(timestamp: Long): String {
val modeData = getXMode(timestamp)
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime)
return "X: ${modeData.ruleSetName} $diffStamp left"
}
fun getXMapFormatted(timestamp: Long): String {
val modeData = getXMode(timestamp)
val map1 = modeData.map1!!.name.split(" ")[0]
val map2 = modeData.map2!!.name.split(" ")[0]
return "X: $map1 & $map2"
}
}

View file

@ -1,535 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api
import io.ktor.http.*
import kotlinx.serialization.json.*
import net.moonleay.botendo.build.BuildConstants
import net.moonleay.lilJudd.data.api.entry.coop.CoopGearData
import net.moonleay.lilJudd.data.api.entry.schedule.*
import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestColor
import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestData
import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamData
import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamResults
import net.moonleay.lilJudd.data.api.entry.splatnet.BrandData
import net.moonleay.lilJudd.data.api.entry.splatnet.GearAbilityData
import net.moonleay.lilJudd.data.api.entry.splatnet.SplatnetItemData
import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.util.Logger
import net.moonleay.lilJudd.util.NetUtil
object Splatoon3ApiCache {
private val user_agent =
"lilJudd/${BuildConstants.version} (${System.getProperty("os.name")}/${System.getProperty("os.version")}) [contact@moonleay.net]"
private val base_url = "https://splatoon3.ink/data/" // Thank god there is an API
internal var cachedSplatfestData = mutableListOf<SplatfestData>()
internal var cachedMapData = mutableMapOf<Int, MapData>()
internal var cachedRegularModeData = mutableListOf<ModeData>()
internal var cachedCompetitiveSeriesModeData = mutableListOf<ModeData>()
internal var cachedCompetitiveOpenModeData = mutableListOf<ModeData>()
internal var cachedXModeData = mutableListOf<ModeData>()
internal var cachedChallengesData = mutableListOf<ChallengeModeData>()
internal var cachedShiftData = mutableListOf<ShiftData>()
internal var cachedBigRunShiftData = mutableListOf<ShiftData>()
internal var cachedCoopRewardsData = mutableListOf<CoopGearData>()
internal var cachedSplatnetItemData = mutableListOf<SplatnetItemData>()
internal var cachedSplatnetLimitedItemData = mutableListOf<SplatnetItemData>()
internal lateinit var splatnetShopBrandData: BrandData
internal lateinit var splatnetShopNextBrandData: BrandData
fun updateData(dataType: ApiDataType, requestType: ApiRequestType) {
Logger.out("Updating data for $dataType with USER-AGENT: $user_agent")
Logger.out("Reason for update: $requestType")
when (dataType) {
ApiDataType.SCHEDULES -> {
updateScheduleCache(user_agent)
}
ApiDataType.SPLATNETGEAR -> {
updateSplatnetGearCache(user_agent)
}
ApiDataType.COOP -> {
updateCOOPCache(user_agent)
}
ApiDataType.SPLATFESTS -> {
updateSplatfestCache(user_agent)
}
ApiDataType.ALL -> {
updateScheduleCache(user_agent)
updateSplatnetGearCache(user_agent)
updateSplatfestCache(user_agent)
updateCOOPCache(user_agent)
}
}
Logger.out("Finished updating data for $dataType")
}
private fun updateSplatnetGearCache(uag: String) {
val apiResponse = NetUtil.GETJsonData("${base_url}gear.json", uag)
if (apiResponse.startsWith("Error")) {
Logger.out("Error getting splatnet data: $apiResponse")
return
}
val json = Json.parseToJsonElement(apiResponse)
val pickupBrandData = json.jsonObject["data"]!!.jsonObject["gesotown"]!!.jsonObject["pickupBrand"]!!.jsonObject
val brand = pickupBrandData["brand"]!!.jsonObject
splatnetShopBrandData =
BrandData(
brand["name"]!!.jsonPrimitive.content,
Url(pickupBrandData["image"]!!.jsonObject["url"]!!.jsonPrimitive.content),
GearAbilityData(
brand["usualGearPower"]!!.jsonObject["name"]!!.jsonPrimitive.content,
brand["usualGearPower"]!!.jsonObject["desc"]!!.jsonPrimitive.content,
Url(brand["usualGearPower"]!!.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
pickupBrandData["saleEndTime"]!!.jsonPrimitive.content
)
val nextBrand = pickupBrandData["nextBrand"]!!.jsonObject
splatnetShopNextBrandData =
BrandData(
nextBrand["name"]!!.jsonPrimitive.content,
Url(pickupBrandData["image"]!!.jsonObject["url"]!!.jsonPrimitive.content),
null,
null
)
cachedSplatnetItemData = mutableListOf()
val items = pickupBrandData["brandGears"]!!.jsonArray
items.forEach {
val obj = it as JsonObject
val gear = it["gear"]!!.jsonObject
val primaryGearPower = gear["primaryGearPower"]!!.jsonObject
val additionalGearPowers = gear["additionalGearPowers"]!!.jsonArray
val additionalGearPowersList = mutableListOf<GearAbilityData>()
additionalGearPowers.forEach {
val ob = it as JsonObject
additionalGearPowersList.add(
GearAbilityData(
ob["name"]!!.jsonPrimitive.content,
null,
Url(ob["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
)
)
}
cachedSplatnetItemData.add(
SplatnetItemData(
obj["saleEndTime"]!!.jsonPrimitive.content,
obj["price"]!!.jsonPrimitive.int,
gear["__typename"]!!.jsonPrimitive.content,
gear["name"]!!.jsonPrimitive.content,
GearAbilityData(
primaryGearPower["name"]!!.jsonPrimitive.content,
null,
Url(primaryGearPower["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
additionalGearPowersList,
Url(gear["image"]!!.jsonObject["url"]!!.jsonPrimitive.content),
splatnetShopBrandData
)
)
}
Logger.out("Updated gear data")
val limitedItemData = json.jsonObject["data"]!!.jsonObject["gesotown"]!!.jsonObject["limitedGears"]!!.jsonArray
cachedSplatnetLimitedItemData = mutableListOf()
limitedItemData.forEach {
val obj = it as JsonObject
val gear = obj["gear"]!!.jsonObject
val additionalGearPowers = gear["additionalGearPowers"]!!.jsonArray
val additionalGearPowersList = mutableListOf<GearAbilityData>()
additionalGearPowers.forEach {
val ob = it as JsonObject
additionalGearPowersList.add(
GearAbilityData(
ob["name"]!!.jsonPrimitive.content,
null,
Url(ob["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
)
)
}
cachedSplatnetLimitedItemData.add(
SplatnetItemData(
obj["saleEndTime"]!!.jsonPrimitive.content,
obj["price"]!!.jsonPrimitive.int,
gear["__typename"]!!.jsonPrimitive.content,
gear["name"]!!.jsonPrimitive.content,
GearAbilityData(
gear["primaryGearPower"]!!.jsonObject["name"]!!.jsonPrimitive.content,
null,
Url(gear["primaryGearPower"]!!.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
additionalGearPowersList,
Url(gear["image"]!!.jsonObject["url"]!!.jsonPrimitive.content),
splatnetShopBrandData
)
)
}
}
private fun updateCOOPCache(uag: String) {
val apiResponse = NetUtil.GETJsonData("${base_url}coop.json", uag)
if (apiResponse.startsWith("Error")) {
Logger.out("Error getting coop data: $apiResponse")
return
}
val json = Json.parseToJsonElement(apiResponse)
val data = json.jsonObject["data"]!!.jsonObject["coopResult"]!!.jsonObject["monthlyGear"]!!.jsonObject
cachedCoopRewardsData = mutableListOf()
cachedCoopRewardsData.add(
CoopGearData(
data["name"]!!.jsonPrimitive.content,
Url(data["image"]!!.jsonObject["url"]!!.jsonPrimitive.content),
data["__typename"]!!.jsonPrimitive.content
)
)
Logger.out("Updated COOP data")
}
private fun updateScheduleCache(uag: String) {
val apiResponse = NetUtil.GETJsonData("${base_url}schedules.json", uag)
if (apiResponse.startsWith("Error")) {
Logger.out("Error getting schedule data: $apiResponse")
return
}
val json = Json.decodeFromString(apiResponse) as JsonObject
val data = json["data"]!!.jsonObject
val mapList = data["vsStages"]!!.jsonObject["nodes"]!!.jsonArray
cachedMapData = mutableMapOf()
mapList.forEach {
val obj = it as JsonObject
val imageURL = Url(obj.jsonObject["originalImage"]!!.jsonObject["url"]!!.jsonPrimitive.content)
val id = obj.jsonObject["vsStageId"]!!.jsonPrimitive.int
cachedMapData[id] = MapData(
id,
imageURL,
it.jsonObject["name"]!!.jsonPrimitive.content
)
}
Logger.out("Updated maplist data")
val regularMatches = data["regularSchedules"]!!.jsonObject["nodes"]!!.jsonArray
cachedRegularModeData = mutableListOf()
regularMatches.forEach {
val obj = it as JsonObject
val setting = obj["regularMatchSetting"]!!.jsonObject
cachedRegularModeData.add(
ModeData(
obj["startTime"]!!.jsonPrimitive.content,
obj["endTime"]!!.jsonPrimitive.content,
setting["__typename"]!!.jsonPrimitive.content,
cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int],
cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int],
setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content,
setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content,
"TURF_WAR"
)
)
}
Logger.out("Updated Regular match data")
val compMatches = data["bankaraSchedules"]!!.jsonObject["nodes"]!!.jsonArray
cachedCompetitiveSeriesModeData = mutableListOf()
cachedCompetitiveOpenModeData = mutableListOf()
compMatches.forEach {
val obj = it as JsonObject
val setting = obj["bankaraMatchSettings"]!!.jsonArray
setting.forEach {
val ob = it as JsonObject
val mode = ob["bankaraMode"]!!.jsonPrimitive.content
if (mode == "CHALLENGE") {
cachedCompetitiveSeriesModeData.add(
ModeData(
obj["startTime"]!!.jsonPrimitive.content,
obj["endTime"]!!.jsonPrimitive.content,
ob["__typename"]!!.jsonPrimitive.content,
cachedMapData[ob["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int],
cachedMapData[ob["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int],
ob["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content,
ob["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content,
mode
)
)
} else if (mode == "OPEN") {
cachedCompetitiveOpenModeData.add(
ModeData(
obj["startTime"]!!.jsonPrimitive.content,
obj["endTime"]!!.jsonPrimitive.content,
ob["__typename"]!!.jsonPrimitive.content,
cachedMapData[ob["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int],
cachedMapData[ob["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int],
ob["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content,
ob["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content,
mode
)
)
}
}
}
Logger.out("Updated Competitive match data")
val xMatches = data["xSchedules"]!!.jsonObject["nodes"]!!.jsonArray
cachedXModeData = mutableListOf()
xMatches.forEach {
val obj = it as JsonObject
val setting = obj["xMatchSetting"]!!.jsonObject
cachedXModeData.add(
ModeData(
obj["startTime"]!!.jsonPrimitive.content,
obj["endTime"]!!.jsonPrimitive.content,
setting["__typename"]!!.jsonPrimitive.content,
cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int],
cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int],
setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content,
setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content,
"X"
)
)
}
Logger.out("Updated X match data")
val challengeData = data["eventSchedules"]!!.jsonObject["nodes"]!!.jsonArray
cachedChallengesData = mutableListOf()
challengeData.forEach {
val obj = it as JsonObject
val tpd = obj["timePeriods"]!!.jsonArray
val setting = obj["leagueMatchSetting"]!!.jsonObject
val event = setting["leagueMatchEvent"]!!.jsonObject
cachedChallengesData.add(
ChallengeModeData(
event["leagueMatchEventId"]!!.jsonPrimitive.content,
event["name"]!!.jsonPrimitive.content,
event["desc"]!!.jsonPrimitive.content,
event["regulation"]!!.jsonPrimitive.content,
cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int],
cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int],
setting["__typename"]!!.jsonPrimitive.content,
setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content,
setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content,
TimePeriodData(
tpd[0].jsonObject["startTime"]!!.jsonPrimitive.content,
tpd[0].jsonObject["endTime"]!!.jsonPrimitive.content
),
TimePeriodData(
tpd[1].jsonObject["startTime"]!!.jsonPrimitive.content,
tpd[1].jsonObject["endTime"]!!.jsonPrimitive.content
),
TimePeriodData(
tpd[2].jsonObject["startTime"]!!.jsonPrimitive.content,
tpd[2].jsonObject["endTime"]!!.jsonPrimitive.content
)
)
)
}
Logger.out("Updated Challenge data")
val shiftData = data["coopGroupingSchedule"]!!.jsonObject["regularSchedules"]!!.jsonObject["nodes"]!!.jsonArray
cachedShiftData = mutableListOf()
shiftData.forEach {
val obj = it as JsonObject
val setting = obj["setting"]!!.jsonObject
val stage = setting["coopStage"]!!.jsonObject
val weapons = setting["weapons"]!!.jsonArray
cachedShiftData.add(
ShiftData(
obj["startTime"]!!.jsonPrimitive.content,
obj["endTime"]!!.jsonPrimitive.content,
obj["__splatoon3ink_king_salmonid_guess"]!!.jsonPrimitive.content,
setting["__typename"]!!.jsonPrimitive.content,
stage["name"]!!.jsonPrimitive.content,
Url(stage["image"]!!.jsonObject["url"]!!.jsonPrimitive.content),
WeaponData(
weapons[0].jsonObject["name"]!!.jsonPrimitive.content,
Url(weapons[0].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
WeaponData(
weapons[1].jsonObject["name"]!!.jsonPrimitive.content,
Url(weapons[1].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
WeaponData(
weapons[2].jsonObject["name"]!!.jsonPrimitive.content,
Url(weapons[2].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
WeaponData(
weapons[3].jsonObject["name"]!!.jsonPrimitive.content,
Url(weapons[3].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
)
)
)
}
val bigRunData = data["coopGroupingSchedule"]!!.jsonObject["bigRunSchedules"]!!.jsonObject["nodes"]!!.jsonArray
cachedBigRunShiftData = mutableListOf()
bigRunData.forEach {
val obj = it as JsonObject
val setting = obj["setting"]!!.jsonObject
val stage = setting["coopStage"]!!.jsonObject
val weapons = setting["weapons"]!!.jsonArray
cachedBigRunShiftData.add(
ShiftData(
obj["startTime"]!!.jsonPrimitive.content,
obj["endTime"]!!.jsonPrimitive.content,
obj["__splatoon3ink_king_salmonid_guess"]!!.jsonPrimitive.content,
setting["__typename"]!!.jsonPrimitive.content,
stage["name"]!!.jsonPrimitive.content,
Url(stage["image"]!!.jsonObject["url"]!!.jsonPrimitive.content),
WeaponData(
weapons[0].jsonObject["name"]!!.jsonPrimitive.content,
Url(weapons[0].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
WeaponData(
weapons[1].jsonObject["name"]!!.jsonPrimitive.content,
Url(weapons[1].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
WeaponData(
weapons[2].jsonObject["name"]!!.jsonPrimitive.content,
Url(weapons[2].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
),
WeaponData(
weapons[3].jsonObject["name"]!!.jsonPrimitive.content,
Url(weapons[3].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content)
)
)
)
}
Logger.out("Updated big run data")
Logger.out("Updated all Schedules")
}
private fun updateSplatfestCache(uag: String) {
val apiResponse = NetUtil.GETJsonData("${base_url}festivals.json", uag)
if (apiResponse.startsWith("Error")) {
Logger.out("Error getting splatfest data: $apiResponse")
return
}
val json = Json.decodeFromString(apiResponse) as JsonObject
val festivals = json["US"]!!.jsonObject["data"]!!.jsonObject["festRecords"]!!.jsonObject["nodes"]!!.jsonArray
cachedSplatfestData = mutableListOf()
festivals.forEach {
val fest = it as JsonObject
val teams = fest.jsonObject["teams"]!!.jsonArray
val team1 = teams[0].jsonObject
val team1Color = team1["color"]!!.jsonObject
var team1Result: JsonObject? = null
if (team1["result"] !is JsonNull) {
team1Result = team1["result"]!!.jsonObject
}
val team2 = teams[1].jsonObject
val team2Color = team2["color"]!!.jsonObject
var team2Result: JsonObject? = null
if (team2["result"] !is JsonNull) {
team2Result = team2["result"]!!.jsonObject
}
val team3 = teams[2].jsonObject
val team3Color = team3["color"]!!.jsonObject
var team3Result: JsonObject? = null
if (team3["result"] !is JsonNull) {
team3Result = team3["result"]!!.jsonObject
}
cachedSplatfestData.add(
SplatfestData(
fest.jsonObject["id"]!!.jsonPrimitive.content,
fest.jsonObject["state"]!!.jsonPrimitive.content,
fest.jsonObject["startTime"]!!.jsonPrimitive.content,
fest.jsonObject["endTime"]!!.jsonPrimitive.content,
fest.jsonObject["title"]!!.jsonPrimitive.content,
Url(fest.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content),
SplatfestTeamData(
team1["teamName"]!!.jsonPrimitive.content,
SplatfestColor(
team1Color["a"]!!.jsonPrimitive.int,
team1Color["b"]!!.jsonPrimitive.double,
team1Color["g"]!!.jsonPrimitive.double,
team1Color["r"]!!.jsonPrimitive.double
),
if (team1Result.isNullOrEmpty() || team1Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null)
null
else SplatfestTeamResults(
team1Result["isWinner"]!!.jsonPrimitive.boolean,
team1Result["horagaiRatio"]!!.jsonPrimitive.double,
team1Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean,
team1Result["voteRatio"]!!.jsonPrimitive.double,
team1Result["isVoteRatioTop"]!!.jsonPrimitive.boolean,
team1Result["regularContributionRatio"]!!.jsonPrimitive.double,
team1Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean,
team1Result["challengeContributionRatio"]!!.jsonPrimitive.double,
team1Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean,
team1Result["tricolorContributionRatio"]!!.jsonPrimitive.double,
team1Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean,
)
),
SplatfestTeamData(
team2["teamName"]!!.jsonPrimitive.content,
SplatfestColor(
team2Color["a"]!!.jsonPrimitive.int,
team2Color["b"]!!.jsonPrimitive.double,
team2Color["g"]!!.jsonPrimitive.double,
team2Color["r"]!!.jsonPrimitive.double
),
if (team2Result.isNullOrEmpty() || team2Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null)
null
else SplatfestTeamResults(
team2Result["isWinner"]!!.jsonPrimitive.boolean,
team2Result["horagaiRatio"]!!.jsonPrimitive.double,
team2Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean,
team2Result["voteRatio"]!!.jsonPrimitive.double,
team2Result["isVoteRatioTop"]!!.jsonPrimitive.boolean,
team2Result["regularContributionRatio"]!!.jsonPrimitive.double,
team2Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean,
team2Result["challengeContributionRatio"]!!.jsonPrimitive.double,
team2Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean,
team2Result["tricolorContributionRatio"]!!.jsonPrimitive.double,
team2Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean,
)
),
SplatfestTeamData(
team3["teamName"]!!.jsonPrimitive.content,
SplatfestColor(
team3Color["a"]!!.jsonPrimitive.int,
team3Color["b"]!!.jsonPrimitive.double,
team3Color["g"]!!.jsonPrimitive.double,
team3Color["r"]!!.jsonPrimitive.double
),
if (team3Result.isNullOrEmpty() || team3Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null)
null
else SplatfestTeamResults(
team3Result["isWinner"]!!.jsonPrimitive.boolean,
team3Result["horagaiRatio"]!!.jsonPrimitive.double,
team3Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean,
team3Result["voteRatio"]!!.jsonPrimitive.double,
team3Result["isVoteRatioTop"]!!.jsonPrimitive.boolean,
team3Result["regularContributionRatio"]!!.jsonPrimitive.double,
team3Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean,
team3Result["challengeContributionRatio"]!!.jsonPrimitive.double,
team3Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean,
team3Result["tricolorContributionRatio"]!!.jsonPrimitive.double,
team3Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean,
)
),
)
)
}
Logger.out("Updated Splatfest data")
}
}

View file

@ -1,28 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.coop
import io.ktor.http.*
data class CoopGearData(
val name: String,
val image: Url,
val __typename: String,
)

View file

@ -1,34 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.schedule
data class ChallengeModeData(
val leagueMatchEventId: String,
val name: String,
val description: String,
val regulation: String,
val map1: MapData?,
val map2: MapData?,
val __typename: String,
val ruleSet: String,
val ruleSetName: String,
val timePeriod1: TimePeriodData,
val timePeriod2: TimePeriodData,
val timePeriod3: TimePeriodData,
)

View file

@ -1,27 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.schedule
import io.ktor.http.*
data class MapData(
val stageID: Int,
val image: Url,
val name: String,
)

View file

@ -1,30 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.schedule
data class ModeData(
val startTime: String,
val endTime: String,
val matchType: String,
val map1: MapData?,
val map2: MapData?,
val ruleSetName: String,
val ruleSet: String,
val mode: String,
)

View file

@ -1,34 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.schedule
import io.ktor.http.*
data class ShiftData(
val startTime: String,
val endTime: String,
val __splatoon3ink_king_salmonid_guess: String,
val __typename: String,
val stageName: String,
val image: Url,
val weapon1: WeaponData,
val weapon2: WeaponData,
val weapon3: WeaponData,
val weapon4: WeaponData,
)

View file

@ -1,24 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.schedule
data class TimePeriodData(
val startTime: String,
val endTime: String,
)

View file

@ -1,26 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.schedule
import io.ktor.http.*
data class WeaponData(
val name: String,
val image: Url,
)

View file

@ -1,26 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.splatfest
data class SplatfestColor(
val a: Int,
val b: Double,
val g: Double,
val r: Double,
)

View file

@ -1,33 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.splatfest
import io.ktor.http.*
data class SplatfestData(
val id: String,
val state: String,
val startTime: String,
val endTime: String,
val title: String,
val image: Url,
val team1: SplatfestTeamData,
val team2: SplatfestTeamData,
val team3: SplatfestTeamData,
)

View file

@ -1,25 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.splatfest
data class SplatfestTeamData(
val teamName: String,
val color: SplatfestColor,
val results: SplatfestTeamResults?,
)

View file

@ -1,33 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.splatfest
data class SplatfestTeamResults(
val isWinner: Boolean,
val horagaiRatio: Double,
val horagaiRatioTop: Boolean,
val voteRatio: Double,
val voteRatioTop: Boolean,
val regularRatio: Double,
val regularRatioTop: Boolean,
val challengeRatio: Double,
val challengeRatioTop: Boolean,
val tricolorRatio: Double,
val tricolorRatioTop: Boolean,
)

View file

@ -1,28 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.splatnet
import io.ktor.http.*
data class BrandData(
val name: String,
val image: Url,
val usualGearPower: GearAbilityData?,
val saleEndTime: String?,
)

View file

@ -1,27 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.splatnet
import io.ktor.http.*
data class GearAbilityData(
val name: String,
val description: String?,
val image: Url,
)

View file

@ -1,32 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.entry.splatnet
import io.ktor.http.*
data class SplatnetItemData(
val saleEndTime: String,
val price: Int,
val typeName: String,
val name: String,
val primaryGearPower: GearAbilityData,
val additionalGearPowers: List<GearAbilityData>,
val image: Url,
val brand: BrandData,
)

View file

@ -1,27 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.type
enum class ApiDataType {
SCHEDULES,
SPLATNETGEAR,
COOP,
SPLATFESTS,
ALL
}

View file

@ -1,26 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.data.api.type
enum class ApiRequestType(val nameToDisplay: String) {
AUTOMATIC_CACHE_UPDATE("automatic request to update the cache"),
AUTOMATIC_CACHE_CREATION_AT_STARTUP("automatic request to create cache at startup"),
MANUAL("manual request"),
DEBUG("debug request")
}

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.entry package net.moonleay.lilJudd.data.entry
data class MatchPlanningDataData( data class MatchPlanningDataData(
val id: Int, val id: Int,

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.entry package net.moonleay.lilJudd.data.entry
data class PlanningNotifierRolesData( data class PlanningNotifierRolesData(
val id: Int, // The id of the entry val id: Int, // The id of the entry

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.entry package net.moonleay.lilJudd.data.entry
data class TimePlanningChannelsData( data class TimePlanningChannelsData(
val id: Int, val id: Int,

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.entry package net.moonleay.lilJudd.data.entry
data class TimePlanningMessagesData( data class TimePlanningMessagesData(
val id: Int, // The id of the entry val id: Int, // The id of the entry

View file

@ -16,10 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.repository package net.moonleay.lilJudd.data.repository
import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData import net.moonleay.lilJudd.data.entry.MatchPlanningDataData
import net.moonleay.lilJudd.data.database.tables.MatchPlanningData import net.moonleay.lilJudd.data.tables.MatchPlanningData
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction

View file

@ -16,10 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.repository package net.moonleay.lilJudd.data.repository
import net.moonleay.lilJudd.data.database.entry.PlanningNotifierRolesData import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData
import net.moonleay.lilJudd.data.database.tables.PlanningNotifierRoles import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction

View file

@ -16,10 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.repository package net.moonleay.lilJudd.data.repository
import net.moonleay.lilJudd.data.database.entry.TimePlanningChannelsData import net.moonleay.lilJudd.data.entry.TimePlanningChannelsData
import net.moonleay.lilJudd.data.database.tables.TimePlanningChannels import net.moonleay.lilJudd.data.tables.TimePlanningChannels
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction

View file

@ -16,10 +16,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.repository package net.moonleay.lilJudd.data.repository
import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData
import net.moonleay.lilJudd.data.database.tables.TimePlanningMessages import net.moonleay.lilJudd.data.tables.TimePlanningMessages
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.select

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.tables package net.moonleay.lilJudd.data.tables
import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.Table

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.tables package net.moonleay.lilJudd.data.tables
import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.Table

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.tables package net.moonleay.lilJudd.data.tables
import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.Table

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.moonleay.lilJudd.data.database.tables package net.moonleay.lilJudd.data.tables
import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.Table

View file

@ -28,8 +28,8 @@ import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.core.behavior.channel.createMessage import dev.kord.core.behavior.channel.createMessage
import dev.kord.core.behavior.createRole import dev.kord.core.behavior.createRole
import dev.kord.rest.builder.message.create.actionRow import dev.kord.rest.builder.message.create.actionRow
import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData import net.moonleay.lilJudd.data.entry.MatchPlanningDataData
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository
import net.moonleay.lilJudd.extensions.component.MatchTypes import net.moonleay.lilJudd.extensions.component.MatchTypes
import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.MatchJob
import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.jobs.component.JobManager

View file

@ -26,8 +26,8 @@ import dev.kord.common.entity.Permission
import dev.kord.core.behavior.channel.createMessage import dev.kord.core.behavior.channel.createMessage
import dev.kord.rest.builder.message.create.actionRow import dev.kord.rest.builder.message.create.actionRow
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData
import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository
import net.moonleay.lilJudd.util.* import net.moonleay.lilJudd.util.*
import java.time.ZoneId import java.time.ZoneId
import java.time.ZonedDateTime import java.time.ZonedDateTime
@ -105,7 +105,7 @@ class SendPlannerExtension : Extension() {
-1, -1,
c.data.guildId.value?.value!!.toLong(), c.data.guildId.value?.value!!.toLong(),
c.id.value.toLong(), c.id.value.toLong(),
(TimeUtil.getWeekStamp().toEpochSecond()), (TimeUtil.getWeekStamp().toEpochSecond() * 1000),
msgStr msgStr
) )
) )

View file

@ -24,11 +24,11 @@ import net.moonleay.botendo.build.BuildConstants
import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.EmbedColor
import net.moonleay.lilJudd.util.MessageUtil import net.moonleay.lilJudd.util.MessageUtil
class InfoExtension : Extension() { class VersionExtension : Extension() {
override val name = "info" override val name = "version"
override suspend fun setup() { override suspend fun setup() {
publicSlashCommand { publicSlashCommand {
name = "info" name = "version"
description = "Show infos about the bot" description = "Show infos about the bot"
this.action { this.action {
MessageUtil.sendEmbedForPublicSlashCommand( MessageUtil.sendEmbedForPublicSlashCommand(
@ -38,8 +38,7 @@ class InfoExtension : Extension() {
"Lil' Judd ***v." + BuildConstants.version + "***\n" + "Lil' Judd ***v." + BuildConstants.version + "***\n" +
"Kord-Extensions ***v." + BuildConstants.kordVersion + "***\n" + "Kord-Extensions ***v." + BuildConstants.kordVersion + "***\n" +
"Coroutines ***v." + BuildConstants.coroutinesVersion + "***\n" + "Coroutines ***v." + BuildConstants.coroutinesVersion + "***\n" +
"Krontab ***v." + BuildConstants.krontabVersion + "***\n\n" + "Krontab ***v." + BuildConstants.krontabVersion + "***"
"Splatoon 3 api data provided by splatoon3.ink"
) )
} }
} }

View file

@ -30,10 +30,10 @@ import dev.kord.core.entity.channel.MessageChannel
import dev.kord.gateway.PrivilegedIntent import dev.kord.gateway.PrivilegedIntent
import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.EmbedBuilder
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.data.database.entry.PlanningNotifierRolesData import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData
import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData
import net.moonleay.lilJudd.data.database.repository.PlanningNotifierRolesRepository import net.moonleay.lilJudd.data.repository.PlanningNotifierRolesRepository
import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository
import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.extensions.FeatureManageExtension
import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.FeatureEnum
import net.moonleay.lilJudd.features.component.IFeature import net.moonleay.lilJudd.features.component.IFeature
@ -47,21 +47,18 @@ object AvailabilityManager : IFeature {
Logger.out("Starting to update roles...") Logger.out("Starting to update roles...")
// ChannelID, Data // ChannelID, Data
val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond()) val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond() * 1000)
.associateBy { it.channelID } .associateBy { it.channelID }
val targetedRoles = PlanningNotifierRolesRepository.getAll().associateBy { it.channelID } val targetedRoles = PlanningNotifierRolesRepository.getAll().associateBy { it.channelID }
if (targetedRoles.isEmpty()) {
Logger.out("No saved roles. Canceling.")
return
}
for (id in messages.keys) { for (id in messages.keys) {
val snf = Snowflake(id) // snf = Snowflake val snf = Snowflake(id) // snf = Snowflake
val data = messages[id]!! // this is the data of the table val data = messages[id]!! // this is the data of the table
if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) { if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null)
// This channel does not exist anymore. continue // This channel does not exist anymore.
Logger.out("Warning: Channel ${data.channelID} does not exist anymore. Skipping.") if (targetedRoles.isEmpty()) {
continue Logger.out("No saved roles. Canceling.")
return
} }
val roleData = targetedRoles[data.channelID] // Get the role data val roleData = targetedRoles[data.channelID] // Get the role data
if (roleData == null) { if (roleData == null) {
@ -74,17 +71,15 @@ object AvailabilityManager : IFeature {
} }
suspend fun updateInChannel(snf: Snowflake) { suspend fun updateInChannel(snf: Snowflake) {
val stamp = TimeUtil.getWeekStamp().toEpochSecond()
Logger.out("Weekstamp: $stamp")
val messageData = TimePlanningMessagesRepository.getWeekInChannel( val messageData = TimePlanningMessagesRepository.getWeekInChannel(
stamp, TimeUtil.getWeekStamp().toEpochSecond() * 1000,
snf.value.toLong() snf.value.toLong()
) )
val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong())
if (messageData == null) { if (messageData == null) {
Logger.out("Could not find data for channel ${snf.value}") Logger.out("Could not find data for channel ${snf.value}")
return return
} }
val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong())
if (roleData == null) { if (roleData == null) {
Logger.out("Role for channel ${messageData.channelID} does not exist") Logger.out("Role for channel ${messageData.channelID} does not exist")
return // this took way to long to find out that this was the issue return // this took way to long to find out that this was the issue
@ -98,7 +93,7 @@ object AvailabilityManager : IFeature {
return // This channel does not exist anymore. return // This channel does not exist anymore.
val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(snf)!! // Get the channel as MessageChannel val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(snf)!! // Get the channel as MessageChannel
val weekday = ZonedDateTime.now().dayOfWeek // The current week day val weekday = ZonedDateTime.now().dayOfWeek // The current week day
val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() // The current week time stamp val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp
Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.")
val g = Bot.bot.kordRef.getGuild(Snowflake(tpmd.serverID)) val g = Bot.bot.kordRef.getGuild(Snowflake(tpmd.serverID))
// Get all members with the role // Get all members with the role

View file

@ -20,8 +20,8 @@ package net.moonleay.lilJudd.features
import dev.kord.common.entity.Snowflake import dev.kord.common.entity.Snowflake
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData import net.moonleay.lilJudd.data.entry.MatchPlanningDataData
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository
import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.MatchJob
import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.jobs.component.JobManager
import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.Logger

View file

@ -29,11 +29,11 @@ import dev.kord.rest.builder.message.EmbedBuilder
import dev.kord.rest.builder.message.create.actionRow import dev.kord.rest.builder.message.create.actionRow
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.data.database.entry.TimePlanningChannelsData import net.moonleay.lilJudd.data.entry.TimePlanningChannelsData
import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData
import net.moonleay.lilJudd.data.database.repository.PlanningNotifierRolesRepository import net.moonleay.lilJudd.data.repository.PlanningNotifierRolesRepository
import net.moonleay.lilJudd.data.database.repository.TimePlanningChannelsRepository import net.moonleay.lilJudd.data.repository.TimePlanningChannelsRepository
import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository
import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.extensions.FeatureManageExtension
import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.FeatureEnum
import net.moonleay.lilJudd.features.component.IFeature import net.moonleay.lilJudd.features.component.IFeature

View file

@ -22,7 +22,7 @@ import dev.inmo.krontab.KronScheduler
import dev.kord.common.entity.Snowflake import dev.kord.common.entity.Snowflake
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository
import net.moonleay.lilJudd.jobs.component.CronjobType import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob import net.moonleay.lilJudd.jobs.component.ICronjob
import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.jobs.component.JobManager

View file

@ -1,50 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
import net.moonleay.lilJudd.util.Logger
object Splatoon3ApiFestivalAndCoopUpdateScheduler : ICronjob {
override val jobName: String
get() = "Splatoon3ApiFestivalAndCoopUpdateScheduler"
override val jobIncoming: String
get() = "0 0 0 /1 * * 0o *" // once a day
override val jobType: CronjobType
get() = CronjobType.INFINITE
override val continueJob: Boolean
get() = true
override lateinit var cronjobJob: Job
override lateinit var scheduler: KronScheduler
override suspend fun jobFunction() {
Logger.out("Running Splatoon3ApiFestivalUpdateScheduler.")
Splatoon3ApiCache.updateData(ApiDataType.SPLATFESTS, ApiRequestType.AUTOMATIC_CACHE_UPDATE)
Logger.out("Splatoon3ApiFestivalUpdateScheduler finished.")
Logger.out("Running Splatoon3ApiCoopUpdateScheduler.")
Splatoon3ApiCache.updateData(ApiDataType.COOP, ApiRequestType.AUTOMATIC_CACHE_UPDATE)
Logger.out("Splatoon3ApiCoopUpdateScheduler finished.")
}
}

View file

@ -1,47 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
import net.moonleay.lilJudd.util.Logger
object Splatoon3ApiScheduleUpdateScheduler : ICronjob {
override val jobName: String
get() = "Splatoon3ApiScheduleUpdateScheduler"
override val jobIncoming: String
get() = "0 0 /1 * * * 0o *" //Every hour
override val jobType: CronjobType
get() = CronjobType.INFINITE
override val continueJob: Boolean
get() = true
override lateinit var cronjobJob: Job
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.")
}
}

View file

@ -1,47 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
import net.moonleay.lilJudd.util.Logger
object Splatoon3ApiSplatnetGearUpdateScheduler : ICronjob {
override val jobName: String
get() = "Splatoon3ApiSplatnetGearUpdateScheduler"
override val jobIncoming: String
get() = "0 0 /6 * * * 0o *" //Every 6 hours
override val jobType: CronjobType
get() = CronjobType.INFINITE
override val continueJob: Boolean
get() = true
override lateinit var cronjobJob: Job
override lateinit var scheduler: KronScheduler
override suspend fun jobFunction() {
Logger.out("Running Splatoon3ApiSplatnetGearUpdateScheduler.")
Splatoon3ApiCache.updateData(ApiDataType.SPLATNETGEAR, ApiRequestType.AUTOMATIC_CACHE_UPDATE)
Logger.out("Splatoon3ApiSplatnetGearUpdateScheduler finished.")
}
}

View file

@ -1,67 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.jobs
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.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
object StatusUpdater : ICronjob {
override val jobName: String
get() = "StatusUpdater"
override val jobIncoming: String
get() = "/5 * * * * * 0o *" //Every 5 seconds
override val jobType: CronjobType
get() = CronjobType.INFINITE
override val continueJob: Boolean
get() = true
override lateinit var cronjobJob: Job
override lateinit var scheduler: KronScheduler
private var statusList = listOf<String>()
private var index = 0
override suspend fun jobFunction() {
refreshStatusList(System.currentTimeMillis())
Bot.bot.kordRef.editPresence {
this.status = PresenceStatus.DoNotDisturb
this.playing(statusList[index])
}
++index
if (index >= statusList.size) {
index = 0
}
}
fun refreshStatusList(timestamp: Long) {
statusList = listOf(
Splatoon3Api.getRegularMapsFormatted(timestamp),
Splatoon3Api.getSeriesModeFormatted(timestamp),
Splatoon3Api.getSeriesMapsFormatted(timestamp),
Splatoon3Api.getOpenModeFormatted(timestamp),
Splatoon3Api.getOpenMapFormatted(timestamp),
Splatoon3Api.getXModeFormatted(timestamp),
Splatoon3Api.getXMapFormatted(timestamp),
)
}
}

View file

@ -1,45 +0,0 @@
/*
* lilJudd
* Copyright (C) 2023 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.util
import java.net.URL
import javax.net.ssl.HttpsURLConnection
object NetUtil {
fun GETJsonData(urlIN: String, userAgent: String): String {
val startTime = System.currentTimeMillis()
val url = URL(urlIN)
val connection = url.openConnection() as HttpsURLConnection
connection.requestMethod = "GET"
connection.setRequestProperty("User-Agent", userAgent)
connection.setRequestProperty("Accept", "application/json")
val responseCode = connection.responseCode
val timeDiff = System.currentTimeMillis() - startTime
Logger.out("GET took $timeDiff ms (from: $urlIN, as $userAgent)")
return if (responseCode == HttpsURLConnection.HTTP_OK) {
val inputStream = connection.inputStream
val inputStreamReader = inputStream.reader()
val inputAsString = inputStreamReader.readText()
inputStream.close()
inputAsString
} else {
"Error $responseCode"
}
}
}

View file

@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit
object TimeUtil { object TimeUtil {
fun getTimeFormatedShortend(time2: Long, showS: Boolean): String { fun getTimeFormatedShortend(time2: Long): String {
var time = time2 var time = time2
val days: Long = TimeUnit.MILLISECONDS val days: Long = TimeUnit.MILLISECONDS
.toDays(time) .toDays(time)
@ -52,7 +52,7 @@ object TimeUtil {
if (minutes >= 1) { if (minutes >= 1) {
s += minutes.toString() + "m " s += minutes.toString() + "m "
} }
if (seconds >= 1 && hours < 1 && showS) { if (seconds >= 1 && hours < 1) {
s += seconds.toString() + "s" s += seconds.toString() + "s"
} }
if (s.isEmpty() || s.isBlank()) { if (s.isEmpty() || s.isBlank()) {
@ -158,17 +158,4 @@ object TimeUtil {
val zdt_ = zdt.minusHours(1) val zdt_ = zdt.minusHours(1)
return "0 ${zdt_.minute} ${zdt_.hour} ${zdt_.dayOfMonth - 1} ${zdt_.month.value - 1} ${zdt_.year}"// 0o *w" return "0 ${zdt_.minute} ${zdt_.hour} ${zdt_.dayOfMonth - 1} ${zdt_.month.value - 1} ${zdt_.year}"// 0o *w"
} }
fun deformatJSONTime(inp: String, zone: String): Long {
// 2023-10-05T08:00:00Z
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
val localDateTime = LocalDateTime.parse(inp, formatter)
val zoneId = ZoneId.of(zone) // TODO: Add the possibility to set your timezone
return ZonedDateTime.of(localDateTime, zoneId).toEpochSecond() * 1000
}
fun getTimeDifferenceFormatted(start: Long, end: Long): String {
val diff = end - start
return getTimeFormatedShortend(diff, false)
}
} }