Compare commits

..

4 commits

Author SHA1 Message Date
373eb15805 fix: off-by-one error in EmbedUtil 2023-12-06 18:12:41 +01:00
10c5f80ae3
chore: update README.md
Signed-off-by: moonleay <contact@moonleay.net>
2023-12-06 16:03:41 +01:00
3c4a7d9a15
chore: update README.md
Signed-off-by: moonleay <contact@moonleay.net>
2023-12-06 16:02:32 +01:00
230f623918 fix!: temp. stopped the StatusUpdater and Cache updater from running to make the bot run again, fixed package names
Signed-off-by: moonleay <contact@moonleay.net>
2023-10-26 18:53:22 +02:00
12 changed files with 23 additions and 138 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
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://moonleay.net/projects/liljudd/). More information can be found on the [Homepage](https://liljudd.ink).
## Contributors ## Contributors
@ -12,7 +12,7 @@ More information can be found on the [Homepage](https://moonleay.net/projects/li
## Known issues ## Known issues
##### If you encounter any bugs, message me on Discord (@moonleay) or send me a mail (issues@moonleay.net). ##### 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).
## Commands & Features ## Commands & Features
@ -29,11 +29,7 @@ More information can be found on the [Homepage](https://moonleay.net/projects/li
## (Maybe) upcoming features ## (Maybe) upcoming features
- Match Planner (Send Notifications some time before a match starts) ##### See the [todo list](https://todo.moonleay.net/share/OmisuzgPDdsrCAXKjGrTfYzWwqNDNclOMGJWeMsi/auth?view=kanban) for more information.
- 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.4" ?: "2.6.5"
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,23 +30,17 @@ 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 {
@ -110,7 +104,6 @@ object Bot {
add(::SendPlannerExtension) add(::SendPlannerExtension)
add(::MatchExtension) add(::MatchExtension)
add(::UpdateRolesExtension) add(::UpdateRolesExtension)
add(::RotationExtension)
} }
this.presence { this.presence {
@ -165,17 +158,21 @@ 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,7 +17,8 @@
*/ */
package net.moonleay.lilJudd package net.moonleay.lilJudd
import net.moonleay.botendo.build.BuildConstants import net.moonleay.liljudd.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 {
fun getRegularMode(timestamp: Long): ModeData { private 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")
} }
fun getOpenMode(timestamp: Long): ModeData { private 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")
} }
fun getXMode(timestamp: Long): ModeData { private 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")
} }
fun getSeriesMode(timestamp: Long): ModeData { private 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,7 +20,6 @@ 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
@ -34,6 +33,7 @@ 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

@ -1,80 +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.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

@ -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.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 - 1) { for (i in 0 until amountOfTables) {
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}"