Compare commits

..

No commits in common. "734ac1b74cbdc5451765b4558652361b1462a4ba" and "d8753a8c1fed1264388c99b63a5f0b7586410ac6" have entirely different histories.

24 changed files with 54 additions and 103 deletions

View file

@ -1,6 +1,6 @@
/* /*
* lilJudd * lilJudd
* Copyright (C) 2024 moonleay * Copyright (C) 2023 moonleay
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -32,9 +32,9 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
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.splatoon3ink.Splatoon3ApiCache import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.data.database.DB 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
@ -74,11 +74,6 @@ object Bot {
exitProcess(3) exitProcess(3)
} }
if (CredentialManager.apiDomain == "empty" || CredentialManager.apiToken == "empty") {
Logger.out("The config does not contain the whole API credentials.")
exitProcess(3)
}
// Connect to the database // Connect to the database
DB.connect( DB.connect(
CredentialManager.dbDomain, CredentialManager.dbDomain,

View file

@ -1,6 +1,6 @@
/* /*
* lilJudd * lilJudd
* Copyright (C) 2024 moonleay * Copyright (C) 2023 moonleay
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -29,8 +29,6 @@ object CredentialManager {
lateinit var dbName: String lateinit var dbName: String
lateinit var dbUser: String lateinit var dbUser: String
lateinit var dbPassword: String lateinit var dbPassword: String
lateinit var apiDomain: String
lateinit var apiToken: String
///Load the needed credentials, generate a config if there is none ///Load the needed credentials, generate a config if there is none
fun load() { fun load() {
@ -53,8 +51,6 @@ object CredentialManager {
dbName = prop.getProperty("dbName") dbName = prop.getProperty("dbName")
dbUser = prop.getProperty("dbUser") dbUser = prop.getProperty("dbUser")
dbPassword = prop.getProperty("dbPassword") dbPassword = prop.getProperty("dbPassword")
apiDomain = prop.getProperty("apiDomain")
apiToken = prop.getProperty("apiToken")
input.close() input.close()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
@ -87,8 +83,6 @@ object CredentialManager {
prop.setProperty("dbName", "empty") prop.setProperty("dbName", "empty")
prop.setProperty("dbUser", "empty") prop.setProperty("dbUser", "empty")
prop.setProperty("dbPassword", "empty") prop.setProperty("dbPassword", "empty")
prop.setProperty("apiDomain", "empty")
prop.setProperty("apiToken", "empty")
prop.store(output, null) prop.store(output, null)
output.close() output.close()

View file

@ -16,9 +16,9 @@
* 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.api.splatoon3ink package net.moonleay.lilJudd.data.api
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule.ModeData import net.moonleay.lilJudd.data.api.entry.schedule.ModeData
import net.moonleay.lilJudd.util.TimeUtil import net.moonleay.lilJudd.util.TimeUtil
object Splatoon3Api { object Splatoon3Api {

View file

@ -16,21 +16,21 @@
* 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.api.splatoon3ink package net.moonleay.lilJudd.data.api
import io.ktor.http.* import io.ktor.http.*
import kotlinx.serialization.json.* import kotlinx.serialization.json.*
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.coop.CoopGearData import net.moonleay.lilJudd.data.api.entry.coop.CoopGearData
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.schedule.* import net.moonleay.lilJudd.data.api.entry.schedule.*
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest.SplatfestColor import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestColor
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest.SplatfestData import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestData
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest.SplatfestTeamData import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamData
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatfest.SplatfestTeamResults import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamResults
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet.BrandData import net.moonleay.lilJudd.data.api.entry.splatnet.BrandData
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet.GearAbilityData import net.moonleay.lilJudd.data.api.entry.splatnet.GearAbilityData
import net.moonleay.lilJudd.data.api.splatoon3ink.entry.splatnet.SplatnetItemData import net.moonleay.lilJudd.data.api.entry.splatnet.SplatnetItemData
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.Logger
import net.moonleay.lilJudd.util.NetUtil import net.moonleay.lilJudd.util.NetUtil
import net.moonleay.liljudd.build.BuildConstants import net.moonleay.liljudd.build.BuildConstants
@ -49,14 +49,13 @@ object Splatoon3ApiCache {
internal var cachedChallengesData = mutableListOf<ChallengeModeData>() internal var cachedChallengesData = mutableListOf<ChallengeModeData>()
internal var cachedShiftData = mutableListOf<ShiftData>() internal var cachedShiftData = mutableListOf<ShiftData>()
internal var cachedBigRunShiftData = mutableListOf<ShiftData>() internal var cachedBigRunShiftData = mutableListOf<ShiftData>()
internal var cachedCoopRewardsData = internal var cachedCoopRewardsData = mutableListOf<CoopGearData>()
mutableListOf<CoopGearData>()
internal var cachedSplatnetItemData = mutableListOf<SplatnetItemData>() internal var cachedSplatnetItemData = mutableListOf<SplatnetItemData>()
internal var cachedSplatnetLimitedItemData = mutableListOf<SplatnetItemData>() internal var cachedSplatnetLimitedItemData = mutableListOf<SplatnetItemData>()
internal lateinit var splatnetShopBrandData: BrandData internal lateinit var splatnetShopBrandData: BrandData
internal lateinit var splatnetShopNextBrandData: BrandData internal lateinit var splatnetShopNextBrandData: BrandData
fun updateData(dataType: ApiDataType, requestType: ApiRequestType) { fun updateData(dataType: ApiDataType, requestType: ApiRequestType) {
Logger.out("Updating data for $dataType with USER-AGENT: ${user_agent}") Logger.out("Updating data for $dataType with USER-AGENT: $user_agent")
Logger.out("Reason for update: $requestType") Logger.out("Reason for update: $requestType")
when (dataType) { when (dataType) {
ApiDataType.SCHEDULES -> { ApiDataType.SCHEDULES -> {
@ -226,8 +225,7 @@ object Splatoon3ApiCache {
val obj = it as JsonObject val obj = it as JsonObject
val imageURL = Url(obj.jsonObject["originalImage"]!!.jsonObject["url"]!!.jsonPrimitive.content) val imageURL = Url(obj.jsonObject["originalImage"]!!.jsonObject["url"]!!.jsonPrimitive.content)
val id = obj.jsonObject["vsStageId"]!!.jsonPrimitive.int val id = obj.jsonObject["vsStageId"]!!.jsonPrimitive.int
cachedMapData[id] = cachedMapData[id] = MapData(
MapData(
id, id,
imageURL, imageURL,
it.jsonObject["name"]!!.jsonPrimitive.content it.jsonObject["name"]!!.jsonPrimitive.content

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.api.splatoon3ink.entry.coop package net.moonleay.lilJudd.data.api.entry.coop
import io.ktor.http.* import io.ktor.http.*

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.api.splatoon3ink.entry.schedule package net.moonleay.lilJudd.data.api.entry.schedule
data class ChallengeModeData( data class ChallengeModeData(
val leagueMatchEventId: String, val leagueMatchEventId: String,

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.api.splatoon3ink.entry.schedule package net.moonleay.lilJudd.data.api.entry.schedule
import io.ktor.http.* import io.ktor.http.*

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.api.splatoon3ink.entry.schedule package net.moonleay.lilJudd.data.api.entry.schedule
data class ModeData( data class ModeData(
val startTime: String, val startTime: String,

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.api.splatoon3ink.entry.schedule package net.moonleay.lilJudd.data.api.entry.schedule
import io.ktor.http.* import io.ktor.http.*

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.api.splatoon3ink.entry.schedule package net.moonleay.lilJudd.data.api.entry.schedule
data class TimePeriodData( data class TimePeriodData(
val startTime: String, val startTime: String,

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.api.splatoon3ink.entry.schedule package net.moonleay.lilJudd.data.api.entry.schedule
import io.ktor.http.* import io.ktor.http.*

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.api.splatoon3ink.entry.splatfest package net.moonleay.lilJudd.data.api.entry.splatfest
data class SplatfestColor( data class SplatfestColor(
val a: Int, val a: 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.api.splatoon3ink.entry.splatfest package net.moonleay.lilJudd.data.api.entry.splatfest
import io.ktor.http.* import io.ktor.http.*

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.api.splatoon3ink.entry.splatfest package net.moonleay.lilJudd.data.api.entry.splatfest
data class SplatfestTeamData( data class SplatfestTeamData(
val teamName: String, val teamName: String,

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.api.splatoon3ink.entry.splatfest package net.moonleay.lilJudd.data.api.entry.splatfest
data class SplatfestTeamResults( data class SplatfestTeamResults(
val isWinner: Boolean, val isWinner: Boolean,

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.api.splatoon3ink.entry.splatnet package net.moonleay.lilJudd.data.api.entry.splatnet
import io.ktor.http.* import io.ktor.http.*

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.api.splatoon3ink.entry.splatnet package net.moonleay.lilJudd.data.api.entry.splatnet
import io.ktor.http.* import io.ktor.http.*

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.api.splatoon3ink.entry.splatnet package net.moonleay.lilJudd.data.api.entry.splatnet
import io.ktor.http.* import io.ktor.http.*

View file

@ -1,36 +0,0 @@
/*
* lilJudd
* 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
* 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.liljudd
import net.moonleay.lilJudd.data.CredentialManager
object LilJuddApi {
val CONFIG_BASE = "${CredentialManager.apiDomain}/config/"
val MATCH_BASE = "${CredentialManager.apiDomain}/match/"
val TIMEPLANNINGMESSAGES_BASE = "${CredentialManager.apiDomain}/tp_messages/"
// GET https://liljudd.ink/api/config/<guild_id>/
// DELETE https://liljudd.ink/api/config/<guild_id>/
// GET https://liljudd.ink/api/tp_messages/<guild_id>/
// PUT https://liljudd.ink/api/tp_messages/<guild_id>/
// POST https://liljudd.ink/api/match/<guild_id>/<channel_id>/
// PUT https://liljudd.ink/api/match/<guild_id>/<channel_id>/<match_message_id>/
// GET https://liljudd.ink/api/match/<guild_id>/
}

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.api.splatoon3ink.type package net.moonleay.lilJudd.data.api.type
enum class ApiDataType { enum class ApiDataType {
SCHEDULES, SCHEDULES,

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.api.splatoon3ink.type package net.moonleay.lilJudd.data.api.type
enum class ApiRequestType(val nameToDisplay: String) { enum class ApiRequestType(val nameToDisplay: String) {
AUTOMATIC_CACHE_UPDATE("automatic request to update the cache"), AUTOMATIC_CACHE_UPDATE("automatic request to update the cache"),

View file

@ -1,6 +1,6 @@
/* /*
* lilJudd * lilJudd
* Copyright (C) 2024 moonleay * Copyright (C) 2023 moonleay
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,9 +20,9 @@ package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiCache import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType import net.moonleay.lilJudd.data.api.type.ApiRequestType
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.util.Logger import net.moonleay.lilJudd.util.Logger

View file

@ -1,6 +1,6 @@
/* /*
* lilJudd * lilJudd
* Copyright (C) 2024 moonleay * Copyright (C) 2023 moonleay
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,9 +20,9 @@ package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiCache import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType import net.moonleay.lilJudd.data.api.type.ApiRequestType
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.util.Logger import net.moonleay.lilJudd.util.Logger

View file

@ -1,6 +1,6 @@
/* /*
* lilJudd * lilJudd
* Copyright (C) 2024 moonleay * Copyright (C) 2023 moonleay
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,9 +20,9 @@ package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3ApiCache import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiDataType import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.splatoon3ink.type.ApiRequestType import net.moonleay.lilJudd.data.api.type.ApiRequestType
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.util.Logger import net.moonleay.lilJudd.util.Logger