Compare commits

..

1 commit

Author SHA1 Message Date
3a4cb20c95 chore: progress commit
Signed-off-by: moonleay <contact@moonleay.net>
2023-10-19 16:42:07 +02:00
12 changed files with 138 additions and 23 deletions

1
.gitignore vendored
View file

@ -1,5 +1,4 @@
run/ run/
/data/
.gradle .gradle
build/ build/

View file

@ -4,7 +4,7 @@
A Discord Bot for Splatoon Teams. A Discord Bot for Splatoon Teams.
More information can be found on the [Homepage](https://liljudd.ink). More information can be found on the [Homepage](https://moonleay.net/projects/liljudd/).
## Contributors ## Contributors
@ -12,7 +12,7 @@ More information can be found on the [Homepage](https://liljudd.ink).
## Known issues ## Known issues
##### If you encounter any bugs, message me on Discord (@moonleay) or send me a mail (issues@moonleay.net). You can also open a ticket [on the support server](https://discord.gg/HTZRktfH4A). ##### If you encounter any bugs, message me on Discord (@moonleay) or send me a mail (issues@moonleay.net).
## Commands & Features ## Commands & Features
@ -29,7 +29,11 @@ More information can be found on the [Homepage](https://liljudd.ink).
## (Maybe) upcoming features ## (Maybe) upcoming features
##### See the [todo list](https://todo.moonleay.net/share/OmisuzgPDdsrCAXKjGrTfYzWwqNDNclOMGJWeMsi/auth?view=kanban) for more information. - Match Planner (Send Notifications some time before a match starts)
- Game Tracker (Save the results of the last matches)
- Replay Saver (Maybe; will save the replay code to a database)
- Rndm map command
- Maybe a DSB / DSL API
## How to self-host (using the Docker container) ## How to self-host (using the Docker container)

View file

@ -32,7 +32,7 @@ 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.5" ?: "2.6.4"
val kordver = "1.5.9-SNAPSHOT" val kordver = "1.5.9-SNAPSHOT"
val coroutinesver = "1.7.3" val coroutinesver = "1.7.3"

View file

@ -30,17 +30,23 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
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.api.type.ApiDataType
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
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
import net.moonleay.liljudd.build.BuildConstants
import kotlin.system.exitProcess import kotlin.system.exitProcess
object Bot { object Bot {
@ -104,6 +110,7 @@ object Bot {
add(::SendPlannerExtension) add(::SendPlannerExtension)
add(::MatchExtension) add(::MatchExtension)
add(::UpdateRolesExtension) add(::UpdateRolesExtension)
add(::RotationExtension)
} }
this.presence { this.presence {
@ -158,21 +165,17 @@ object Bot {
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 // Make the bot update the status every 6 seconds
// JobManager.addJob(StatusUpdater) JobManager.addJob(StatusUpdater)
} }
// Update the Splatoon 3 api data and make sure it stays up-to-date // Update the Splatoon 3 api data and make sure it stays up-to-date
// Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_CREATION_AT_STARTUP) Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_CREATION_AT_STARTUP)
// JobManager.addJob(Splatoon3ApiScheduleUpdateScheduler) JobManager.addJob(Splatoon3ApiScheduleUpdateScheduler)
/* /*
Other caches will be added when implemented Other caches will be added when implemented
its not used yet in order to reduce load on the api, its not used yet in order to reduce load on the api,
which i am using. which i am using.
*/ */
// Had to disable bc of an error.
// Will fix when I have time
//JobManager.addJob(Splatoon3ApiFestivalAndCoopUpdateScheduler) //JobManager.addJob(Splatoon3ApiFestivalAndCoopUpdateScheduler)
//JobManager.addJob(Splatoon3ApiSplatnetGearUpdateScheduler) //JobManager.addJob(Splatoon3ApiSplatnetGearUpdateScheduler)

View file

@ -17,8 +17,7 @@
*/ */
package net.moonleay.lilJudd package net.moonleay.lilJudd
import net.moonleay.liljudd.build.BuildConstants import net.moonleay.botendo.build.BuildConstants
suspend fun main() { suspend fun main() {
println( println(

View file

@ -22,7 +22,7 @@ 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 {
private fun getRegularMode(timestamp: Long): ModeData { fun getRegularMode(timestamp: Long): ModeData {
Splatoon3ApiCache.cachedRegularModeData.map { modeData -> Splatoon3ApiCache.cachedRegularModeData.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
@ -33,7 +33,7 @@ object Splatoon3Api {
throw Exception("No current mode found") throw Exception("No current mode found")
} }
private fun getOpenMode(timestamp: Long): ModeData { fun getOpenMode(timestamp: Long): ModeData {
Splatoon3ApiCache.cachedCompetitiveOpenModeData.map { modeData -> Splatoon3ApiCache.cachedCompetitiveOpenModeData.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
@ -44,7 +44,7 @@ object Splatoon3Api {
throw Exception("No current mode found") throw Exception("No current mode found")
} }
private fun getXMode(timestamp: Long): ModeData { fun getXMode(timestamp: Long): ModeData {
Splatoon3ApiCache.cachedXModeData.map { modeData -> Splatoon3ApiCache.cachedXModeData.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
@ -55,7 +55,7 @@ object Splatoon3Api {
throw Exception("No current mode found") throw Exception("No current mode found")
} }
private fun getSeriesMode(timestamp: Long): ModeData { fun getSeriesMode(timestamp: Long): ModeData {
Splatoon3ApiCache.cachedCompetitiveSeriesModeData.map { modeData -> Splatoon3ApiCache.cachedCompetitiveSeriesModeData.map { modeData ->
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")

View file

@ -20,6 +20,7 @@ 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.botendo.build.BuildConstants
import net.moonleay.lilJudd.data.api.entry.coop.CoopGearData import net.moonleay.lilJudd.data.api.entry.coop.CoopGearData
import net.moonleay.lilJudd.data.api.entry.schedule.* 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.SplatfestColor
@ -33,7 +34,6 @@ import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.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
object Splatoon3ApiCache { object Splatoon3ApiCache {
private val user_agent = private val user_agent =

View file

@ -20,9 +20,9 @@ package net.moonleay.lilJudd.extensions
import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
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
import net.moonleay.liljudd.build.BuildConstants
class InfoExtension : Extension() { class InfoExtension : Extension() {
override val name = "info" override val name = "info"

View file

@ -0,0 +1,80 @@
/*
* 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.extensions
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.impl.enumChoice
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import net.moonleay.lilJudd.extensions.component.SplatoonOnlineMode
import net.moonleay.lilJudd.util.Logger
class RotationExtension : Extension() {
override val name = "rotation"
override val allowApplicationCommandInDMs: Boolean
get() = false
override suspend fun setup() {
publicSlashCommand(::RotationArguments) {
name = "rotation"
description = "Check the current rotations"
this.action {
val mode = this.arguments.mode
when (mode) {
SplatoonOnlineMode.ALL -> {
}
SplatoonOnlineMode.REGULAR -> {
}
SplatoonOnlineMode.SERIES -> {
}
SplatoonOnlineMode.OPEN -> {
}
SplatoonOnlineMode.X -> {
}
SplatoonOnlineMode.SALMON_RUN -> {
}
}
Logger.out("Done")
}
}
}
inner class RotationArguments : Arguments() {
val mode by enumChoice<SplatoonOnlineMode> {
this.name = "mode"
this.description = "The mode you want to check the rotation for"
this.typeName = "en_US"
}
}
}

View file

@ -0,0 +1,30 @@
/*
* 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.extensions.component
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.ChoiceEnum
enum class SplatoonOnlineMode(override val readableName: String) : ChoiceEnum {
ALL("All Modes"),
REGULAR("Regular Battle"),
SERIES("Ranked Battle (Series)"),
OPEN("Ranked Battle (Open)"),
X("X Battle"),
SALMON_RUN("Salmon Run"),
}

View file

@ -82,7 +82,7 @@ object EmbedUtil {
fun getAllUsersInTheFirstXTables(amountOfTables: Int, e: Embed): List<String> { fun getAllUsersInTheFirstXTables(amountOfTables: Int, e: Embed): List<String> {
val users = mutableListOf<String>() val users = mutableListOf<String>()
for (i in 0 until amountOfTables) { for (i in 0 until amountOfTables - 1) {
val f = e.fields[i] val f = e.fields[i]
if (!f.value.contains("@")) if (!f.value.contains("@"))
continue // check next one. this one does not have any entries continue // check next one. this one does not have any entries

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.build package net.moonleay.lilJudd.build
internal object BuildConstants { internal object BuildConstants {
const val version = "${version}" const val version = "${version}"