Compare commits
144 commits
Author | SHA1 | Date | |
---|---|---|---|
4b46d34f45 | |||
0cd3e4d6a8 | |||
a7e656bcbe | |||
404e043da1 | |||
c65e4031d9 | |||
ab7016cdb3 | |||
d928258028 | |||
8e1551cd6c | |||
4dceef6a1f | |||
906c41be88 | |||
0f399cb58c | |||
95321b4895 | |||
d0ae43e420 | |||
46ee799760 | |||
02b29da5fd | |||
98cdbebf79 | |||
05b4dc39b5 | |||
58f2379f45 | |||
39917e4b5a | |||
97d4143cda | |||
b65dadd42f | |||
38d61ae862 | |||
2182f8751a | |||
894e03c9c6 | |||
abd17b3256 | |||
ec92cac2e7 | |||
0f2410c7c1 | |||
734ac1b74c | |||
e6803f6474 | |||
f3b28ac392 | |||
d8753a8c1f | |||
c1536b259b | |||
7d442bd224 | |||
5581f8f348 | |||
a2dafa5c72 | |||
fc7edc0d0d | |||
b2c43e2c04 | |||
32da9ac7af | |||
d71db45532 | |||
60c30af3e9 | |||
5ad7fe0ae6 | |||
52703b4b61 | |||
984bcabd0c | |||
94149e4272 | |||
0bf527b6e0 | |||
05d2d1a6b9 | |||
5b613d25f2 | |||
bf057dd317 | |||
dac2bdd6d3 | |||
75b8321ba6 | |||
2834989bbb | |||
486417b383 | |||
a2fa3c0d51 | |||
daf3ed0c21 | |||
89e6142ebf | |||
390cd2a345 | |||
e02117fa36 | |||
594050dd61 | |||
ef6820da11 | |||
1b24a9b7d7 | |||
1c17a5d2be | |||
886d891787 | |||
06edbb9288 | |||
028e566c70 | |||
984c9653d9 | |||
11cc32ce72 | |||
59c399d41f | |||
9e1a06bdd5 | |||
1cdcef209b | |||
76571f10e4 | |||
8c33192472 | |||
ea505a1395 | |||
344751b9de | |||
9072109b34 | |||
a730bdffa5 | |||
39c8867722 | |||
47a703156c | |||
3d1b2750e5 | |||
3695f716ed | |||
4e4876a61d | |||
2b42ef5dec | |||
79b0dd8d6a | |||
266376f7cb | |||
0a2368417a | |||
24687d4060 | |||
1cd622a778 | |||
50ab9c0b0d | |||
eee820917d | |||
8a2d2be505 | |||
e0e522f561 | |||
5ce99c904e | |||
7d1952d870 | |||
266b331699 | |||
fa0ba09412 | |||
998de8bae5 | |||
5d2ef4fc44 | |||
6b612dcec6 | |||
8dd123fe44 | |||
5431515976 | |||
9c27e13ec6 | |||
b8915cfefa | |||
e051335d84 | |||
c16ff4bdba | |||
4f3c76910c | |||
6ab6aa1279 | |||
a3d3005ff0 | |||
0c363391ba | |||
4ae3b0052b | |||
bf9754f404 | |||
86771a36fb | |||
c663641e42 | |||
213cb45d6c | |||
6b0bf40e0a | |||
9fa7f38228 | |||
9099d02bf4 | |||
ef28b08214 | |||
187da815e2 | |||
e04956a800 | |||
ad99e2767e | |||
407f0ff1ea | |||
3f3fb87ebd | |||
62e230777b | |||
cd4e881e60 | |||
97fc2975c5 | |||
e03e5bbd9e | |||
1b2b35e10a | |||
7ab73765e4 | |||
ad6040ebf3 | |||
f79e1b1582 | |||
aabc50952b | |||
063ef3ef91 | |||
d92396784e | |||
196bb378b4 | |||
d6bf2e7bc9 | |||
948ac8a184 | |||
4fac341c11 | |||
a42016961f | |||
f87ef82e66 | |||
5b1b9682ff | |||
e64569c748 | |||
e8667dca5b | |||
5ffd3c7ccc | |||
e0228c65cd | |||
15d2aec85e |
118 changed files with 5263 additions and 1238 deletions
|
@ -1,3 +1,4 @@
|
||||||
**.nils
|
**.nils
|
||||||
/run
|
/run
|
||||||
/run/
|
/run/
|
||||||
|
docker-compose.yml
|
||||||
|
|
23
.forgejo/workflows/action.yml
Normal file
23
.forgejo/workflows/action.yml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
name: Build Gradle project
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-gradle-project:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- name: apt update
|
||||||
|
run: apt update
|
||||||
|
- name: install prerequisits
|
||||||
|
run: apt install openjdk-17-jdk ca-certificates-java ssl-cert openssl ca-certificates -y
|
||||||
|
- name: Checkout project sources
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/gradle-build-action@v2
|
||||||
|
- name: Run build with Gradle Wrapper
|
||||||
|
run: ./gradlew shadowJar
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: lilJudd.jar
|
||||||
|
path: build/libs/
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
run/
|
run/
|
||||||
|
/data/
|
||||||
|
|
||||||
.gradle
|
.gradle
|
||||||
build/
|
build/
|
||||||
|
|
|
@ -21,14 +21,15 @@ cache:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- gradle shadowJar
|
- gradle shadowJar
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
stage: publish
|
stage: publish
|
||||||
script:
|
script:
|
||||||
- gradle publish
|
- gradle publish
|
||||||
|
|
||||||
|
|
65
README.md
65
README.md
|
@ -2,11 +2,7 @@
|
||||||
|
|
||||||
"Oh boy, here we go again" ~ me
|
"Oh boy, here we go again" ~ me
|
||||||
|
|
||||||
A Discord Bot for Splatoon Teams
|
A Discord Bot for Splatoon Teams.
|
||||||
|
|
||||||
[](https://gitlab.com/moonleay/liljudd/-/releases)
|
|
||||||
[](https://gitlab.com/moonleay/liljudd/-/commits/master)
|
|
||||||
[](https://gitlab.com/moonleay/liljudd/-/blob/master/LICENSE)
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
|
@ -14,59 +10,60 @@ A Discord Bot for Splatoon Teams
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
|
|
||||||
- There is a bug with being able to register the same feature in the same channel without checking if it is already
|
##### If you encounter any bugs, message me on Discord (@moonleay) or email me (issues@moonleay.net). You can also open a ticket [on the support server](https://discord.gg/HTZRktfH4A).
|
||||||
active
|
|
||||||
|
|
||||||
##### If you encounter any bugs, message me on Discord (@moonleay) or send me a mail (issues@moonleay.net).
|
|
||||||
|
|
||||||
## Commands & Features
|
## Commands & Features
|
||||||
|
|
||||||
- Commands
|
- Commands
|
||||||
- version -- Show the versions of the bot and the most important dependencies
|
- version -- Show the versions of the bot and the most important dependencies
|
||||||
- feature -- Manage bot features
|
- feature -- Manage bot features
|
||||||
|
- match -- Create a new match
|
||||||
|
- updateroles -- Update the roles of all users
|
||||||
|
- sendplanner -- Send the planner message
|
||||||
|
- rotation -- See the current rotation
|
||||||
- Features
|
- Features
|
||||||
- Time Planner -- Make the bot send messages and reactions into a selected channel in order to make planning easier
|
- Time Planner -- Make the bot send messages and reactions into a selected channel in order to make planning easier
|
||||||
|
- Availability Manager -- Make the bot assign users roles every day, so it is possible to notify available people
|
||||||
|
- Match Planner -- Make a match, for which players can sign up and the bot will assign teams and roles to them
|
||||||
|
|
||||||
## (Maybe) upcoming features
|
## The todo list
|
||||||
|
|
||||||
- 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.
|
||||||
- Planning Notifier (Make it possible to ping people, who have time at a specific time)
|
|
||||||
- Game Tracker (Save the results of the last matches)
|
|
||||||
- Replay Saver (Maybe; will save the replay code to a database)
|
|
||||||
- Rndm map command
|
|
||||||
|
|
||||||
## TODO
|
|
||||||
|
|
||||||
- Rewrite the feature system
|
|
||||||
- Rewrite the Cronjob system
|
|
||||||
- Rewrite the Database connection system (from transactions all over the place to a single package with transactions)
|
|
||||||
|
|
||||||
## How to self-host (using the Docker container)
|
## How to self-host (using the Docker container)
|
||||||
|
|
||||||
1. Pull the container
|
1. Copy the docker-compose.yml file from the repository.
|
||||||
2. Map /data/ to a folder on disk
|
2. Install docker and docker-compose.
|
||||||
3. Run the Bot once
|
3. Create a directory called "data" in the same directory as the docker-compose.yml file.
|
||||||
4. Follow step 4 - 7 of "How to self-host (using the JAR)"
|
4. Create a directory called "config" in the same directory as the docker-compose.yml file.
|
||||||
|
5. Start the bot once.
|
||||||
|
6. After 10 seconds, stop the bot.
|
||||||
|
7. Open the config file "credentials.nils" in the config directory.
|
||||||
|
8. Put in your credentials.
|
||||||
|
1. token: your Discord bot token
|
||||||
|
2. dbDomain: the domain and port of your postgresql database (e.g.: "postgresql", when using the docker-compose.yml
|
||||||
|
file)
|
||||||
|
3. dbName: the name of the database
|
||||||
|
4. dbUser: the username of the database
|
||||||
|
5. dbPassword: the password to the db user
|
||||||
|
9. Start the bot again.
|
||||||
|
10. The bot should now be up and running.
|
||||||
|
|
||||||
## How to self-host (using the JAR)
|
## How to self-host (using the JAR)
|
||||||
|
|
||||||
1. Download the latest release from the Package Registry ("Packages and registries" > "Package Registry")
|
1. Download the latest release from the Releases page.
|
||||||
1. It should be called something like this: "lilJudd-X.X.X-xxxxxxxx-prod.jar" (replace "X.X.X" with the latest
|
|
||||||
version and xxxxxxxx" with the commit its based on.)
|
|
||||||
2. If you want to run an early version, which may be (very) unsable, you can run a development version. Just use an
|
|
||||||
entry ending in "-dev.jar"
|
|
||||||
2. Place it anywhere you want.
|
2. Place it anywhere you want.
|
||||||
3. Run the following command:
|
3. Run the following command:
|
||||||
> java -jar lilJudd-X.X.X-xxxxxxxx-prod.jar
|
> java -jar lilJudd.jar
|
||||||
4. The bot should start and create a config file named "credentials.nils" in a folder called "data"
|
4. The bot should start and create a config file named "credentials.nils" in a folder called "data"
|
||||||
5. Open it and put in your credentials.
|
5. Open it and put in your credentials.
|
||||||
1. token: your Discord bot token
|
1. token: your Discord bot token
|
||||||
2. dbDomain: the domain and port of your postgresql database (e.g.: 192.168.178.1:5432)
|
2. dbDomain: the domain and port of your postgresql database (e.g.: 192.168.178.1:5432)
|
||||||
3. dbName: the name of your database
|
3. dbName: the name of the database
|
||||||
4. dbUser: the username of the database
|
4. dbUser: the username of the database
|
||||||
5. dbPassword: the password to your user
|
5. dbPassword: the password to the db user
|
||||||
6. Rerun the command
|
6. Rerun the command
|
||||||
> java -jar lilJudd-X.X.X-xxxxxxxx-prod.jar
|
> java -jar lilJudd.jar
|
||||||
7. The bot should now be up and running.
|
7. The bot should now be up and running.
|
||||||
|
|
||||||
## How to set up workspace
|
## How to set up workspace
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -21,25 +21,27 @@ import org.jetbrains.gradle.ext.TaskTriggersConfig
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.8.20"
|
kotlin("jvm") version "1.9.22"
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
kotlin("plugin.serialization") version "1.9.22"
|
||||||
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.6"
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
|
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
//lilJudd version 2
|
//lilJudd version 2
|
||||||
val ownerID = 372703841151614976L
|
val creatorID = 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.3.0"
|
?: "2.7.2"
|
||||||
|
|
||||||
val kordver = "1.5.6"
|
val kordver = "1.7.1-SNAPSHOT"
|
||||||
val coroutinesver = "1.1.0"
|
val coroutinesver = "1.7.3"
|
||||||
val ktor_version = "2.3.0"
|
val ktorver = "2.3.7"
|
||||||
val exposedver = "0.40.1"
|
val exposedver = "0.46.0"
|
||||||
val postgresver = "42.3.8"
|
val postgresver = "42.7.1"
|
||||||
val krontabver = "2.0.0"
|
val krontabver = "2.2.6"
|
||||||
|
val kotlinxserializationver = "1.6.0"
|
||||||
|
|
||||||
val mavenArtifact = "lilJudd"
|
val mavenArtifact = "lilJudd"
|
||||||
project.base.archivesName.set(mavenArtifact)
|
project.base.archivesName.set(mavenArtifact)
|
||||||
|
@ -72,6 +74,14 @@ repositories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "sonatype 2"
|
||||||
|
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val shadow by configurations.getting
|
val shadow by configurations.getting
|
||||||
|
@ -81,8 +91,13 @@ 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")
|
||||||
|
|
||||||
|
//JSON Stuff
|
||||||
|
shadow("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxserializationver")
|
||||||
|
|
||||||
//Logging
|
//Logging
|
||||||
shadow("org.slf4j:slf4j-api:2.0.3")
|
shadow("org.slf4j:slf4j-api:2.0.3")
|
||||||
shadow("org.slf4j:slf4j-simple:2.0.3")
|
shadow("org.slf4j:slf4j-simple:2.0.3")
|
||||||
|
@ -93,25 +108,26 @@ 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")
|
||||||
|
|
||||||
//Korntab
|
//Krontab
|
||||||
shadow("dev.inmo:krontab:$krontabver")
|
shadow("dev.inmo:krontab:$krontabver")
|
||||||
"shadow"("io.ktor:ktor-client-core-jvm:2.3.1")
|
shadow("io.ktor:ktor-client-core-jvm:$ktorver")
|
||||||
"shadow"("io.ktor:ktor-client-cio-jvm:2.3.1")
|
shadow("io.ktor:ktor-client-cio-jvm:$ktorver")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val targetJavaVersion = 17
|
val targetJavaVersion = 17
|
||||||
val templateSrc = project.rootDir.resolve("src/main/templates")
|
val templateSrc = project.rootDir.resolve("src/main/templates")
|
||||||
val templateDest = project.buildDir.resolve("generated/templates")
|
val templateDest = project.projectDir.resolve("build/generated/templates")
|
||||||
val templateProps = mapOf(
|
val templateProps = mapOf(
|
||||||
"version" to project.version as String,
|
"version" to project.version as String,
|
||||||
"ownerID" to ownerID,
|
"creatorID" to creatorID,
|
||||||
"kordversion" to kordver,
|
"kordversion" to kordver,
|
||||||
"coroutinesversion" to coroutinesver,
|
"coroutinesversion" to coroutinesver,
|
||||||
"ktorversion" to ktor_version,
|
"ktorversion" to ktorver,
|
||||||
"exposedversion" to exposedver,
|
"exposedversion" to exposedver,
|
||||||
"postgresversion" to postgresver,
|
"postgresversion" to postgresver,
|
||||||
"krontabversion" to krontabver
|
"krontabversion" to krontabver,
|
||||||
|
"kotlinxserializationversion" to kotlinxserializationver
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
32
docker-compose.yml
Normal file
32
docker-compose.yml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
lilJudd:
|
||||||
|
container_name: liljudd
|
||||||
|
image: limiteddev/liljudd:x.x.x
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "1"
|
||||||
|
memory: 1G
|
||||||
|
networks:
|
||||||
|
- traefik
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./config/liljudd/:/data/
|
||||||
|
postgresql:
|
||||||
|
container_name: postgresql
|
||||||
|
image: postgres:13.3-alpine
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "1"
|
||||||
|
memory: 1G
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=liljudd
|
||||||
|
- POSTGRES_PASSWORD=changeme
|
||||||
|
- POSTGRES_DB=liljudd
|
||||||
|
networks:
|
||||||
|
- traefik
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./data/postgresql/:/var/lib/postgresql/data/
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
6
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# lilJudd
|
# lilJudd
|
||||||
# Copyright (C) 2023 moonleay
|
# Copyright (C) 2024 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
|
||||||
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
43
gradlew
vendored
43
gradlew
vendored
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#
|
#
|
||||||
# lilJudd
|
# lilJudd
|
||||||
# Copyright (C) 2023 moonleay
|
# Copyright (C) 2024 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
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
@ -82,13 +82,11 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
@ -135,22 +133,29 @@ location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
|
@ -195,11 +200,15 @@ if "$cygwin" || "$msys" ; then
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
@ -207,6 +216,12 @@ set -- \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|
15
gradlew.bat
vendored
15
gradlew.bat
vendored
|
@ -14,7 +14,7 @@
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
|
@ -25,7 +25,8 @@
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
|
@ -1,152 +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
|
|
||||||
|
|
||||||
import com.kotlindiscord.kord.extensions.ExtensibleBot
|
|
||||||
import dev.kord.common.Color
|
|
||||||
import dev.kord.common.entity.PresenceStatus
|
|
||||||
import dev.kord.core.behavior.interaction.response.respond
|
|
||||||
import dev.kord.core.event.interaction.ButtonInteractionCreateEvent
|
|
||||||
import dev.kord.core.on
|
|
||||||
import dev.kord.gateway.Intent
|
|
||||||
import dev.kord.gateway.PrivilegedIntent
|
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import net.moonleay.botendo.build.BuildConstants
|
|
||||||
import net.moonleay.lilJudd.buttons.component.EditButtonManager
|
|
||||||
import net.moonleay.lilJudd.data.CredentialManager
|
|
||||||
import net.moonleay.lilJudd.data.DB
|
|
||||||
import net.moonleay.lilJudd.extensions.FeatureManageExtension
|
|
||||||
import net.moonleay.lilJudd.extensions.SendPlannerExtension
|
|
||||||
import net.moonleay.lilJudd.extensions.VersionExtension
|
|
||||||
import net.moonleay.lilJudd.features.TimeManager
|
|
||||||
import net.moonleay.lilJudd.util.Logger
|
|
||||||
import net.moonleay.lilJudd.util.MessageUtil
|
|
||||||
import kotlin.system.exitProcess
|
|
||||||
|
|
||||||
object Bot {
|
|
||||||
//The kord object gets set at app launch
|
|
||||||
lateinit var bot: ExtensibleBot
|
|
||||||
|
|
||||||
@OptIn(PrivilegedIntent::class)
|
|
||||||
suspend fun start() {
|
|
||||||
Logger.out("Starting Bot...")
|
|
||||||
|
|
||||||
// Load config
|
|
||||||
CredentialManager.load()
|
|
||||||
|
|
||||||
// Don't run the bot when there is no bot token in config
|
|
||||||
if (CredentialManager.token == "empty") {
|
|
||||||
Logger.out("The config does not contain a bot token.")
|
|
||||||
exitProcess(3)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the credentials for the Database are existent, don't run if they are missing
|
|
||||||
if (CredentialManager.dbDomain == "empty" || CredentialManager.dbName == "empty" || CredentialManager.dbUser == "empty" || CredentialManager.dbPassword == "empty") {
|
|
||||||
Logger.out("The config does not contain the whole Database credentials.")
|
|
||||||
exitProcess(3)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect to the database
|
|
||||||
DB.connect(
|
|
||||||
CredentialManager.dbDomain,
|
|
||||||
CredentialManager.dbName,
|
|
||||||
CredentialManager.dbUser,
|
|
||||||
CredentialManager.dbPassword
|
|
||||||
)
|
|
||||||
|
|
||||||
// Register the TimePlanner thread
|
|
||||||
val coroutineJob = GlobalScope.launch {
|
|
||||||
TimeManager.registerThread()
|
|
||||||
//PlanningNotifier.registerThread()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a shutdown hook to cancel the coroutine when the application is terminated
|
|
||||||
Runtime.getRuntime().addShutdownHook(Thread {
|
|
||||||
coroutineJob.cancel()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Add bot token to kord
|
|
||||||
bot = ExtensibleBot(CredentialManager.token) {
|
|
||||||
applicationCommands {
|
|
||||||
enabled = true
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions {
|
|
||||||
add(::VersionExtension)
|
|
||||||
add(::FeatureManageExtension)
|
|
||||||
add(::SendPlannerExtension)
|
|
||||||
//add(::UpdateRolesExtension) // This command is only for debugging purposes
|
|
||||||
//add(::TestExtension) // See comment in TestExtension.kt
|
|
||||||
}
|
|
||||||
|
|
||||||
this.presence {
|
|
||||||
this.status = PresenceStatus.DoNotDisturb
|
|
||||||
this.playing("v." + BuildConstants.version)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.intents {
|
|
||||||
+Intent.GuildMembers
|
|
||||||
}
|
|
||||||
|
|
||||||
// Will add Sharding someday, I promise
|
|
||||||
/*
|
|
||||||
sharding { recommended ->
|
|
||||||
Shards(recommended)
|
|
||||||
} */
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register button presses
|
|
||||||
bot.kordRef.on<ButtonInteractionCreateEvent> {
|
|
||||||
val inter = this.interaction
|
|
||||||
val u = inter.user
|
|
||||||
Logger.out("Button interaction: ${inter.componentId} from ${u.asUser().username}#${u.asUser().discriminator}")
|
|
||||||
if (inter.componentId.startsWith("public.edit.")) {
|
|
||||||
val response = inter.deferPublicMessageUpdate()
|
|
||||||
val g = this.interaction.getOriginalInteractionResponse().getGuild()
|
|
||||||
for (b in EditButtonManager.buttons) {
|
|
||||||
if (b.id != inter.componentId)
|
|
||||||
continue
|
|
||||||
b.onInteraction(inter, response, g, u)
|
|
||||||
return@on
|
|
||||||
}
|
|
||||||
return@on
|
|
||||||
}
|
|
||||||
if (inter.componentId.startsWith("public.message.")) {
|
|
||||||
val response = inter.deferPublicResponse()
|
|
||||||
val g = this.interaction.getOriginalInteractionResponse().getGuild()
|
|
||||||
response.respond {
|
|
||||||
this.embeds = mutableListOf(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0xE0311A),
|
|
||||||
"Error",
|
|
||||||
"Could not find button with id \"${inter.componentId}\".\nPlease report this.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Start the bot
|
|
||||||
bot.start()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,306 +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.commands.converters.impl.channel
|
|
||||||
import com.kotlindiscord.kord.extensions.extensions.Extension
|
|
||||||
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
|
||||||
import com.kotlindiscord.kord.extensions.types.respond
|
|
||||||
import com.kotlindiscord.kord.extensions.utils.hasPermission
|
|
||||||
import dev.kord.common.Color
|
|
||||||
import dev.kord.common.entity.Permission
|
|
||||||
import dev.kord.common.entity.Snowflake
|
|
||||||
import dev.kord.core.behavior.createRole
|
|
||||||
import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles
|
|
||||||
import net.moonleay.lilJudd.data.tables.TimePlanningChannels
|
|
||||||
import net.moonleay.lilJudd.extensions.component.EnableOrDisable
|
|
||||||
import net.moonleay.lilJudd.features.component.FeatureEnum
|
|
||||||
import net.moonleay.lilJudd.util.Logger
|
|
||||||
import net.moonleay.lilJudd.util.MessageUtil
|
|
||||||
import org.jetbrains.exposed.sql.*
|
|
||||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
|
|
||||||
class FeatureManageExtension : Extension() {
|
|
||||||
|
|
||||||
override val name = "feature"
|
|
||||||
override val allowApplicationCommandInDMs: Boolean
|
|
||||||
get() = false
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Note: This has to be rewritten at some point to better support more features
|
|
||||||
* and improve this mess of a class.
|
|
||||||
* */
|
|
||||||
override suspend fun setup() {
|
|
||||||
publicSlashCommand(::FeatureManagerArgs) {
|
|
||||||
name = "feature"
|
|
||||||
description = "Manage features"
|
|
||||||
|
|
||||||
this.action {
|
|
||||||
val u = this.user
|
|
||||||
if (!u.asMember(this.guild!!.id).hasPermission(Permission.Administrator)) {
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0xE0311A),
|
|
||||||
"403: Forbidden",
|
|
||||||
"You cannot edit features, as you don't have the Administrator permission.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return@action
|
|
||||||
}
|
|
||||||
val gID = this.guild!!.id.toString()
|
|
||||||
val cID = this.arguments.channel.id.toString()
|
|
||||||
val channel = this.arguments.channel
|
|
||||||
val args = this.arguments
|
|
||||||
Logger.out("${args.feature.readableName} ${args.setStatus.readableName} ${channel.data.name.value}")
|
|
||||||
if (this.arguments.setStatus == EnableOrDisable.ENABLE) {
|
|
||||||
when (this.arguments.feature) {
|
|
||||||
FeatureEnum.TIMEPLANNINGFEATURE -> {
|
|
||||||
var alreadyExists = false
|
|
||||||
transaction {
|
|
||||||
alreadyExists = TimePlanningChannels.select {
|
|
||||||
(TimePlanningChannels.serverid eq gID) and
|
|
||||||
(TimePlanningChannels.channelid eq cID)
|
|
||||||
}.count() > 0
|
|
||||||
}
|
|
||||||
if (!alreadyExists) {
|
|
||||||
transaction {
|
|
||||||
TimePlanningChannels.insert {
|
|
||||||
it[TimePlanningChannels.serverid] = gID
|
|
||||||
it[TimePlanningChannels.channelid] = cID
|
|
||||||
} get TimePlanningChannels.id
|
|
||||||
}
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0x52E01A),
|
|
||||||
"200: Success",
|
|
||||||
"The feature was enabled in channel ${args.channel.data.name.value}",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return@action
|
|
||||||
}
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0xE0311A),
|
|
||||||
"403: Forbidden",
|
|
||||||
"The feature is already enabled in this channel.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FeatureEnum.PLANNINGROLES -> {
|
|
||||||
var alreadyExists = false
|
|
||||||
// Check if the channel and guild already exist in the db
|
|
||||||
transaction {
|
|
||||||
alreadyExists = PlanningNotifierRoles.select {
|
|
||||||
(PlanningNotifierRoles.serverid eq gID) and (PlanningNotifierRoles.channelid eq cID)
|
|
||||||
}.count() > 0
|
|
||||||
}
|
|
||||||
if (!alreadyExists) {
|
|
||||||
|
|
||||||
// Create the roles in Discord
|
|
||||||
val hasTimeRole = this.guild!!.createRole {
|
|
||||||
this.name = "available [${channel.data.name.value}]"
|
|
||||||
this.mentionable = true
|
|
||||||
}
|
|
||||||
val htr = hasTimeRole.id.toString()
|
|
||||||
|
|
||||||
val wantsNotifsRole = this.guild!!.createRole {
|
|
||||||
this.name = "notifications [${channel.data.name.value}]"
|
|
||||||
this.mentionable = true
|
|
||||||
}
|
|
||||||
val wnr = wantsNotifsRole.id.toString()
|
|
||||||
|
|
||||||
// Save the role ids to db
|
|
||||||
transaction {
|
|
||||||
PlanningNotifierRoles.insert {
|
|
||||||
it[PlanningNotifierRoles.serverid] = gID
|
|
||||||
it[PlanningNotifierRoles.channelid] = cID
|
|
||||||
it[PlanningNotifierRoles.hastimeroleid] = htr
|
|
||||||
it[PlanningNotifierRoles.wantstobenotifiedid] = wnr
|
|
||||||
} get PlanningNotifierRoles.id
|
|
||||||
}
|
|
||||||
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0x52E01A),
|
|
||||||
"200: Success",
|
|
||||||
"The feature was enabled in channel ${args.channel.data.name.value} with roles ${hasTimeRole.mention} & ${wantsNotifsRole.mention}.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return@action
|
|
||||||
}
|
|
||||||
|
|
||||||
// They exist, do not add them
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0xE0311A),
|
|
||||||
"403: Forbidden",
|
|
||||||
"The feature is already enabled in this channel.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return@action
|
|
||||||
}
|
|
||||||
//Disable
|
|
||||||
when (this.arguments.feature) {
|
|
||||||
FeatureEnum.TIMEPLANNINGFEATURE -> {
|
|
||||||
// Check if entry exists in db
|
|
||||||
var alreadyExists = false
|
|
||||||
transaction {
|
|
||||||
alreadyExists = TimePlanningChannels.select {
|
|
||||||
(TimePlanningChannels.serverid eq gID) and
|
|
||||||
(TimePlanningChannels.channelid eq cID)
|
|
||||||
}.count() > 0
|
|
||||||
}
|
|
||||||
if (alreadyExists) {
|
|
||||||
// delete all entrys for this channel
|
|
||||||
transaction {
|
|
||||||
val matchingEntries = TimePlanningChannels.select {
|
|
||||||
(TimePlanningChannels.serverid eq gID) and
|
|
||||||
(TimePlanningChannels.channelid eq cID)
|
|
||||||
}.toList()
|
|
||||||
|
|
||||||
matchingEntries.forEach { entry ->
|
|
||||||
TimePlanningChannels.deleteWhere { id eq entry[id] }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0x52E019),
|
|
||||||
"200: Success",
|
|
||||||
"The feature was disabled.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return@action
|
|
||||||
}
|
|
||||||
// Do nothing; not in db
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0xE0311A),
|
|
||||||
"403: Forbidden",
|
|
||||||
"The feature is already disabled in this channel.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FeatureEnum.PLANNINGROLES -> {
|
|
||||||
// Check if entry exists in db
|
|
||||||
var alreadyExists = false
|
|
||||||
transaction {
|
|
||||||
alreadyExists = PlanningNotifierRoles.select {
|
|
||||||
(PlanningNotifierRoles.serverid eq gID) and (PlanningNotifierRoles.channelid eq cID)
|
|
||||||
}.count() > 0
|
|
||||||
}
|
|
||||||
if (alreadyExists) {
|
|
||||||
var matchingEntries: List<ResultRow> = mutableListOf()
|
|
||||||
transaction {
|
|
||||||
matchingEntries = PlanningNotifierRoles.select {
|
|
||||||
(PlanningNotifierRoles.serverid eq gID) and
|
|
||||||
(PlanningNotifierRoles.channelid eq cID)
|
|
||||||
}.toList()
|
|
||||||
}
|
|
||||||
// delete all entries for this guild and channel combo
|
|
||||||
for (e in matchingEntries) {
|
|
||||||
this.guild!!.getRoleOrNull(Snowflake(e[PlanningNotifierRoles.hastimeroleid]))?.delete()
|
|
||||||
this.guild!!.getRoleOrNull(Snowflake(e[PlanningNotifierRoles.wantstobenotifiedid]))
|
|
||||||
?.delete()
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete all found entries
|
|
||||||
transaction {
|
|
||||||
matchingEntries.forEach { entry ->
|
|
||||||
PlanningNotifierRoles.deleteWhere { id eq entry[id] }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0x52E019),
|
|
||||||
"200: Success",
|
|
||||||
"The feature was disabled.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return@action
|
|
||||||
}
|
|
||||||
// not in db, do nothing
|
|
||||||
this.respond {
|
|
||||||
embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0xE0311A),
|
|
||||||
"403: Forbidden",
|
|
||||||
"The feature is already disabled in this channel.",
|
|
||||||
u.asUser().username + "#" + u.asUser().discriminator
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class FeatureManagerArgs : Arguments() {
|
|
||||||
|
|
||||||
val feature by enumChoice<FeatureEnum> {
|
|
||||||
this.name = "feature"
|
|
||||||
this.description = "The targeted feature"
|
|
||||||
this.typeName = "en_US"
|
|
||||||
}
|
|
||||||
|
|
||||||
val setStatus by enumChoice<EnableOrDisable> {
|
|
||||||
this.name = "set"
|
|
||||||
this.description = "Set enabled or disabled"
|
|
||||||
this.typeName = "en_US"
|
|
||||||
}
|
|
||||||
|
|
||||||
val channel by channel {
|
|
||||||
this.name = "channel"
|
|
||||||
this.description = "Target Channel"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,120 +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.extensions.Extension
|
|
||||||
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
|
||||||
import com.kotlindiscord.kord.extensions.types.respond
|
|
||||||
import com.kotlindiscord.kord.extensions.utils.hasPermission
|
|
||||||
import dev.kord.common.Color
|
|
||||||
import dev.kord.common.entity.Permission
|
|
||||||
import dev.kord.core.behavior.channel.createMessage
|
|
||||||
import dev.kord.rest.builder.message.create.actionRow
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import net.moonleay.lilJudd.data.tables.TimePlanningMessages
|
|
||||||
import net.moonleay.lilJudd.util.EmbedUtil
|
|
||||||
import net.moonleay.lilJudd.util.Logger
|
|
||||||
import net.moonleay.lilJudd.util.MessageUtil
|
|
||||||
import net.moonleay.lilJudd.util.TimeUtil
|
|
||||||
import org.jetbrains.exposed.sql.insert
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import java.time.ZoneId
|
|
||||||
import java.time.ZonedDateTime
|
|
||||||
|
|
||||||
/* This extension has no proper use.
|
|
||||||
It is used in testing to test stuff, without having to wait for certain events to trigger. */
|
|
||||||
class SendPlannerExtension : Extension() {
|
|
||||||
override val name = "sendplanner"
|
|
||||||
override val allowApplicationCommandInDMs: Boolean
|
|
||||||
get() = false
|
|
||||||
|
|
||||||
override suspend fun setup() {
|
|
||||||
publicSlashCommand() {
|
|
||||||
name = "sendplanner"
|
|
||||||
description = "Send the planner for the current and x next weeks"
|
|
||||||
this.action {
|
|
||||||
if (!this.member!!.asMember(this.guild!!.id)
|
|
||||||
.hasPermission(Permission.Administrator)
|
|
||||||
) {
|
|
||||||
val res = this.respond {
|
|
||||||
this.content = "no."
|
|
||||||
}
|
|
||||||
res.delete()
|
|
||||||
return@action
|
|
||||||
}
|
|
||||||
val res = this.respond {
|
|
||||||
this.content = "OK."
|
|
||||||
}
|
|
||||||
res.delete() // Delete the response
|
|
||||||
val c = this.getChannel().asChannel()
|
|
||||||
var msgStr = ""
|
|
||||||
var then =
|
|
||||||
ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withDayOfMonth(TimeUtil.getMondayDayOfMonth())
|
|
||||||
.withHour(4)
|
|
||||||
.withMinute(0).withSecond(0)
|
|
||||||
c.createMessage {
|
|
||||||
this.embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0X4C4645),
|
|
||||||
"Time Planning Feature",
|
|
||||||
"Do you have time on the following Days?",
|
|
||||||
"Automated Message"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
delay(1000)
|
|
||||||
repeat(7) {
|
|
||||||
val msg = c.createMessage {
|
|
||||||
this.embeds.add(
|
|
||||||
MessageUtil.getEmbedWithTable(
|
|
||||||
Color(0X4C4645),
|
|
||||||
"",
|
|
||||||
"${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday",
|
|
||||||
mapOf(
|
|
||||||
"Is available" to listOf(),
|
|
||||||
"May be available" to listOf(),
|
|
||||||
"Is not available" to listOf()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
this.actionRow {
|
|
||||||
this.components.addAll(EmbedUtil.getTimePlannerButtons().components)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msgStr += "${it}:${msg.id.value};"
|
|
||||||
then = then.plusDays(1).withHour(4).withMinute(0).withSecond(0)
|
|
||||||
Logger.out("Finished sending day $it")
|
|
||||||
delay(1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the message ids
|
|
||||||
transaction {
|
|
||||||
TimePlanningMessages.insert {
|
|
||||||
it[serverid] = c.data.guildId.value.toString()
|
|
||||||
it[channelid] = c.id.value.toString()
|
|
||||||
it[weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString()
|
|
||||||
it[messageids] = msgStr
|
|
||||||
} get TimePlanningMessages.id
|
|
||||||
}
|
|
||||||
Logger.out("Finished with ${c.data.guildId.value}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +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.extensions.Extension
|
|
||||||
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
|
||||||
import com.kotlindiscord.kord.extensions.types.respond
|
|
||||||
import dev.kord.common.Color
|
|
||||||
import dev.kord.rest.builder.message.create.actionRow
|
|
||||||
import net.moonleay.lilJudd.util.EmbedUtil
|
|
||||||
import net.moonleay.lilJudd.util.MessageUtil
|
|
||||||
|
|
||||||
/* This extension has no proper use.
|
|
||||||
It is used in testing to test stuff, without having to wait for certain events to trigger. */
|
|
||||||
class TestExtension : Extension() {
|
|
||||||
override val name = "test"
|
|
||||||
override val allowApplicationCommandInDMs: Boolean
|
|
||||||
get() = false
|
|
||||||
|
|
||||||
override suspend fun setup() {
|
|
||||||
publicSlashCommand {
|
|
||||||
name = "test"
|
|
||||||
description = "Test game"
|
|
||||||
this.action {
|
|
||||||
this.respond {
|
|
||||||
this.embeds.add(
|
|
||||||
MessageUtil.getEmbedWithTable(
|
|
||||||
Color(0X4C4645),
|
|
||||||
"",
|
|
||||||
"MONDAY, 22.05.2023",
|
|
||||||
mapOf(
|
|
||||||
"Is available" to listOf(),
|
|
||||||
"May be available" to listOf(),
|
|
||||||
"Is not available" to listOf()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
this.actionRow {
|
|
||||||
this.components.addAll(EmbedUtil.getTimePlannerButtons().components)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,146 +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.features
|
|
||||||
|
|
||||||
import dev.inmo.krontab.buildSchedule
|
|
||||||
import dev.inmo.krontab.doInfinity
|
|
||||||
import dev.kord.common.entity.Snowflake
|
|
||||||
import dev.kord.core.behavior.requestMembers
|
|
||||||
import dev.kord.core.entity.channel.MessageChannel
|
|
||||||
import dev.kord.gateway.PrivilegedIntent
|
|
||||||
import net.moonleay.lilJudd.Bot
|
|
||||||
import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData
|
|
||||||
import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData
|
|
||||||
import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles
|
|
||||||
import net.moonleay.lilJudd.data.tables.TimePlanningMessages
|
|
||||||
import net.moonleay.lilJudd.util.EmbedUtil
|
|
||||||
import net.moonleay.lilJudd.util.Logger
|
|
||||||
import net.moonleay.lilJudd.util.TimeUtil
|
|
||||||
import org.jetbrains.exposed.sql.select
|
|
||||||
import org.jetbrains.exposed.sql.selectAll
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import java.time.ZonedDateTime
|
|
||||||
|
|
||||||
object AvailabilityManager {
|
|
||||||
|
|
||||||
// This runs during the cronjob.
|
|
||||||
@OptIn(PrivilegedIntent::class)
|
|
||||||
suspend fun runThread() {
|
|
||||||
// ChannelID, Data
|
|
||||||
val messageMap = mutableMapOf<Snowflake, TimePlanningMessagesData>()
|
|
||||||
// ChannelID, Data
|
|
||||||
val roleMap = mutableMapOf<String, PlanningNotifierRolesData>()
|
|
||||||
|
|
||||||
transaction {
|
|
||||||
for (pnr in TimePlanningMessages.select {
|
|
||||||
TimePlanningMessages.weekstamp eq (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString()
|
|
||||||
}) {
|
|
||||||
messageMap[Snowflake(pnr[TimePlanningMessages.channelid])] =
|
|
||||||
TimePlanningMessagesData(
|
|
||||||
pnr[TimePlanningMessages.serverid],
|
|
||||||
pnr[TimePlanningMessages.channelid],
|
|
||||||
pnr[TimePlanningMessages.weekstamp],
|
|
||||||
pnr[TimePlanningMessages.messageids]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
for (pnr in PlanningNotifierRoles.selectAll()) {
|
|
||||||
roleMap[pnr[PlanningNotifierRoles.channelid]] =
|
|
||||||
PlanningNotifierRolesData(
|
|
||||||
pnr[PlanningNotifierRoles.serverid],
|
|
||||||
pnr[PlanningNotifierRoles.channelid],
|
|
||||||
pnr[PlanningNotifierRoles.hastimeroleid],
|
|
||||||
pnr[PlanningNotifierRoles.wantstobenotifiedid]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val weekday = ZonedDateTime.now().dayOfWeek // The current week day
|
|
||||||
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.")
|
|
||||||
for (snf in messageMap.keys) { // snf = Snowflake
|
|
||||||
val data = messageMap[snf]!! // this is the data of the table
|
|
||||||
if (Bot.bot.kordRef.getChannel(Snowflake(data.channelid)) == null)
|
|
||||||
continue // This channel does not exist anymore.
|
|
||||||
val c =
|
|
||||||
Bot.bot.kordRef.getChannelOf<MessageChannel>(Snowflake(data.channelid))!! // Get the channel as MessageChannel
|
|
||||||
val roleData = roleMap[data.channelid]!! // Get the role data
|
|
||||||
val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(data.serverid))
|
|
||||||
// Get all members with the role
|
|
||||||
val mce = g.requestMembers {
|
|
||||||
this.requestAllMembers()
|
|
||||||
}
|
|
||||||
mce.collect { it1 ->
|
|
||||||
it1.members.forEach {
|
|
||||||
Logger.out("Checking member ${it.id.value}")
|
|
||||||
if (it.roleIds.contains(Snowflake(roleData.hastimeroleid)))
|
|
||||||
it.removeRole(Snowflake(roleData.hastimeroleid))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.out("Got through all members")
|
|
||||||
// This stores the ids of the messages.
|
|
||||||
// The format is weekdaNR:ID
|
|
||||||
// The last entry (nr 8) is empty, so we can ignore it
|
|
||||||
val messageIdSplit = data.messageids.split(";").subList(0, 7)
|
|
||||||
for (mid in messageIdSplit) {
|
|
||||||
Logger.out("Checking id $mid")
|
|
||||||
if (!mid.startsWith((TimeUtil.getDayOfMonthInt(weekday) - 1).toString(), true))
|
|
||||||
continue // This is not the right message, check the next one
|
|
||||||
val idFiltered = mid.split(":")[1] // This is the target message id
|
|
||||||
val message = c.getMessageOrNull(Snowflake(idFiltered)) // Get the message from the channel
|
|
||||||
if (message == null) {
|
|
||||||
Logger.out("Could not find message.")
|
|
||||||
break // This message does not exist anymore. Nothing we can do about that.
|
|
||||||
}
|
|
||||||
if (message.data.embeds.isEmpty()) {
|
|
||||||
Logger.out("There are no embeds.")
|
|
||||||
break // There are no embeds or there are not enough embeds
|
|
||||||
}
|
|
||||||
val targets = EmbedUtil.getAllUsersInTheFirstXTables(2, message.embeds[0])
|
|
||||||
for (tid in targets) {
|
|
||||||
Logger.out("Checking id $tid")
|
|
||||||
if (Bot.bot.kordRef.getGuildOrNull(Snowflake(data.serverid))!!
|
|
||||||
.getMemberOrNull(Snowflake(tid)) == null
|
|
||||||
)
|
|
||||||
continue // This member does not exist anymore.
|
|
||||||
val member = Bot.bot.kordRef.getGuildOrThrow(Snowflake(data.serverid))
|
|
||||||
.getMember(Snowflake(tid)) // Get the member
|
|
||||||
if (member.roleIds.contains(Snowflake(roleData.hastimeroleid)))
|
|
||||||
continue // This member already has the role
|
|
||||||
member.addRole(Snowflake(roleData.hastimeroleid)) // Add the role
|
|
||||||
Logger.out("Added role to ${member.username}")
|
|
||||||
}
|
|
||||||
Logger.out("Done with message. Moving on...")
|
|
||||||
// We found the right message. We don't need to check the others.
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Logger.out("Done! Until tomorrow! <3 ")
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun registerThread() {
|
|
||||||
Logger.out("Adding availability scheduler...")
|
|
||||||
val scheduler = buildSchedule("0 0 5 * * * 0o *w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
|
||||||
scheduler.doInfinity {
|
|
||||||
|
|
||||||
this.runThread()
|
|
||||||
}
|
|
||||||
Logger.out("Starting to update roles...")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,148 +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.features
|
|
||||||
|
|
||||||
import dev.inmo.krontab.buildSchedule
|
|
||||||
import dev.inmo.krontab.doInfinity
|
|
||||||
import dev.kord.common.Color
|
|
||||||
import dev.kord.common.entity.Snowflake
|
|
||||||
import dev.kord.core.behavior.channel.createMessage
|
|
||||||
import dev.kord.core.entity.channel.MessageChannel
|
|
||||||
import dev.kord.rest.builder.message.create.actionRow
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import net.moonleay.lilJudd.Bot
|
|
||||||
import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData
|
|
||||||
import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles
|
|
||||||
import net.moonleay.lilJudd.data.tables.TimePlanningChannels
|
|
||||||
import net.moonleay.lilJudd.data.tables.TimePlanningMessages
|
|
||||||
import net.moonleay.lilJudd.util.EmbedUtil
|
|
||||||
import net.moonleay.lilJudd.util.Logger
|
|
||||||
import net.moonleay.lilJudd.util.MessageUtil
|
|
||||||
import net.moonleay.lilJudd.util.TimeUtil
|
|
||||||
import org.jetbrains.exposed.sql.insert
|
|
||||||
import org.jetbrains.exposed.sql.selectAll
|
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
|
||||||
import java.time.ZoneId
|
|
||||||
import java.time.ZonedDateTime
|
|
||||||
|
|
||||||
|
|
||||||
object TimeManager {
|
|
||||||
/* /--------------- Seconds
|
|
||||||
| /------------- Minutes
|
|
||||||
| | /----------- Hours
|
|
||||||
| | | /--------- Days of months
|
|
||||||
| | | | /------- Months
|
|
||||||
| | | | | /----- (optional) Year
|
|
||||||
| | | | | | /--- (optional) Timezone offset
|
|
||||||
| | | | | | | / (optional) Week days
|
|
||||||
* * * * * * 0o *w*/
|
|
||||||
|
|
||||||
suspend fun registerThread() {
|
|
||||||
Logger.out("Adding message scheduler...")
|
|
||||||
val scheduler = buildSchedule("0 0 4 * * * 0o 1w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
|
||||||
scheduler.doInfinity {
|
|
||||||
Logger.out("Starting to notify...")
|
|
||||||
|
|
||||||
|
|
||||||
// ChannelID, ServerID
|
|
||||||
val channelList = mutableMapOf<Snowflake, Snowflake>()
|
|
||||||
// ChannelID, Data
|
|
||||||
val roleList = mutableMapOf<Snowflake, PlanningNotifierRolesData>()
|
|
||||||
|
|
||||||
var msgStr = ""
|
|
||||||
|
|
||||||
transaction {
|
|
||||||
for (tp in TimePlanningChannels.selectAll()) {
|
|
||||||
channelList[Snowflake(tp[TimePlanningChannels.channelid])] =
|
|
||||||
Snowflake(tp[TimePlanningChannels.serverid])
|
|
||||||
Logger.out("Have to notify channel with ID ${tp[TimePlanningChannels.channelid]}.")
|
|
||||||
}
|
|
||||||
|
|
||||||
for (pnr in PlanningNotifierRoles.selectAll()) {
|
|
||||||
roleList[Snowflake(pnr[PlanningNotifierRoles.channelid])] = PlanningNotifierRolesData(
|
|
||||||
pnr[PlanningNotifierRoles.serverid],
|
|
||||||
pnr[PlanningNotifierRoles.channelid],
|
|
||||||
pnr[PlanningNotifierRoles.hastimeroleid],
|
|
||||||
pnr[PlanningNotifierRoles.wantstobenotifiedid]
|
|
||||||
)
|
|
||||||
Logger.out("Have to ping roles: ${pnr[PlanningNotifierRoles.wantstobenotifiedid]}}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Logger.out("${channelList.count()} Channels to notify with ${roleList.count()} Roles to ping!")
|
|
||||||
for (ch in channelList.keys) {
|
|
||||||
if (Bot.bot.kordRef.getChannel(ch) == null)
|
|
||||||
continue // TODO: Check if the channel is valid in another shard
|
|
||||||
val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(ch)!!
|
|
||||||
c.createMessage {
|
|
||||||
if (roleList[ch] != null) {
|
|
||||||
this.content =
|
|
||||||
"The weekly planning starts now <@&${Snowflake(roleList[ch]?.wantstobenotifid!!)}>"
|
|
||||||
}
|
|
||||||
this.embeds.add(
|
|
||||||
MessageUtil.getEmbed(
|
|
||||||
Color(0X4C4645),
|
|
||||||
"Time Planning Feature",
|
|
||||||
"Do you have time on the following Days?",
|
|
||||||
"Automated Message"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
delay(2000)
|
|
||||||
var then = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withHour(4).withMinute(0).withSecond(0)
|
|
||||||
repeat(7) {
|
|
||||||
val msg = c.createMessage {
|
|
||||||
this.embeds.add(
|
|
||||||
MessageUtil.getEmbedWithTable(
|
|
||||||
Color(0X4C4645),
|
|
||||||
"",
|
|
||||||
"${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday",
|
|
||||||
mapOf(
|
|
||||||
"Is available" to listOf(),
|
|
||||||
"May be available" to listOf(),
|
|
||||||
"Is not available" to listOf()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
this.actionRow {
|
|
||||||
this.components.addAll(EmbedUtil.getTimePlannerButtons().components)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msgStr += "${it}:${msg.id.value};"
|
|
||||||
then = then.plusDays(1).withHour(4).withMinute(0).withSecond(0)
|
|
||||||
Logger.out("Finished sending day $it")
|
|
||||||
|
|
||||||
delay(1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the message ids
|
|
||||||
transaction {
|
|
||||||
TimePlanningMessages.insert {
|
|
||||||
it[TimePlanningMessages.serverid] = c.data.guildId.value.toString()
|
|
||||||
it[TimePlanningMessages.channelid] = c.id.value.toString()
|
|
||||||
it[TimePlanningMessages.weekstamp] = TimeUtil.getWeekStamp().toOffsetDateTime().toString()
|
|
||||||
it[TimePlanningMessages.messageids] = msgStr
|
|
||||||
} get PlanningNotifierRoles.id
|
|
||||||
}
|
|
||||||
Logger.out("Finished with ${c.data.guildId.value}")
|
|
||||||
}
|
|
||||||
Logger.out("Done! Until next Monday! <3 ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
232
src/main/kotlin/net/moonleay/liljudd/Bot.kt
Normal file
232
src/main/kotlin/net/moonleay/liljudd/Bot.kt
Normal file
|
@ -0,0 +1,232 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.ExtensibleBot
|
||||||
|
import com.kotlindiscord.kord.extensions.utils.dm
|
||||||
|
import dev.kord.common.entity.PresenceStatus
|
||||||
|
import dev.kord.core.behavior.interaction.response.respond
|
||||||
|
import dev.kord.core.event.gateway.ReadyEvent
|
||||||
|
import dev.kord.core.event.interaction.ButtonInteractionCreateEvent
|
||||||
|
import dev.kord.core.on
|
||||||
|
import dev.kord.gateway.Intent
|
||||||
|
import dev.kord.gateway.PrivilegedIntent
|
||||||
|
import dev.kord.gateway.builder.Shards
|
||||||
|
import dev.kord.rest.builder.message.embed
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import net.moonleay.liljudd.build.BuildConstants
|
||||||
|
import net.moonleay.liljudd.buttons.component.EditButtonManager
|
||||||
|
import net.moonleay.liljudd.data.CredentialManager
|
||||||
|
import net.moonleay.liljudd.data.NewsManager
|
||||||
|
import net.moonleay.liljudd.data.StacktraceSaver
|
||||||
|
import net.moonleay.liljudd.data.database.DB
|
||||||
|
import net.moonleay.liljudd.extensions.*
|
||||||
|
import net.moonleay.liljudd.features.AvailabilityManager
|
||||||
|
import net.moonleay.liljudd.features.MatchManager
|
||||||
|
import net.moonleay.liljudd.features.TimeManager
|
||||||
|
import net.moonleay.liljudd.util.EmbedColor
|
||||||
|
import net.moonleay.liljudd.util.Logger
|
||||||
|
import net.moonleay.liljudd.util.MessageUtil
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
|
||||||
|
object Bot {
|
||||||
|
//The kord object gets set at app launch
|
||||||
|
lateinit var bot: ExtensibleBot
|
||||||
|
|
||||||
|
private val jobs = mutableListOf<Job>()
|
||||||
|
|
||||||
|
@OptIn(PrivilegedIntent::class)
|
||||||
|
suspend fun start() {
|
||||||
|
Logger.out("Starting Bot...")
|
||||||
|
|
||||||
|
// Load config
|
||||||
|
CredentialManager.load()
|
||||||
|
|
||||||
|
// Don't run the bot when there is no bot token in config
|
||||||
|
if (CredentialManager.token == "empty") {
|
||||||
|
Logger.out("The config does not contain a bot token.")
|
||||||
|
exitProcess(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the credentials for the Database are existent, don't run if they are missing
|
||||||
|
if (CredentialManager.dbDomain == "empty" || CredentialManager.dbName == "empty" || CredentialManager.dbUser == "empty" || CredentialManager.dbPassword == "empty") {
|
||||||
|
Logger.out("The config does not contain the whole Database credentials.")
|
||||||
|
exitProcess(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there are api credentials
|
||||||
|
if (CredentialManager.apiDomain == "empty" || CredentialManager.apiToken == "empty") {
|
||||||
|
Logger.out("The config does not contain the whole API credentials.")
|
||||||
|
exitProcess(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect to the database
|
||||||
|
DB.connect(
|
||||||
|
CredentialManager.dbDomain,
|
||||||
|
CredentialManager.dbName,
|
||||||
|
CredentialManager.dbUser,
|
||||||
|
CredentialManager.dbPassword
|
||||||
|
)
|
||||||
|
|
||||||
|
// Make sure the database is up-to-date
|
||||||
|
DB.register()
|
||||||
|
|
||||||
|
// Register all the jobs
|
||||||
|
jobs.addAll(
|
||||||
|
listOf(
|
||||||
|
TimeManager,
|
||||||
|
AvailabilityManager,
|
||||||
|
).map {
|
||||||
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
|
it.registerThread()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
// Thanks silenium-dev <3
|
||||||
|
|
||||||
|
// Create the bot object
|
||||||
|
bot = ExtensibleBot(CredentialManager.token) {
|
||||||
|
applicationCommands {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
extensions {
|
||||||
|
add(::InfoExtension)
|
||||||
|
add(::FeatureManageExtension)
|
||||||
|
add(::SendPlannerExtension)
|
||||||
|
add(::MatchExtension)
|
||||||
|
add(::UpdateRolesExtension)
|
||||||
|
add(::RotationExtension)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.presence {
|
||||||
|
this.status = PresenceStatus.DoNotDisturb
|
||||||
|
this.playing("v." + BuildConstants.version)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.intents {
|
||||||
|
+Intent.GuildMembers
|
||||||
|
}
|
||||||
|
|
||||||
|
errorResponse { _, type ->
|
||||||
|
val stamp = System.currentTimeMillis()
|
||||||
|
this.embed {
|
||||||
|
this.title = "Oops. Something went wrong."
|
||||||
|
this.description = "The bot encountered an error during execution.\n" +
|
||||||
|
"Please report this to <@${BuildConstants.creatorID}>.\n" +
|
||||||
|
"The errorid is \"$stamp.stk\""
|
||||||
|
this.field {
|
||||||
|
this.name = "Error message:"
|
||||||
|
this.value = type.error.message.toString()
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StacktraceSaver.saveStacktrace(type.error, stamp)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sharding { recommended ->
|
||||||
|
Shards(recommended)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register button presses
|
||||||
|
bot.kordRef.on<ButtonInteractionCreateEvent> {
|
||||||
|
val inter = this.interaction
|
||||||
|
val u = inter.user
|
||||||
|
Logger.out("Button interaction: ${inter.componentId} from ${u.asUser().username}#${u.asUser().discriminator}")
|
||||||
|
if (inter.componentId.startsWith("public.edit.")) {
|
||||||
|
val response = inter.deferPublicMessageUpdate()
|
||||||
|
val g = this.interaction.getOriginalInteractionResponse().getGuild()
|
||||||
|
for (b in EditButtonManager.buttons) {
|
||||||
|
if (b.id != inter.componentId)
|
||||||
|
continue
|
||||||
|
b.onInteraction(inter, response, g, u)
|
||||||
|
return@on
|
||||||
|
}
|
||||||
|
return@on
|
||||||
|
}
|
||||||
|
if (inter.componentId.startsWith("public.message.")) {
|
||||||
|
val response = inter.deferPublicResponse()
|
||||||
|
response.respond {
|
||||||
|
this.embeds = mutableListOf(
|
||||||
|
MessageUtil.getEmbed(
|
||||||
|
EmbedColor.ERROR,
|
||||||
|
"404: Not Found",
|
||||||
|
"Could not find button with id \"${inter.componentId}\"." +
|
||||||
|
"\nPlease report this.",
|
||||||
|
u.asUser().username + "#" + u.asUser().discriminator
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bot.kordRef.on<ReadyEvent> {
|
||||||
|
AvailabilityManager.runThread() // Update Availabilities
|
||||||
|
MatchManager.update() // Update Matches
|
||||||
|
// Load news
|
||||||
|
NewsManager.load()
|
||||||
|
if(NewsManager.shouldPost == "yes"){
|
||||||
|
val contactedOwners = mutableListOf<ULong>()
|
||||||
|
bot.kordRef.guilds.collect {
|
||||||
|
val owner = it.owner.asUser()
|
||||||
|
if (!contactedOwners.contains(owner.id.value)) {
|
||||||
|
Logger.out("Sent News to ${owner.username} from ${it.name}")
|
||||||
|
owner.dm {
|
||||||
|
this.embed {
|
||||||
|
this.title = NewsManager.title
|
||||||
|
this.description = NewsManager.news
|
||||||
|
this.footer {
|
||||||
|
this.icon = bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contactedOwners.add(owner.id.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NewsManager.shouldPost = "no"
|
||||||
|
NewsManager.update()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// Splatoon3Api.updateSchedule()
|
||||||
|
// 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.
|
||||||
|
*/
|
||||||
|
// Had to disable bc of an error.
|
||||||
|
// Will fix when I have time
|
||||||
|
|
||||||
|
//Start the bot
|
||||||
|
bot.start()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -15,9 +15,11 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* 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
|
package net.moonleay.liljudd
|
||||||
|
|
||||||
|
import net.moonleay.liljudd.build.BuildConstants
|
||||||
|
import net.moonleay.liljudd.util.Logger
|
||||||
|
|
||||||
import net.moonleay.botendo.build.BuildConstants
|
|
||||||
|
|
||||||
suspend fun main() {
|
suspend fun main() {
|
||||||
println(
|
println(
|
||||||
|
@ -26,9 +28,11 @@ suspend fun main() {
|
||||||
"| |_| |__| |_ _ _| |_| |\n" +
|
"| |_| |__| |_ _ _| |_| |\n" +
|
||||||
"| | | | | | | | . | . |\n" +
|
"| | | | | | | | . | . |\n" +
|
||||||
"|_|_|_|_____|___|___|___|\n" +
|
"|_|_|_|_____|___|___|___|\n" +
|
||||||
" "
|
"v.${BuildConstants.version}\n"
|
||||||
)
|
)
|
||||||
println("v.${BuildConstants.version}")
|
|
||||||
|
Logger.out("li'l Judd made by moonleay (https://moonleay.net). Web UI made by aronmal (https://mal-noh.de).")
|
||||||
|
Logger.out("For more information check out https://liljudd.ink and https://git.moonleay.net/DiscordBots/lilJudd")
|
||||||
|
|
||||||
Bot.start()
|
Bot.start()
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,16 +16,22 @@
|
||||||
* 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.buttons.component
|
package net.moonleay.liljudd.buttons.component
|
||||||
|
|
||||||
import net.moonleay.lilJudd.buttons.timeplanner.IsAvailableEditButton
|
import net.moonleay.liljudd.buttons.matchplanner.AcceptEditButton
|
||||||
import net.moonleay.lilJudd.buttons.timeplanner.MaybeAvailableEditButton
|
import net.moonleay.liljudd.buttons.matchplanner.CancelEditButton
|
||||||
import net.moonleay.lilJudd.buttons.timeplanner.NotAvailableEditButton
|
import net.moonleay.liljudd.buttons.matchplanner.DeclineEditButton
|
||||||
|
import net.moonleay.liljudd.buttons.timeplanner.IsAvailableEditButton
|
||||||
|
import net.moonleay.liljudd.buttons.timeplanner.MaybeAvailableEditButton
|
||||||
|
import net.moonleay.liljudd.buttons.timeplanner.NotAvailableEditButton
|
||||||
|
|
||||||
object EditButtonManager {
|
object EditButtonManager {
|
||||||
val buttons = listOf(
|
val buttons = listOf(
|
||||||
IsAvailableEditButton(),
|
IsAvailableEditButton(),
|
||||||
MaybeAvailableEditButton(),
|
MaybeAvailableEditButton(),
|
||||||
NotAvailableEditButton()
|
NotAvailableEditButton(),
|
||||||
|
AcceptEditButton(),
|
||||||
|
CancelEditButton(),
|
||||||
|
DeclineEditButton(),
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,16 +16,17 @@
|
||||||
* 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.buttons.component
|
package net.moonleay.liljudd.buttons.component
|
||||||
|
|
||||||
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
||||||
import dev.kord.core.entity.Guild
|
import dev.kord.core.entity.Guild
|
||||||
import dev.kord.core.entity.User
|
import dev.kord.core.entity.User
|
||||||
import dev.kord.core.entity.interaction.ButtonInteraction
|
import dev.kord.core.entity.interaction.ButtonInteraction
|
||||||
|
|
||||||
open class EditButton(val id: String) {
|
interface IEditButton {
|
||||||
|
|
||||||
open suspend fun onInteraction(
|
val id: String
|
||||||
|
suspend fun onInteraction(
|
||||||
interaction: ButtonInteraction,
|
interaction: ButtonInteraction,
|
||||||
response: PublicMessageInteractionResponseBehavior,
|
response: PublicMessageInteractionResponseBehavior,
|
||||||
guild: Guild,
|
guild: Guild,
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
* 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.buttons.matchplanner
|
||||||
|
|
||||||
|
import dev.kord.common.entity.Snowflake
|
||||||
|
import dev.kord.core.behavior.edit
|
||||||
|
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
||||||
|
import dev.kord.core.entity.Guild
|
||||||
|
import dev.kord.core.entity.User
|
||||||
|
import dev.kord.core.entity.channel.MessageChannel
|
||||||
|
import dev.kord.core.entity.interaction.ButtonInteraction
|
||||||
|
import dev.kord.rest.builder.message.EmbedBuilder
|
||||||
|
import dev.kord.rest.builder.message.embed
|
||||||
|
import net.moonleay.liljudd.Bot
|
||||||
|
import net.moonleay.liljudd.buttons.component.IEditButton
|
||||||
|
import net.moonleay.liljudd.data.database.repository.MatchPlanningDataRepository
|
||||||
|
import net.moonleay.liljudd.util.EmbedUtil
|
||||||
|
import net.moonleay.liljudd.util.Logger
|
||||||
|
import net.moonleay.liljudd.util.MessageUtil
|
||||||
|
|
||||||
|
class AcceptEditButton : IEditButton {
|
||||||
|
override val id: String = "public.edit.btn.matchmanagement.accept"
|
||||||
|
|
||||||
|
override suspend fun onInteraction(
|
||||||
|
interaction: ButtonInteraction,
|
||||||
|
response: PublicMessageInteractionResponseBehavior,
|
||||||
|
guild: Guild,
|
||||||
|
user: User
|
||||||
|
) {
|
||||||
|
val m = interaction.message
|
||||||
|
val eb = MessageUtil.getAClonedEmbed(m.embeds[0])
|
||||||
|
var shouldEditButton = false
|
||||||
|
val mpdd = MatchPlanningDataRepository.getFromMessageInChannelInServer(
|
||||||
|
m.id.value.toLong(),
|
||||||
|
interaction.channelId.value.toLong(),
|
||||||
|
guild.id.value.toLong()
|
||||||
|
)
|
||||||
|
if (mpdd == null) {
|
||||||
|
Logger.out("mpdd is null")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val role = guild.getRoleOrNull(Snowflake(mpdd.roleID))
|
||||||
|
if (role == null) {
|
||||||
|
Logger.out("role is null")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val member = interaction.user.asMember(guild.id)
|
||||||
|
// do the checks and update
|
||||||
|
if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) {
|
||||||
|
if (member.roleIds.contains(Snowflake(mpdd.roleID))) {
|
||||||
|
Logger.out("Removing role from ${member.username}")
|
||||||
|
member.removeRole(role.id)
|
||||||
|
}
|
||||||
|
// remove the user from the 1st list in the embed
|
||||||
|
Logger.out("Removing ${user.username} from the 1st list in the embed")
|
||||||
|
eb.fields = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", eb, 1).fields
|
||||||
|
shouldEditButton = true
|
||||||
|
}
|
||||||
|
if (m.embeds[0].fields[1].value.contains(user.id.value.toString())) {
|
||||||
|
Logger.out("Removing ${user.username} from the 2nd list in the embed")
|
||||||
|
eb.fields = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", eb, 2).fields
|
||||||
|
shouldEditButton = true
|
||||||
|
}
|
||||||
|
if (!m.embeds[0].fields[0].value.contains(user.id.value.toString())) {
|
||||||
|
if (!member.roleIds.contains(Snowflake(mpdd.roleID))) {
|
||||||
|
Logger.out("Adding role to ${member.username}")
|
||||||
|
member.addRole(role.id)
|
||||||
|
}
|
||||||
|
//Add the user to the list in the embed
|
||||||
|
Logger.out("Adding ${user.username} to the 1st list in the embed")
|
||||||
|
eb.fields = EmbedUtil.addXToValuesAtTable(user.id.value.toString(), eb, 1).fields
|
||||||
|
shouldEditButton = true
|
||||||
|
}
|
||||||
|
if (shouldEditButton) {
|
||||||
|
// update the message
|
||||||
|
Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit {
|
||||||
|
this.embed(fun EmbedBuilder.() {
|
||||||
|
color = eb.color
|
||||||
|
title = eb.title
|
||||||
|
description = eb.description
|
||||||
|
fields = eb.fields
|
||||||
|
footer = eb.footer
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* 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.buttons.matchplanner
|
||||||
|
|
||||||
|
import dev.kord.common.entity.Snowflake
|
||||||
|
import dev.kord.core.behavior.edit
|
||||||
|
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
||||||
|
import dev.kord.core.entity.Guild
|
||||||
|
import dev.kord.core.entity.User
|
||||||
|
import dev.kord.core.entity.channel.MessageChannel
|
||||||
|
import dev.kord.core.entity.interaction.ButtonInteraction
|
||||||
|
import dev.kord.rest.builder.message.EmbedBuilder
|
||||||
|
import dev.kord.rest.builder.message.embed
|
||||||
|
import net.moonleay.liljudd.Bot
|
||||||
|
import net.moonleay.liljudd.buttons.component.IEditButton
|
||||||
|
import net.moonleay.liljudd.data.database.repository.MatchPlanningDataRepository
|
||||||
|
import net.moonleay.liljudd.util.EmbedUtil
|
||||||
|
import net.moonleay.liljudd.util.Logger
|
||||||
|
|
||||||
|
class CancelEditButton : IEditButton {
|
||||||
|
override val id: String = "public.edit.btn.matchmanagement.cancel"
|
||||||
|
|
||||||
|
override suspend fun onInteraction(
|
||||||
|
interaction: ButtonInteraction,
|
||||||
|
response: PublicMessageInteractionResponseBehavior,
|
||||||
|
guild: Guild,
|
||||||
|
user: User
|
||||||
|
) {
|
||||||
|
val m = interaction.message
|
||||||
|
if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) {
|
||||||
|
val mpdd = MatchPlanningDataRepository.getFromMessageInChannelInServer(
|
||||||
|
m.id.value.toLong(),
|
||||||
|
interaction.channelId.value.toLong(),
|
||||||
|
guild.id.value.toLong()
|
||||||
|
)
|
||||||
|
if (mpdd == null) {
|
||||||
|
Logger.out("mpdd is null")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val role = guild.getRoleOrNull(Snowflake(mpdd.roleID))
|
||||||
|
if (role == null) {
|
||||||
|
Logger.out("role is null")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val member = interaction.user.asMember(guild.id)
|
||||||
|
if (member.roleIds.contains(Snowflake(mpdd.roleID))) {
|
||||||
|
member.removeRole(role.id)
|
||||||
|
}
|
||||||
|
Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit {
|
||||||
|
this.embed(fun EmbedBuilder.() {
|
||||||
|
val temp = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", m.embeds[0], 1)
|
||||||
|
color = temp.color
|
||||||
|
title = temp.title
|
||||||
|
description = temp.description
|
||||||
|
fields = temp.fields
|
||||||
|
footer = temp.footer
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
* 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.buttons.matchplanner
|
||||||
|
|
||||||
|
import dev.kord.common.entity.Snowflake
|
||||||
|
import dev.kord.core.behavior.edit
|
||||||
|
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
||||||
|
import dev.kord.core.entity.Guild
|
||||||
|
import dev.kord.core.entity.User
|
||||||
|
import dev.kord.core.entity.channel.MessageChannel
|
||||||
|
import dev.kord.core.entity.interaction.ButtonInteraction
|
||||||
|
import dev.kord.rest.builder.message.EmbedBuilder
|
||||||
|
import dev.kord.rest.builder.message.embed
|
||||||
|
import net.moonleay.liljudd.Bot
|
||||||
|
import net.moonleay.liljudd.buttons.component.IEditButton
|
||||||
|
import net.moonleay.liljudd.data.database.repository.MatchPlanningDataRepository
|
||||||
|
import net.moonleay.liljudd.util.EmbedUtil
|
||||||
|
import net.moonleay.liljudd.util.Logger
|
||||||
|
import net.moonleay.liljudd.util.MessageUtil
|
||||||
|
|
||||||
|
class DeclineEditButton : IEditButton {
|
||||||
|
override val id: String = "public.edit.btn.matchmanagement.decline"
|
||||||
|
|
||||||
|
override suspend fun onInteraction(
|
||||||
|
interaction: ButtonInteraction,
|
||||||
|
response: PublicMessageInteractionResponseBehavior,
|
||||||
|
guild: Guild,
|
||||||
|
user: User
|
||||||
|
) {
|
||||||
|
val m = interaction.message
|
||||||
|
val eb = MessageUtil.getAClonedEmbed(m.embeds[0])
|
||||||
|
var shouldEditButton = false
|
||||||
|
val mpdd = MatchPlanningDataRepository.getFromMessageInChannelInServer(
|
||||||
|
m.id.value.toLong(),
|
||||||
|
interaction.channelId.value.toLong(),
|
||||||
|
guild.id.value.toLong()
|
||||||
|
)
|
||||||
|
if (mpdd == null) {
|
||||||
|
Logger.out("mpdd is null")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val role = guild.getRoleOrNull(Snowflake(mpdd.roleID))
|
||||||
|
if (role == null) {
|
||||||
|
Logger.out("role is null")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val member = interaction.user.asMember(guild.id)
|
||||||
|
if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) {
|
||||||
|
if (member.roleIds.contains(Snowflake(mpdd.roleID))) {
|
||||||
|
Logger.out("Removing role from ${member.username}")
|
||||||
|
member.removeRole(role.id)
|
||||||
|
}
|
||||||
|
// remove the user from the 1st list in the embed
|
||||||
|
Logger.out("Removing ${user.username} from the 1st list in the embed")
|
||||||
|
eb.fields = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", eb, 1).fields
|
||||||
|
shouldEditButton = true
|
||||||
|
}
|
||||||
|
if (!m.embeds[0].fields[1].value.contains(user.id.value.toString())) {
|
||||||
|
if (member.roleIds.contains(Snowflake(mpdd.roleID))) {
|
||||||
|
Logger.out("Removing role from ${member.username}")
|
||||||
|
member.removeRole(role.id)
|
||||||
|
}
|
||||||
|
// Add the user to the list in the embed
|
||||||
|
Logger.out("Adding ${user.username} to the 2nd list in the embed")
|
||||||
|
eb.fields = EmbedUtil.addXToValuesAtTable(user.id.value.toString(), eb, 2).fields
|
||||||
|
shouldEditButton = true
|
||||||
|
}
|
||||||
|
if (m.embeds[0].fields[1].value.contains(user.id.value.toString())) {
|
||||||
|
// Remove the user from all tables
|
||||||
|
Logger.out("Removing ${user.username} from the 2nd list in the embed")
|
||||||
|
eb.fields = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", eb, 2).fields
|
||||||
|
shouldEditButton = true
|
||||||
|
}
|
||||||
|
if (shouldEditButton) {
|
||||||
|
// update the message
|
||||||
|
Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit {
|
||||||
|
this.embed(fun EmbedBuilder.() {
|
||||||
|
color = eb.color
|
||||||
|
title = eb.title
|
||||||
|
description = eb.description
|
||||||
|
fields = eb.fields
|
||||||
|
footer = eb.footer
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -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.buttons.timeplanner
|
package net.moonleay.liljudd.buttons.timeplanner
|
||||||
|
|
||||||
import dev.kord.core.behavior.edit
|
import dev.kord.core.behavior.edit
|
||||||
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
||||||
|
@ -24,12 +24,15 @@ import dev.kord.core.entity.Guild
|
||||||
import dev.kord.core.entity.User
|
import dev.kord.core.entity.User
|
||||||
import dev.kord.core.entity.channel.MessageChannel
|
import dev.kord.core.entity.channel.MessageChannel
|
||||||
import dev.kord.core.entity.interaction.ButtonInteraction
|
import dev.kord.core.entity.interaction.ButtonInteraction
|
||||||
import dev.kord.rest.builder.message.modify.embed
|
import dev.kord.rest.builder.message.embed
|
||||||
import net.moonleay.lilJudd.Bot
|
import net.moonleay.liljudd.Bot
|
||||||
import net.moonleay.lilJudd.buttons.component.EditButton
|
import net.moonleay.liljudd.buttons.component.IEditButton
|
||||||
import net.moonleay.lilJudd.util.EmbedUtil
|
import net.moonleay.liljudd.features.AvailabilityManager
|
||||||
|
import net.moonleay.liljudd.util.EmbedUtil
|
||||||
|
|
||||||
|
class IsAvailableEditButton : IEditButton {
|
||||||
|
override val id: String = "public.edit.btn.timemanagement.available"
|
||||||
|
|
||||||
class IsAvailableEditButton : EditButton("public.edit.btn.timemanagement.available") {
|
|
||||||
override suspend fun onInteraction(
|
override suspend fun onInteraction(
|
||||||
interaction: ButtonInteraction,
|
interaction: ButtonInteraction,
|
||||||
response: PublicMessageInteractionResponseBehavior,
|
response: PublicMessageInteractionResponseBehavior,
|
||||||
|
@ -60,5 +63,6 @@ class IsAvailableEditButton : EditButton("public.edit.btn.timemanagement.availab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AvailabilityManager.updateInChannel(interaction.channelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -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.buttons.timeplanner
|
package net.moonleay.liljudd.buttons.timeplanner
|
||||||
|
|
||||||
import dev.kord.core.behavior.edit
|
import dev.kord.core.behavior.edit
|
||||||
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
||||||
|
@ -24,12 +24,15 @@ import dev.kord.core.entity.Guild
|
||||||
import dev.kord.core.entity.User
|
import dev.kord.core.entity.User
|
||||||
import dev.kord.core.entity.channel.MessageChannel
|
import dev.kord.core.entity.channel.MessageChannel
|
||||||
import dev.kord.core.entity.interaction.ButtonInteraction
|
import dev.kord.core.entity.interaction.ButtonInteraction
|
||||||
import dev.kord.rest.builder.message.modify.embed
|
import dev.kord.rest.builder.message.embed
|
||||||
import net.moonleay.lilJudd.Bot
|
import net.moonleay.liljudd.Bot
|
||||||
import net.moonleay.lilJudd.buttons.component.EditButton
|
import net.moonleay.liljudd.buttons.component.IEditButton
|
||||||
import net.moonleay.lilJudd.util.EmbedUtil
|
import net.moonleay.liljudd.features.AvailabilityManager
|
||||||
|
import net.moonleay.liljudd.util.EmbedUtil
|
||||||
|
|
||||||
|
class MaybeAvailableEditButton : IEditButton {
|
||||||
|
override val id: String = "public.edit.btn.timemanagement.maybeavailable"
|
||||||
|
|
||||||
class MaybeAvailableEditButton : EditButton("public.edit.btn.timemanagement.maybeavailable") {
|
|
||||||
override suspend fun onInteraction(
|
override suspend fun onInteraction(
|
||||||
interaction: ButtonInteraction,
|
interaction: ButtonInteraction,
|
||||||
response: PublicMessageInteractionResponseBehavior,
|
response: PublicMessageInteractionResponseBehavior,
|
||||||
|
@ -60,5 +63,6 @@ class MaybeAvailableEditButton : EditButton("public.edit.btn.timemanagement.mayb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AvailabilityManager.updateInChannel(interaction.channelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -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.buttons.timeplanner
|
package net.moonleay.liljudd.buttons.timeplanner
|
||||||
|
|
||||||
import dev.kord.core.behavior.edit
|
import dev.kord.core.behavior.edit
|
||||||
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior
|
||||||
|
@ -24,12 +24,14 @@ import dev.kord.core.entity.Guild
|
||||||
import dev.kord.core.entity.User
|
import dev.kord.core.entity.User
|
||||||
import dev.kord.core.entity.channel.MessageChannel
|
import dev.kord.core.entity.channel.MessageChannel
|
||||||
import dev.kord.core.entity.interaction.ButtonInteraction
|
import dev.kord.core.entity.interaction.ButtonInteraction
|
||||||
import dev.kord.rest.builder.message.modify.embed
|
import dev.kord.rest.builder.message.embed
|
||||||
import net.moonleay.lilJudd.Bot
|
import net.moonleay.liljudd.Bot
|
||||||
import net.moonleay.lilJudd.buttons.component.EditButton
|
import net.moonleay.liljudd.buttons.component.IEditButton
|
||||||
import net.moonleay.lilJudd.util.EmbedUtil
|
import net.moonleay.liljudd.features.AvailabilityManager
|
||||||
|
import net.moonleay.liljudd.util.EmbedUtil
|
||||||
|
|
||||||
class NotAvailableEditButton : EditButton("public.edit.btn.timemanagement.notavailable") {
|
class NotAvailableEditButton : IEditButton {
|
||||||
|
override val id: String = "public.edit.btn.timemanagement.notavailable"
|
||||||
|
|
||||||
override suspend fun onInteraction(
|
override suspend fun onInteraction(
|
||||||
interaction: ButtonInteraction,
|
interaction: ButtonInteraction,
|
||||||
|
@ -61,5 +63,6 @@ class NotAvailableEditButton : EditButton("public.edit.btn.timemanagement.notava
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AvailabilityManager.updateInChannel(interaction.channelId)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -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
|
package net.moonleay.liljudd.data
|
||||||
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -29,6 +29,8 @@ 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() {
|
||||||
|
@ -51,6 +53,8 @@ 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()
|
||||||
|
@ -83,6 +87,8 @@ 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()
|
||||||
|
|
120
src/main/kotlin/net/moonleay/liljudd/data/NewsManager.kt
Normal file
120
src/main/kotlin/net/moonleay/liljudd/data/NewsManager.kt
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import java.io.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object NewsManager {
|
||||||
|
private const val foldername = "data"
|
||||||
|
private const val filename = "news.nick"
|
||||||
|
lateinit var shouldPost: String
|
||||||
|
lateinit var title: String
|
||||||
|
lateinit var news: String
|
||||||
|
|
||||||
|
///Load the needed credentials, generate a config if there is none
|
||||||
|
fun load() {
|
||||||
|
val folder = File(foldername)
|
||||||
|
if (!folder.exists()) {
|
||||||
|
save()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val configFile = File(folder, filename)
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
save()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val input: InputStream = FileInputStream(foldername + File.separator + filename)
|
||||||
|
val prop = Properties()
|
||||||
|
prop.load(input)
|
||||||
|
shouldPost = prop.getProperty("shouldPost")
|
||||||
|
title = prop.getProperty("title")
|
||||||
|
news = prop.getProperty("news")
|
||||||
|
input.close()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun update(){
|
||||||
|
val folder = File(foldername)
|
||||||
|
if (!folder.exists()) {
|
||||||
|
try {
|
||||||
|
folder.mkdirs()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val configFile = File(foldername + File.separator + filename)
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
try {
|
||||||
|
configFile.createNewFile()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val output: OutputStream = FileOutputStream(foldername + File.separator + filename)
|
||||||
|
val prop = Properties()
|
||||||
|
prop.setProperty("shouldPost", shouldPost)
|
||||||
|
prop.setProperty("title", title)
|
||||||
|
prop.setProperty("news", news)
|
||||||
|
prop.store(output, null)
|
||||||
|
output.close()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///generate a new sample config
|
||||||
|
private fun save() {
|
||||||
|
val folder = File(foldername)
|
||||||
|
if (!folder.exists()) {
|
||||||
|
try {
|
||||||
|
folder.mkdirs()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val configFile = File(foldername + File.separator + filename)
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
try {
|
||||||
|
configFile.createNewFile()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val output: OutputStream = FileOutputStream(foldername + File.separator + filename)
|
||||||
|
val prop = Properties()
|
||||||
|
prop.setProperty("shouldPost", "no")
|
||||||
|
prop.setProperty("title", "empty")
|
||||||
|
prop.setProperty("news", "empty")
|
||||||
|
prop.store(output, null)
|
||||||
|
output.close()
|
||||||
|
|
||||||
|
shouldPost = "no"
|
||||||
|
title = "empty"
|
||||||
|
news = "empty"
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
src/main/kotlin/net/moonleay/liljudd/data/StacktraceSaver.kt
Normal file
37
src/main/kotlin/net/moonleay/liljudd/data/StacktraceSaver.kt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
object StacktraceSaver {
|
||||||
|
fun saveStacktrace(stacktrace: Throwable, timestamp: Long) {
|
||||||
|
createFolder()
|
||||||
|
val dir = File("data", "stacktraces")
|
||||||
|
File(dir, "$timestamp.stk").bufferedWriter().use { out ->
|
||||||
|
out.write(stacktrace.stackTraceToString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createFolder() {
|
||||||
|
val dir = File("data", "stacktraces")
|
||||||
|
if (!dir.exists())
|
||||||
|
dir.mkdir()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink
|
||||||
|
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import net.moonleay.liljudd.build.BuildConstants
|
||||||
|
import net.moonleay.liljudd.data.api.splatoon3ink.schedules.Schedules
|
||||||
|
import net.moonleay.liljudd.util.NetUtil
|
||||||
|
|
||||||
|
object Splatoon3Api {
|
||||||
|
|
||||||
|
var schedules: Schedules? = null
|
||||||
|
|
||||||
|
fun updateSchedule() {
|
||||||
|
val response = NetUtil.GETJsonData("https://splatoon3.ink/data/schedules.json", "lilJudd/${BuildConstants.version}")
|
||||||
|
if (response.startsWith("error")){
|
||||||
|
println("Error: $response")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
schedules = Json.decodeFromString(response)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink
|
||||||
|
|
||||||
|
import net.moonleay.liljudd.data.api.splatoon3ink.schedules.BankaraNode
|
||||||
|
import net.moonleay.liljudd.data.api.splatoon3ink.schedules.RegularNode
|
||||||
|
import net.moonleay.liljudd.data.api.splatoon3ink.schedules.SalmonRunNode
|
||||||
|
import net.moonleay.liljudd.data.api.splatoon3ink.schedules.XNode
|
||||||
|
import net.moonleay.liljudd.util.TimeUtil
|
||||||
|
|
||||||
|
object Splatoon3ApiDataGrabber {
|
||||||
|
fun getRegularMode(timestamp: Long): RegularNode {
|
||||||
|
Splatoon3Api.schedules!!.data.regularSchedules.nodes.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 getOpenMode(timestamp: Long): BankaraNode {
|
||||||
|
Splatoon3Api.schedules!!.data.bankaraSchedules.nodes.map { modeData ->
|
||||||
|
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
|
||||||
|
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
|
||||||
|
if (timestamp in startTime..endTime) {
|
||||||
|
modeData.bankaraMatchSettings!!.map { matchSetting ->
|
||||||
|
if (matchSetting.bankaraMode == "OPEN")
|
||||||
|
return modeData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw Exception("No current mode found")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getXMode(timestamp: Long): XNode {
|
||||||
|
Splatoon3Api.schedules!!.data.xSchedules.nodes.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 getSeriesMode(timestamp: Long): BankaraNode {
|
||||||
|
Splatoon3Api.schedules!!.data.bankaraSchedules.nodes.map { modeData ->
|
||||||
|
val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC")
|
||||||
|
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
|
||||||
|
if (timestamp in startTime..endTime) {
|
||||||
|
modeData.bankaraMatchSettings!!.map { matchSetting ->
|
||||||
|
if (matchSetting.bankaraMode == "CHALLENGE")
|
||||||
|
return modeData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw Exception("No current mode found")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSalmonRun(timestamp: Long): SalmonRunNode {
|
||||||
|
Splatoon3Api.schedules!!.data.coopGroupingSchedule.regularSchedules.nodes.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 getRotationTime(timestamp: Long): String {
|
||||||
|
val modeData = getRegularMode(timestamp)
|
||||||
|
val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC")
|
||||||
|
val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime)
|
||||||
|
return "$diffStamp left in rotation"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getRegularMapsFormatted(timestamp: Long): String {
|
||||||
|
val modeData = getRegularMode(timestamp)
|
||||||
|
val map1 = modeData.regularMatchSetting.vsStages[0].name.split(" ")[0]
|
||||||
|
val map2 = modeData.regularMatchSetting.vsStages[1].name.split(" ")[0]
|
||||||
|
return "R: $map1, $map2"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getOpenMapFormatted(timestamp: Long): String {
|
||||||
|
val modeData = getOpenMode(timestamp)
|
||||||
|
// FIXME: This may cause issues if there is a Splatfest going on
|
||||||
|
// TODO: Check if this works during splatfest
|
||||||
|
// The Open Mode should always be the second mode in the list
|
||||||
|
// FIXME: Add check if 2nd itm in list is open mode
|
||||||
|
val map1 = modeData.bankaraMatchSettings!![1].vsStages[0].name.split(" ")[0]
|
||||||
|
val map2 = modeData.bankaraMatchSettings[1].vsStages[1].name.split(" ")[0]
|
||||||
|
return "O: ${modeData.bankaraMatchSettings[1].vsRule.name}: $map1, $map2"
|
||||||
|
.replace("Rainmaker", "RMK")
|
||||||
|
.replace("Tower Control", "TC")
|
||||||
|
.replace("Splat Zones", "SZ")
|
||||||
|
.replace("Clam Blitz", "CB")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSeriesMapsFormatted(timestamp: Long): String {
|
||||||
|
val modeData = getSeriesMode(timestamp)
|
||||||
|
// FIXME: This may cause issues if there is a Splatfest going on
|
||||||
|
// TODO: Check all the same things as in getOpenMapFormatted
|
||||||
|
val map1 = modeData.bankaraMatchSettings!![0].vsStages[0].name.split(" ")[0]
|
||||||
|
val map2 = modeData.bankaraMatchSettings[0].vsStages[1].name.split(" ")[0]
|
||||||
|
return "S: ${modeData.bankaraMatchSettings[0].vsRule.name}: $map1, $map2"
|
||||||
|
.replace("Rainmaker", "RMK")
|
||||||
|
.replace("Tower Control", "TC")
|
||||||
|
.replace("Splat Zones", "SZ")
|
||||||
|
.replace("Clam Blitz", "CB")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getXMapFormatted(timestamp: Long): String {
|
||||||
|
val modeData = getXMode(timestamp)
|
||||||
|
val map1 = modeData.xMatchSetting.vsStages[0].name.split(" ")[0]
|
||||||
|
val map2 = modeData.xMatchSetting.vsStages[1].name.split(" ")[0]
|
||||||
|
return "X: ${modeData.xMatchSetting.vsRule.name}: $map1, $map2"
|
||||||
|
.replace("Rainmaker", "RMK")
|
||||||
|
.replace("Tower Control", "TC")
|
||||||
|
.replace("Splat Zones", "SZ")
|
||||||
|
.replace("Clam Blitz", "CB")
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BankaraMatchSetting(
|
||||||
|
@SerialName("bankaraMode")
|
||||||
|
val bankaraMode: String,
|
||||||
|
@SerialName("__isVsSetting")
|
||||||
|
val isVsSetting: String,
|
||||||
|
@SerialName("__typename")
|
||||||
|
val typename: String,
|
||||||
|
@SerialName("vsRule")
|
||||||
|
val vsRule: VsRule,
|
||||||
|
@SerialName("vsStages")
|
||||||
|
val vsStages: List<VsStage>
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BankaraNode(
|
||||||
|
@SerialName("bankaraMatchSettings")
|
||||||
|
val bankaraMatchSettings: List<BankaraMatchSetting>?,
|
||||||
|
@SerialName("endTime")
|
||||||
|
val endTime: String,
|
||||||
|
@SerialName("festMatchSettings")
|
||||||
|
val festMatchSettings: List<FestMatchSettingX>?,
|
||||||
|
@SerialName("startTime")
|
||||||
|
val startTime: String
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BankaraSchedules(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<BankaraNode>
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BannerImage(
|
||||||
|
@SerialName("url")
|
||||||
|
val url: String,
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class BigRunSchedules(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<SalmonRunNode>
|
||||||
|
)
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Boss(
|
||||||
|
@SerialName("id")
|
||||||
|
val id: String,
|
||||||
|
@SerialName("name")
|
||||||
|
val name: String
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Color(
|
||||||
|
@SerialName("a")
|
||||||
|
val a: Int,
|
||||||
|
@SerialName("b")
|
||||||
|
val b: Double,
|
||||||
|
@SerialName("g")
|
||||||
|
val g: Double,
|
||||||
|
@SerialName("r")
|
||||||
|
val r: Double
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CoopGroupingSchedule(
|
||||||
|
@SerialName("bannerImage")
|
||||||
|
val bannerImage: BannerImage?, // is null
|
||||||
|
@SerialName("bigRunSchedules")
|
||||||
|
val bigRunSchedules: BigRunSchedules,
|
||||||
|
@SerialName("regularSchedules")
|
||||||
|
val regularSchedules: RegularSchedules,
|
||||||
|
@SerialName("teamContestSchedules")
|
||||||
|
val teamContestSchedules: TeamContestSchedules?
|
||||||
|
)
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CoopSetting(
|
||||||
|
@SerialName("boss")
|
||||||
|
val boss: String?, // Not really String, but idk
|
||||||
|
@SerialName("coopStage")
|
||||||
|
val coopStage: CoopStage,
|
||||||
|
@SerialName("__isCoopSetting")
|
||||||
|
val isCoopSetting: String,
|
||||||
|
@SerialName("rule")
|
||||||
|
val rule: String,
|
||||||
|
@SerialName("__typename")
|
||||||
|
val typename: String,
|
||||||
|
@SerialName("weapons")
|
||||||
|
val weapons: List<Weapon>
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CoopStage(
|
||||||
|
@SerialName("id")
|
||||||
|
val id: String,
|
||||||
|
@SerialName("image")
|
||||||
|
val image: Image,
|
||||||
|
@SerialName("name")
|
||||||
|
val name: String,
|
||||||
|
@SerialName("thumbnailImage")
|
||||||
|
val thumbnailImage: ThumbnailImage
|
||||||
|
)
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CurrentFest(
|
||||||
|
@SerialName("endTime")
|
||||||
|
val endTime: String,
|
||||||
|
@SerialName("id")
|
||||||
|
val id: String,
|
||||||
|
@SerialName("midtermTime")
|
||||||
|
val midtermTime: String,
|
||||||
|
@SerialName("startTime")
|
||||||
|
val startTime: String,
|
||||||
|
@SerialName("state")
|
||||||
|
val state: String,
|
||||||
|
@SerialName("teams")
|
||||||
|
val teams: List<Team>,
|
||||||
|
@SerialName("title")
|
||||||
|
val title: String,
|
||||||
|
@SerialName("tricolorStage")
|
||||||
|
val tricolorStage: TricolorStage
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CurrentPlayer(
|
||||||
|
@SerialName("userIcon")
|
||||||
|
val userIcon: UserIcon
|
||||||
|
)
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class EventNode(
|
||||||
|
@SerialName("leagueMatchSetting")
|
||||||
|
val leagueMatchSetting: LeagueMatchSetting,
|
||||||
|
@SerialName("timePeriods")
|
||||||
|
val timePeriods: List<TimePeriod>
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class EventSchedules(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<EventNode>
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class FestMatchSettingX(
|
||||||
|
@SerialName("__isVsSetting")
|
||||||
|
val isVsSetting: String,
|
||||||
|
@SerialName("__typename")
|
||||||
|
val typename: String,
|
||||||
|
@SerialName("vsRule")
|
||||||
|
val vsRule: VsRule,
|
||||||
|
@SerialName("vsStages")
|
||||||
|
val vsStages: List<VsStage>
|
||||||
|
)
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class FestMatchSettingXX(
|
||||||
|
@SerialName("__typename")
|
||||||
|
val typename: String
|
||||||
|
)
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class FestNode(
|
||||||
|
@SerialName("endTime")
|
||||||
|
val endTime: String,
|
||||||
|
@SerialName("festMatchSettings")
|
||||||
|
val festMatchSettings: FestMatchSettingX?,
|
||||||
|
@SerialName("startTime")
|
||||||
|
val startTime: String
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class FestSchedules(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<FestNode>
|
||||||
|
)
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,11 +16,14 @@
|
||||||
* 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.tables
|
package net.moonleay.liljudd.data.api.splatoon3ink.schedules
|
||||||
|
|
||||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
|
||||||
|
|
||||||
object TimePlanningChannels : IntIdTable() {
|
import kotlinx.serialization.SerialName
|
||||||
var serverid = varchar("serverid", 50)
|
import kotlinx.serialization.Serializable
|
||||||
val channelid = varchar("channelid", 50)
|
|
||||||
}
|
@Serializable
|
||||||
|
data class Image(
|
||||||
|
@SerialName("url")
|
||||||
|
val url: String
|
||||||
|
)
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class LeagueMatchEvent(
|
||||||
|
@SerialName("desc")
|
||||||
|
val desc: String,
|
||||||
|
@SerialName("id")
|
||||||
|
val id: String,
|
||||||
|
@SerialName("leagueMatchEventId")
|
||||||
|
val leagueMatchEventId: String,
|
||||||
|
@SerialName("name")
|
||||||
|
val name: String,
|
||||||
|
@SerialName("regulation")
|
||||||
|
val regulation: String,
|
||||||
|
@SerialName("regulationUrl")
|
||||||
|
val regulationUrl: String? // is null
|
||||||
|
)
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class LeagueMatchSetting(
|
||||||
|
@SerialName("__isVsSetting")
|
||||||
|
val isVsSetting: String,
|
||||||
|
@SerialName("leagueMatchEvent")
|
||||||
|
val leagueMatchEvent: LeagueMatchEvent,
|
||||||
|
@SerialName("__typename")
|
||||||
|
val typename: String,
|
||||||
|
@SerialName("vsRule")
|
||||||
|
val vsRule: VsRule,
|
||||||
|
@SerialName("vsStages")
|
||||||
|
val vsStages: List<VsStage>
|
||||||
|
)
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,19 +16,22 @@
|
||||||
* 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
|
package net.moonleay.liljudd.data.api.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
import org.jetbrains.exposed.sql.Database
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
object DB {
|
@Serializable
|
||||||
//Connect to the provided DB; trows errors, if the DB is not avalible.
|
data class MapNode(
|
||||||
fun connect(dbDomain: String, dbName: String, dbUser: String, dbPasswd: String) {
|
@SerialName("id")
|
||||||
Database.connect(
|
val id: String,
|
||||||
"jdbc:postgresql://$dbDomain/$dbName",
|
@SerialName("name")
|
||||||
driver = "org.postgresql.Driver",
|
val name: String,
|
||||||
user = dbUser,
|
@SerialName("originalImage")
|
||||||
password = dbPasswd
|
val originalImage: OriginalImage,
|
||||||
)
|
@SerialName("stats")
|
||||||
}
|
val stats: String?, // is null
|
||||||
}
|
@SerialName("vsStageId")
|
||||||
|
val vsStageId: Int
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class OriginalImage(
|
||||||
|
@SerialName("url")
|
||||||
|
val url: String
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RegularMatchSetting(
|
||||||
|
@SerialName("__isVsSetting")
|
||||||
|
val isVsSetting: String,
|
||||||
|
@SerialName("__typename")
|
||||||
|
val typename: String,
|
||||||
|
@SerialName("vsRule")
|
||||||
|
val vsRule: VsRule,
|
||||||
|
@SerialName("vsStages")
|
||||||
|
val vsStages: List<VsStage>
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RegularNode(
|
||||||
|
@SerialName("endTime")
|
||||||
|
val endTime: String,
|
||||||
|
@SerialName("festMatchSettings")
|
||||||
|
val festMatchSettings: FestMatchSettingXX?,
|
||||||
|
@SerialName("regularMatchSetting")
|
||||||
|
val regularMatchSetting: RegularMatchSetting,
|
||||||
|
@SerialName("startTime")
|
||||||
|
val startTime: String
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RegularSchedules(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<SalmonRunNode>
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class RegularSchedulesX(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<RegularNode>
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SalmonRunNode(
|
||||||
|
@SerialName("endTime")
|
||||||
|
val endTime: String,
|
||||||
|
@SerialName("setting")
|
||||||
|
val setting: Setting,
|
||||||
|
@SerialName("__splatoon3ink_king_salmonid_guess")
|
||||||
|
val splatoon3inkKingSalmonidGuess: String,
|
||||||
|
@SerialName("startTime")
|
||||||
|
val startTime: String
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Schedules(
|
||||||
|
@SerialName("data")
|
||||||
|
val data: SchedulesData
|
||||||
|
)
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SchedulesData(
|
||||||
|
@SerialName("bankaraSchedules")
|
||||||
|
val bankaraSchedules: BankaraSchedules,
|
||||||
|
@SerialName("coopGroupingSchedule")
|
||||||
|
val coopGroupingSchedule: CoopGroupingSchedule,
|
||||||
|
@SerialName("currentFest")
|
||||||
|
val currentFest: CurrentFest?,
|
||||||
|
@SerialName("currentPlayer")
|
||||||
|
val currentPlayer: CurrentPlayer,
|
||||||
|
@SerialName("eventSchedules")
|
||||||
|
val eventSchedules: EventSchedules,
|
||||||
|
@SerialName("festSchedules")
|
||||||
|
val festSchedules: FestSchedules,
|
||||||
|
@SerialName("regularSchedules")
|
||||||
|
val regularSchedules: RegularSchedulesX,
|
||||||
|
@SerialName("vsStages")
|
||||||
|
val vsStages: VsStages,
|
||||||
|
@SerialName("xSchedules")
|
||||||
|
val xSchedules: XSchedules
|
||||||
|
)
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Setting(
|
||||||
|
@SerialName("boss")
|
||||||
|
val boss: Boss,
|
||||||
|
@SerialName("coopStage")
|
||||||
|
val coopStage: CoopStage,
|
||||||
|
@SerialName("__isCoopSetting")
|
||||||
|
val isCoopSetting: String,
|
||||||
|
@SerialName("__typename")
|
||||||
|
val typename: String,
|
||||||
|
@SerialName("weapons")
|
||||||
|
val weapons: List<Weapon>
|
||||||
|
)
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Team(
|
||||||
|
@SerialName("color")
|
||||||
|
val color: Color,
|
||||||
|
@SerialName("id")
|
||||||
|
val id: String,
|
||||||
|
// @SerialName("myVoteState")
|
||||||
|
// val myVoteState: Any?
|
||||||
|
)
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,13 +16,18 @@
|
||||||
* 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.tables
|
package net.moonleay.liljudd.data.api.splatoon3ink.schedules
|
||||||
|
|
||||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
|
||||||
|
|
||||||
object PlanningNotifierRoles : IntIdTable() {
|
import kotlinx.serialization.SerialName
|
||||||
var serverid = varchar("serverid", 50)
|
import kotlinx.serialization.Serializable
|
||||||
var channelid = varchar("channelid", 50)
|
|
||||||
var hastimeroleid = varchar("hastimeroleid", 50)
|
@Serializable
|
||||||
var wantstobenotifiedid = varchar("wantstobenotifiedid", 50)
|
data class TeamContestNode(
|
||||||
}
|
@SerialName("endTime")
|
||||||
|
val endTime: String,
|
||||||
|
@SerialName("setting")
|
||||||
|
val setting: CoopSetting,
|
||||||
|
@SerialName("startTime")
|
||||||
|
val startTime: String
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class TeamContestSchedules(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<TeamContestNode> // This is a placeholder.
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ThumbnailImage(
|
||||||
|
@SerialName("url")
|
||||||
|
val url: String
|
||||||
|
)
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class TimePeriod(
|
||||||
|
@SerialName("endTime")
|
||||||
|
val endTime: String,
|
||||||
|
@SerialName("startTime")
|
||||||
|
val startTime: String
|
||||||
|
)
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class TricolorStage(
|
||||||
|
@SerialName("id")
|
||||||
|
val id: String,
|
||||||
|
@SerialName("image")
|
||||||
|
val image: Image,
|
||||||
|
@SerialName("name")
|
||||||
|
val name: String
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class UserIcon(
|
||||||
|
@SerialName("url")
|
||||||
|
val url: String
|
||||||
|
)
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class VsRule(
|
||||||
|
@SerialName("id")
|
||||||
|
val id: String,
|
||||||
|
@SerialName("name")
|
||||||
|
val name: String,
|
||||||
|
@SerialName("rule")
|
||||||
|
val rule: String
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class VsStage(
|
||||||
|
@SerialName("id")
|
||||||
|
val id: String,
|
||||||
|
@SerialName("image")
|
||||||
|
val image: Image,
|
||||||
|
@SerialName("name")
|
||||||
|
val name: String,
|
||||||
|
@SerialName("vsStageId")
|
||||||
|
val vsStageId: Int
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class VsStages(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<MapNode>
|
||||||
|
)
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Weapon(
|
||||||
|
@SerialName("image")
|
||||||
|
val image: Image,
|
||||||
|
@SerialName("name")
|
||||||
|
val name: String,
|
||||||
|
@SerialName("__splatoon3ink_id")
|
||||||
|
val splatoon3inkId: String
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class XMatchSetting(
|
||||||
|
@SerialName("__isVsSetting")
|
||||||
|
val isVsSetting: String,
|
||||||
|
@SerialName("__typename")
|
||||||
|
val typename: String,
|
||||||
|
@SerialName("vsRule")
|
||||||
|
val vsRule: VsRule,
|
||||||
|
@SerialName("vsStages")
|
||||||
|
val vsStages: List<VsStage>
|
||||||
|
)
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class XNode(
|
||||||
|
@SerialName("endTime")
|
||||||
|
val endTime: String,
|
||||||
|
@SerialName("festMatchSettings")
|
||||||
|
val festMatchSettings: FestMatchSettingXX?,
|
||||||
|
@SerialName("startTime")
|
||||||
|
val startTime: String,
|
||||||
|
@SerialName("xMatchSetting")
|
||||||
|
val xMatchSetting: XMatchSetting
|
||||||
|
)
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.splatoon3ink.schedules
|
||||||
|
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class XSchedules(
|
||||||
|
@SerialName("nodes")
|
||||||
|
val nodes: List<XNode>
|
||||||
|
)
|
55
src/main/kotlin/net/moonleay/liljudd/data/database/DB.kt
Normal file
55
src/main/kotlin/net/moonleay/liljudd/data/database/DB.kt
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* 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.database
|
||||||
|
|
||||||
|
|
||||||
|
import net.moonleay.liljudd.data.database.tables.MatchPlanningData
|
||||||
|
import net.moonleay.liljudd.data.database.tables.PlanningNotifierRoles
|
||||||
|
import net.moonleay.liljudd.data.database.tables.TimePlanningChannels
|
||||||
|
import net.moonleay.liljudd.data.database.tables.TimePlanningMessages
|
||||||
|
import org.jetbrains.exposed.sql.Database
|
||||||
|
import org.jetbrains.exposed.sql.SchemaUtils
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
|
object DB {
|
||||||
|
private var connected = false
|
||||||
|
|
||||||
|
//Connect to the provided DB; trows errors, if the DB is not available.
|
||||||
|
fun connect(dbDomain: String, dbName: String, dbUser: String, dbPasswd: String) {
|
||||||
|
Database.connect(
|
||||||
|
"jdbc:postgresql://$dbDomain/$dbName",
|
||||||
|
driver = "org.postgresql.Driver",
|
||||||
|
user = dbUser,
|
||||||
|
password = dbPasswd
|
||||||
|
)
|
||||||
|
connected = true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun register() {
|
||||||
|
if (!connected)
|
||||||
|
return
|
||||||
|
// Register tables here
|
||||||
|
transaction {
|
||||||
|
SchemaUtils.create(TimePlanningChannels)
|
||||||
|
SchemaUtils.create(TimePlanningMessages)
|
||||||
|
SchemaUtils.create(MatchPlanningData)
|
||||||
|
SchemaUtils.create(PlanningNotifierRoles)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* 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.database.entry
|
||||||
|
|
||||||
|
data class MatchPlanningDataData(
|
||||||
|
val id: Int,
|
||||||
|
val serverID: Long,
|
||||||
|
val channelID: Long,
|
||||||
|
val matchType: String,
|
||||||
|
val registererID: Long,
|
||||||
|
val roleID: Long,
|
||||||
|
val opponentName: String,
|
||||||
|
val messageID: Long,
|
||||||
|
val timestamp: Long,
|
||||||
|
val jobString: String
|
||||||
|
)
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,11 +16,12 @@
|
||||||
* 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.entry
|
package net.moonleay.liljudd.data.database.entry
|
||||||
|
|
||||||
data class PlanningNotifierRolesData(
|
data class PlanningNotifierRolesData(
|
||||||
val serverID: String, // The id of the server
|
val id: Int, // The id of the entry
|
||||||
val channelId: String, // The id of the channel
|
val serverID: Long, // The id of the server
|
||||||
val hastimeroleid: String, // The id of the role that has time today
|
val channelID: Long, // The id of the channel
|
||||||
val wantstobenotifid: String // The id of the role that wants to be notified
|
val hasTimeRoleID: Long, // The id of the role that has time today
|
||||||
|
val wantsToBeNotifiedID: Long // The id of the role that wants to be notified
|
||||||
)
|
)
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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.database.entry
|
||||||
|
|
||||||
|
data class TimePlanningChannelsData(
|
||||||
|
val id: Int,
|
||||||
|
val serverID: Long,
|
||||||
|
val channelID: Long,
|
||||||
|
)
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,11 +16,12 @@
|
||||||
* 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.entry
|
package net.moonleay.liljudd.data.database.entry
|
||||||
|
|
||||||
data class TimePlanningMessagesData(
|
data class TimePlanningMessagesData(
|
||||||
val serverid: String, // The discord server id
|
val id: Int, // The id of the entry
|
||||||
val channelid: String, // The discord channel id
|
val serverID: Long, // The discord server id
|
||||||
val weekstamp: String, // The timestamp of the monday of the week at 4am UTC
|
val channelID: Long, // The discord channel id
|
||||||
val messageids: String // IDs are in the following format: "{weekdayNr}:{id};{weekdayNr}:{id};[etc.]"
|
val weekstamp: Long, // The timestamp of the monday of the week at 4am UTC
|
||||||
|
val messageIDs: String // IDs are in the following format: "{weekdayNr}:{id};{weekdayNr}:{id};[etc.]"
|
||||||
)
|
)
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
* 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.database.repository
|
||||||
|
|
||||||
|
import net.moonleay.liljudd.data.database.entry.MatchPlanningDataData
|
||||||
|
import net.moonleay.liljudd.data.database.tables.MatchPlanningData
|
||||||
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||||
|
import org.jetbrains.exposed.sql.and
|
||||||
|
import org.jetbrains.exposed.sql.deleteWhere
|
||||||
|
import org.jetbrains.exposed.sql.insert
|
||||||
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
|
object MatchPlanningDataRepository {
|
||||||
|
|
||||||
|
fun getAll(): List<MatchPlanningDataData> {
|
||||||
|
val dataList = mutableListOf<MatchPlanningDataData>()
|
||||||
|
transaction {
|
||||||
|
MatchPlanningData.selectAll().forEach {
|
||||||
|
dataList.add(
|
||||||
|
MatchPlanningDataData(
|
||||||
|
it[MatchPlanningData.id],
|
||||||
|
it[MatchPlanningData.serverid],
|
||||||
|
it[MatchPlanningData.channelid],
|
||||||
|
it[MatchPlanningData.matchtype],
|
||||||
|
it[MatchPlanningData.registererid],
|
||||||
|
it[MatchPlanningData.roleid],
|
||||||
|
it[MatchPlanningData.opponentName],
|
||||||
|
it[MatchPlanningData.messageid],
|
||||||
|
it[MatchPlanningData.timestamp],
|
||||||
|
it[MatchPlanningData.jobstr]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataList
|
||||||
|
}
|
||||||
|
|
||||||
|
fun get(id: Int): MatchPlanningDataData? =
|
||||||
|
transaction {
|
||||||
|
MatchPlanningData.selectAll().where { MatchPlanningData.id eq id }.firstOrNull()?.let {
|
||||||
|
MatchPlanningDataData(
|
||||||
|
it[MatchPlanningData.id],
|
||||||
|
it[MatchPlanningData.serverid],
|
||||||
|
it[MatchPlanningData.channelid],
|
||||||
|
it[MatchPlanningData.matchtype],
|
||||||
|
it[MatchPlanningData.registererid],
|
||||||
|
it[MatchPlanningData.roleid],
|
||||||
|
it[MatchPlanningData.opponentName],
|
||||||
|
it[MatchPlanningData.messageid],
|
||||||
|
it[MatchPlanningData.timestamp],
|
||||||
|
it[MatchPlanningData.jobstr]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getFromMessageInChannelInServer(messageID: Long, channelID: Long, serverID: Long): MatchPlanningDataData? =
|
||||||
|
transaction {
|
||||||
|
MatchPlanningData.selectAll().where {
|
||||||
|
MatchPlanningData.messageid eq (messageID) and (
|
||||||
|
MatchPlanningData.serverid eq (serverID)) and (
|
||||||
|
MatchPlanningData.channelid eq (channelID))
|
||||||
|
}.firstOrNull()?.let {
|
||||||
|
MatchPlanningDataData(
|
||||||
|
it[MatchPlanningData.id],
|
||||||
|
it[MatchPlanningData.serverid],
|
||||||
|
it[MatchPlanningData.channelid],
|
||||||
|
it[MatchPlanningData.matchtype],
|
||||||
|
it[MatchPlanningData.registererid],
|
||||||
|
it[MatchPlanningData.roleid],
|
||||||
|
it[MatchPlanningData.opponentName],
|
||||||
|
it[MatchPlanningData.messageid],
|
||||||
|
it[MatchPlanningData.timestamp],
|
||||||
|
it[MatchPlanningData.jobstr]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun delete(id: Int) {
|
||||||
|
transaction {
|
||||||
|
MatchPlanningData.deleteWhere { MatchPlanningData.id eq id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun write(data: MatchPlanningDataData): Int =
|
||||||
|
transaction {
|
||||||
|
MatchPlanningData.insert {
|
||||||
|
it[serverid] = data.serverID
|
||||||
|
it[channelid] = data.channelID
|
||||||
|
it[matchtype] = data.matchType
|
||||||
|
it[registererid] = data.registererID
|
||||||
|
it[roleid] = data.roleID
|
||||||
|
it[opponentName] = data.opponentName
|
||||||
|
it[messageid] = data.messageID
|
||||||
|
it[timestamp] = data.timestamp
|
||||||
|
it[jobstr] = data.jobString
|
||||||
|
} get MatchPlanningData.id
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* 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.database.repository
|
||||||
|
|
||||||
|
import net.moonleay.liljudd.data.database.entry.PlanningNotifierRolesData
|
||||||
|
import net.moonleay.liljudd.data.database.tables.PlanningNotifierRoles
|
||||||
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||||
|
import org.jetbrains.exposed.sql.and
|
||||||
|
import org.jetbrains.exposed.sql.deleteWhere
|
||||||
|
import org.jetbrains.exposed.sql.insert
|
||||||
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
|
object PlanningNotifierRolesRepository {
|
||||||
|
|
||||||
|
fun getAll(): List<PlanningNotifierRolesData> {
|
||||||
|
val dataList = mutableListOf<PlanningNotifierRolesData>()
|
||||||
|
transaction {
|
||||||
|
for (pnr in PlanningNotifierRoles.selectAll()) {
|
||||||
|
dataList.add(
|
||||||
|
PlanningNotifierRolesData(
|
||||||
|
pnr[PlanningNotifierRoles.id],
|
||||||
|
pnr[PlanningNotifierRoles.serverid],
|
||||||
|
pnr[PlanningNotifierRoles.channelid],
|
||||||
|
pnr[PlanningNotifierRoles.hastimeroleid],
|
||||||
|
pnr[PlanningNotifierRoles.wantstobenotifiedid]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataList
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getForChannel(channelID: Long): PlanningNotifierRolesData? =
|
||||||
|
transaction {
|
||||||
|
PlanningNotifierRoles.selectAll().where { PlanningNotifierRoles.channelid eq channelID }.firstOrNull()?.let {
|
||||||
|
PlanningNotifierRolesData(
|
||||||
|
it[PlanningNotifierRoles.id],
|
||||||
|
it[PlanningNotifierRoles.serverid],
|
||||||
|
it[PlanningNotifierRoles.channelid],
|
||||||
|
it[PlanningNotifierRoles.hastimeroleid],
|
||||||
|
it[PlanningNotifierRoles.wantstobenotifiedid]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getForChannelInServer(channelID: Long, serverID: Long): PlanningNotifierRolesData? =
|
||||||
|
transaction {
|
||||||
|
PlanningNotifierRoles.selectAll()
|
||||||
|
.where { PlanningNotifierRoles.channelid eq channelID and (PlanningNotifierRoles.serverid eq serverID) }
|
||||||
|
.firstOrNull()?.let {
|
||||||
|
PlanningNotifierRolesData(
|
||||||
|
it[PlanningNotifierRoles.id],
|
||||||
|
it[PlanningNotifierRoles.serverid],
|
||||||
|
it[PlanningNotifierRoles.channelid],
|
||||||
|
it[PlanningNotifierRoles.hastimeroleid],
|
||||||
|
it[PlanningNotifierRoles.wantstobenotifiedid]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun existsInChannel(channelID: Long): Boolean =
|
||||||
|
transaction {
|
||||||
|
PlanningNotifierRoles.selectAll().where { PlanningNotifierRoles.channelid eq channelID }.count() > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun existsInChannelFromSever(channelID: Long, serverID: Long): Boolean =
|
||||||
|
transaction {
|
||||||
|
PlanningNotifierRoles.selectAll()
|
||||||
|
.where { PlanningNotifierRoles.channelid eq channelID and (PlanningNotifierRoles.serverid eq serverID) }
|
||||||
|
.count() > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun write(data: PlanningNotifierRolesData) {
|
||||||
|
transaction {
|
||||||
|
PlanningNotifierRoles.insert {
|
||||||
|
it[serverid] = data.serverID
|
||||||
|
it[channelid] = data.channelID
|
||||||
|
it[hastimeroleid] = data.hasTimeRoleID
|
||||||
|
it[wantstobenotifiedid] = data.wantsToBeNotifiedID
|
||||||
|
} get PlanningNotifierRoles.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun delete(id: Int) {
|
||||||
|
transaction {
|
||||||
|
PlanningNotifierRoles.deleteWhere { PlanningNotifierRoles.id eq id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* 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.database.repository
|
||||||
|
|
||||||
|
import net.moonleay.liljudd.data.database.entry.TimePlanningChannelsData
|
||||||
|
import net.moonleay.liljudd.data.database.tables.TimePlanningChannels
|
||||||
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||||
|
import org.jetbrains.exposed.sql.and
|
||||||
|
import org.jetbrains.exposed.sql.deleteWhere
|
||||||
|
import org.jetbrains.exposed.sql.insert
|
||||||
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
|
object TimePlanningChannelsRepository {
|
||||||
|
|
||||||
|
fun getAll(): List<TimePlanningChannelsData> {
|
||||||
|
val dataList = mutableListOf<TimePlanningChannelsData>()
|
||||||
|
transaction {
|
||||||
|
for (tp in TimePlanningChannels.selectAll())
|
||||||
|
dataList.add(
|
||||||
|
TimePlanningChannelsData(
|
||||||
|
id = tp[TimePlanningChannels.id],
|
||||||
|
serverID = tp[TimePlanningChannels.serverid],
|
||||||
|
channelID = tp[TimePlanningChannels.channelid],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return dataList
|
||||||
|
}
|
||||||
|
|
||||||
|
fun exists(channelID: Long, serverID: Long): Boolean =
|
||||||
|
transaction {
|
||||||
|
TimePlanningChannels.selectAll()
|
||||||
|
.where { TimePlanningChannels.channelid eq channelID and (TimePlanningChannels.serverid eq serverID) }
|
||||||
|
.firstOrNull() != null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun delete(id: Int) {
|
||||||
|
transaction {
|
||||||
|
TimePlanningChannels.deleteWhere { TimePlanningChannels.id eq id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deleteFromChannelInServer(channelID: Long, serverID: Long) {
|
||||||
|
transaction {
|
||||||
|
TimePlanningChannels.deleteWhere { channelid eq channelID and (serverid eq serverID) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun write(data: TimePlanningChannelsData): Int =
|
||||||
|
transaction {
|
||||||
|
TimePlanningChannels.insert {
|
||||||
|
it[serverid] = data.serverID
|
||||||
|
it[channelid] = data.channelID
|
||||||
|
} get TimePlanningChannels.id
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* 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.database.repository
|
||||||
|
|
||||||
|
import net.moonleay.liljudd.data.database.entry.TimePlanningMessagesData
|
||||||
|
import net.moonleay.liljudd.data.database.tables.TimePlanningMessages
|
||||||
|
import org.jetbrains.exposed.sql.and
|
||||||
|
import org.jetbrains.exposed.sql.insert
|
||||||
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
|
object TimePlanningMessagesRepository {
|
||||||
|
|
||||||
|
fun write(data: TimePlanningMessagesData): Int =
|
||||||
|
transaction {
|
||||||
|
TimePlanningMessages.insert {
|
||||||
|
it[serverid] = data.serverID
|
||||||
|
it[channelid] = data.channelID
|
||||||
|
it[weekstamp] = data.weekstamp
|
||||||
|
it[messageids] = data.messageIDs
|
||||||
|
} get TimePlanningMessages.id
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getWeek(stamp: Long): List<TimePlanningMessagesData> {
|
||||||
|
val dataList = mutableListOf<TimePlanningMessagesData>()
|
||||||
|
transaction {
|
||||||
|
for (pnr in TimePlanningMessages.selectAll().where { TimePlanningMessages.weekstamp eq (stamp) }) {
|
||||||
|
dataList.add(
|
||||||
|
TimePlanningMessagesData(
|
||||||
|
pnr[TimePlanningMessages.id],
|
||||||
|
pnr[TimePlanningMessages.serverid],
|
||||||
|
pnr[TimePlanningMessages.channelid],
|
||||||
|
pnr[TimePlanningMessages.weekstamp],
|
||||||
|
pnr[TimePlanningMessages.messageids]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataList
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getWeekInChannel(stamp: Long, channelID: Long): TimePlanningMessagesData? =
|
||||||
|
transaction {
|
||||||
|
TimePlanningMessages.selectAll()
|
||||||
|
.where { TimePlanningMessages.weekstamp eq (stamp) and (TimePlanningMessages.channelid eq channelID) }.firstOrNull()?.let {
|
||||||
|
TimePlanningMessagesData(
|
||||||
|
it[TimePlanningMessages.id],
|
||||||
|
it[TimePlanningMessages.serverid],
|
||||||
|
it[TimePlanningMessages.channelid],
|
||||||
|
it[TimePlanningMessages.weekstamp],
|
||||||
|
it[TimePlanningMessages.messageids]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* 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.database.tables
|
||||||
|
|
||||||
|
import org.jetbrains.exposed.sql.Table
|
||||||
|
|
||||||
|
object MatchPlanningData : Table(name = "new_matchplanning_data") {
|
||||||
|
var id = integer("id").autoIncrement()
|
||||||
|
var serverid = long("serverid")
|
||||||
|
var channelid = long("channelid")
|
||||||
|
var matchtype = varchar("matchtype", 50)
|
||||||
|
var registererid = long("registererid")
|
||||||
|
var roleid = long("roleid")
|
||||||
|
var opponentName = varchar("opponentname", 100)
|
||||||
|
var messageid = long("messageid")
|
||||||
|
var timestamp = long("timestamp")
|
||||||
|
var jobstr = varchar("jobstr", 50)
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.database.tables
|
||||||
|
|
||||||
|
import org.jetbrains.exposed.sql.Table
|
||||||
|
|
||||||
|
object PlanningNotifierRoles : Table(name = "new_planningnotifier_roles") {
|
||||||
|
var id = integer("id").autoIncrement()
|
||||||
|
var serverid = long("serverid")
|
||||||
|
var channelid = long("channelid")
|
||||||
|
var hastimeroleid = long("hastimeroleid")
|
||||||
|
var wantstobenotifiedid = long("wantstobenotifiedid")
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* 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.database.tables
|
||||||
|
|
||||||
|
import org.jetbrains.exposed.sql.Table
|
||||||
|
|
||||||
|
|
||||||
|
object TimePlanningChannels : Table(name = "new_timeplanning_channels") {
|
||||||
|
var id = integer("id").autoIncrement()
|
||||||
|
var serverid = long("serverid")
|
||||||
|
val channelid = long("channelid")
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,13 +16,14 @@
|
||||||
* 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.tables
|
package net.moonleay.liljudd.data.database.tables
|
||||||
|
|
||||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
import org.jetbrains.exposed.sql.Table
|
||||||
|
|
||||||
object TimePlanningMessages : IntIdTable() {
|
object TimePlanningMessages : Table(name = "new_timeplanning_messages") {
|
||||||
var serverid = varchar("serverid", 50)
|
var id = integer("id").autoIncrement()
|
||||||
var channelid = varchar("channelid", 50)
|
var serverid = long("serverid")
|
||||||
var weekstamp = varchar("weekstamp", 50)
|
var channelid = long("channelid")
|
||||||
|
var weekstamp = long("weekstamp")
|
||||||
var messageids = varchar("messageids", 200)
|
var messageids = varchar("messageids", 200)
|
||||||
}
|
}
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
* 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.extensions
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.Arguments
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.impl.enumChoice
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.converters.impl.channel
|
||||||
|
import com.kotlindiscord.kord.extensions.extensions.Extension
|
||||||
|
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
||||||
|
import com.kotlindiscord.kord.extensions.utils.hasPermission
|
||||||
|
import dev.kord.common.entity.Permission
|
||||||
|
import dev.kord.rest.builder.message.embed
|
||||||
|
import net.moonleay.liljudd.extensions.component.EnableOrDisable
|
||||||
|
import net.moonleay.liljudd.features.component.FeatureEnum
|
||||||
|
import net.moonleay.liljudd.features.component.FeatureManager
|
||||||
|
import net.moonleay.liljudd.util.EmbedColor
|
||||||
|
import net.moonleay.liljudd.util.Logger
|
||||||
|
import net.moonleay.liljudd.util.MessageUtil
|
||||||
|
|
||||||
|
class FeatureManageExtension : Extension() {
|
||||||
|
|
||||||
|
override val name = "feature"
|
||||||
|
override val allowApplicationCommandInDMs: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
|
|
||||||
|
override suspend fun setup() {
|
||||||
|
publicSlashCommand(::FeatureManagerArgs) {
|
||||||
|
name = "feature"
|
||||||
|
description = "Manage features"
|
||||||
|
|
||||||
|
this.action {
|
||||||
|
val u = this.user
|
||||||
|
if (!u.asMember(this.guild!!.id).hasPermission(Permission.Administrator)) {
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.color = EmbedColor.ERROR.color
|
||||||
|
this.title = "401: Not Authorized"
|
||||||
|
this.description =
|
||||||
|
"You cannot edit features, as you don't have the Administrator permission."
|
||||||
|
this.footer {
|
||||||
|
this.icon = u.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(u)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return@action
|
||||||
|
}
|
||||||
|
val gID = this.guild!!.id.value.toLong()
|
||||||
|
val cID = this.arguments.channel.id.value.toLong()
|
||||||
|
val channel = this.arguments.channel
|
||||||
|
val args = this.arguments
|
||||||
|
Logger.out("${args.feature.readableName} ${args.setStatus.readableName} ${channel.data.name.value}")
|
||||||
|
val f = FeatureManager.getFeature(args.feature)
|
||||||
|
if (f == null) {
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.color = EmbedColor.ERROR.color
|
||||||
|
this.title = "404: Not Found"
|
||||||
|
this.description = "The feature you are trying to edit does not exist."
|
||||||
|
this.footer {
|
||||||
|
this.icon = u.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(u)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return@action
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.arguments.setStatus == EnableOrDisable.ENABLE) {
|
||||||
|
val enabled = f.enable(u, gID, cID, channel, args)
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.color = enabled.color
|
||||||
|
this.title = enabled.title
|
||||||
|
this.description = enabled.description
|
||||||
|
this.footer {
|
||||||
|
this.icon = u.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(u)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return@action
|
||||||
|
}
|
||||||
|
val disabled = f.disable(u, gID, cID, channel, args)
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.color = disabled.color
|
||||||
|
this.title = disabled.title
|
||||||
|
this.description = disabled.description
|
||||||
|
this.footer {
|
||||||
|
this.icon = u.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(u)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class FeatureManagerArgs : Arguments() {
|
||||||
|
|
||||||
|
val feature by enumChoice<FeatureEnum> {
|
||||||
|
this.name = "feature"
|
||||||
|
this.description = "The targeted feature"
|
||||||
|
this.typeName = "en_US"
|
||||||
|
}
|
||||||
|
|
||||||
|
val setStatus by enumChoice<EnableOrDisable> {
|
||||||
|
this.name = "set"
|
||||||
|
this.description = "Set enabled or disabled"
|
||||||
|
this.typeName = "en_US"
|
||||||
|
}
|
||||||
|
|
||||||
|
val channel by channel {
|
||||||
|
this.name = "channel"
|
||||||
|
this.description = "Target Channel"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,30 +16,32 @@
|
||||||
* 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.extensions
|
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 dev.kord.common.Color
|
import dev.kord.rest.builder.message.embed
|
||||||
import net.moonleay.botendo.build.BuildConstants
|
import net.moonleay.liljudd.build.BuildConstants
|
||||||
import net.moonleay.lilJudd.util.MessageUtil
|
import net.moonleay.liljudd.util.EmbedColor
|
||||||
|
|
||||||
class VersionExtension : Extension() {
|
class InfoExtension : Extension() {
|
||||||
override val name = "version"
|
override val name = "info"
|
||||||
override suspend fun setup() {
|
override suspend fun setup() {
|
||||||
publicSlashCommand {
|
publicSlashCommand {
|
||||||
name = "version"
|
name = "info"
|
||||||
description = "Show infos about the bot"
|
description = "Show infos about the bot"
|
||||||
this.action {
|
this.action {
|
||||||
MessageUtil.sendEmbedForPublicSlashCommand(
|
this.respond {
|
||||||
this,
|
this.embed {
|
||||||
Color(0x52E01A),
|
this.color = EmbedColor.INFO.color
|
||||||
"Lil' Judd",
|
this.title = "Li'l Judd"
|
||||||
"Lil' Judd ***v." + BuildConstants.version + "***\n" +
|
this.description = "Li'l 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 + "***"
|
"Krontab ***v." + BuildConstants.krontabVersion + "***\n\n" +
|
||||||
)
|
"Splatoon 3 api data provided by splatoon3.ink"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,172 @@
|
||||||
|
/*
|
||||||
|
* 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.extensions
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.Arguments
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.impl.enumChoice
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.converters.impl.string
|
||||||
|
import com.kotlindiscord.kord.extensions.extensions.Extension
|
||||||
|
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
||||||
|
import dev.kord.core.behavior.createRole
|
||||||
|
import dev.kord.rest.builder.message.actionRow
|
||||||
|
import dev.kord.rest.builder.message.embed
|
||||||
|
import net.moonleay.liljudd.data.database.entry.MatchPlanningDataData
|
||||||
|
import net.moonleay.liljudd.data.database.repository.MatchPlanningDataRepository
|
||||||
|
import net.moonleay.liljudd.extensions.component.MatchTypes
|
||||||
|
import net.moonleay.liljudd.jobs.MatchJob
|
||||||
|
import net.moonleay.liljudd.jobs.component.JobManager
|
||||||
|
import net.moonleay.liljudd.util.EmbedColor
|
||||||
|
import net.moonleay.liljudd.util.EmbedUtil
|
||||||
|
import net.moonleay.liljudd.util.MessageUtil
|
||||||
|
import net.moonleay.liljudd.util.TimeUtil
|
||||||
|
|
||||||
|
class MatchExtension : Extension() {
|
||||||
|
|
||||||
|
override val name = "match"
|
||||||
|
override val allowApplicationCommandInDMs: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
|
|
||||||
|
override suspend fun setup() {
|
||||||
|
publicSlashCommand(::MatchArguments) {
|
||||||
|
name = "match"
|
||||||
|
description = "Create a match"
|
||||||
|
this.action {
|
||||||
|
val args = this.arguments
|
||||||
|
val m = this.member!!
|
||||||
|
val gID = this.guild!!.id.value
|
||||||
|
val cID = this.channel.id.value
|
||||||
|
val opponent = args.opponent
|
||||||
|
if (!TimeUtil.validateDateString(args.timeStamp)) {
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.color = EmbedColor.ERROR.color
|
||||||
|
this.title = "400: Bad Request"
|
||||||
|
this.description = "The given timestamp is invalid.\n" +
|
||||||
|
"Please use the format \"dd.MM.yyyy HH:mm\"."
|
||||||
|
this.footer {
|
||||||
|
this.icon = m.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(m.asUser())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return@action
|
||||||
|
}
|
||||||
|
// filter time to date:
|
||||||
|
val zdt = TimeUtil.getDateFromString(args.timeStamp)
|
||||||
|
// get the string for the cronjob
|
||||||
|
val jobString = TimeUtil.getCronjobStringFromDate(zdt)
|
||||||
|
// create the role
|
||||||
|
val role = this.guild!!.createRole {
|
||||||
|
this.name =
|
||||||
|
"${args.matchType.readableName} Vs ${opponent} At ${zdt.dayOfMonth}/${zdt.month}/${zdt.year} ${zdt.hour}:${zdt.minute}"
|
||||||
|
this.mentionable = true
|
||||||
|
}
|
||||||
|
// Check if the role was created successfully
|
||||||
|
if (role == null) {
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.color = EmbedColor.ERROR.color
|
||||||
|
this.title = "500: Internal Error"
|
||||||
|
this.description = "Could not find created role.\n" +
|
||||||
|
"It seems, that said role could not be created."
|
||||||
|
this.footer {
|
||||||
|
this.icon = m.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(m.asUser())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return@action
|
||||||
|
}
|
||||||
|
val msg = this.respond {
|
||||||
|
val eb = MessageUtil.getEmbedWithTable(
|
||||||
|
EmbedColor.INFO,
|
||||||
|
args.matchType.readableName,
|
||||||
|
"***Vs. $opponent***\n" +
|
||||||
|
"At ${args.timeStamp}\n" +
|
||||||
|
"Registered by ${m.mention}",
|
||||||
|
mapOf(
|
||||||
|
"Signed up" to listOf(),
|
||||||
|
"Unavailable" to listOf(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
this.embed {
|
||||||
|
this.color = eb.color
|
||||||
|
this.title = eb.title
|
||||||
|
this.description = eb.description
|
||||||
|
this.fields = eb.fields
|
||||||
|
this.footer {
|
||||||
|
this.icon = m.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(m.asUser())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.actionRow {
|
||||||
|
this.components.addAll(EmbedUtil.getMatchButtons().components)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val tID = MatchPlanningDataRepository.write(
|
||||||
|
MatchPlanningDataData(
|
||||||
|
0,
|
||||||
|
gID.toLong(),
|
||||||
|
cID.toLong(),
|
||||||
|
args.matchType.readableName,
|
||||||
|
m.id.value.toLong(),
|
||||||
|
role.id.value.toLong(),
|
||||||
|
opponent,
|
||||||
|
msg.id.value.toLong(),
|
||||||
|
(zdt.toEpochSecond() * 1000),
|
||||||
|
jobString
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if (tID == null || tID <= 0) {
|
||||||
|
return@action // Not saved to db
|
||||||
|
// TODO: Add error message
|
||||||
|
}
|
||||||
|
JobManager.addJob(
|
||||||
|
MatchJob(
|
||||||
|
jobString,
|
||||||
|
tID,
|
||||||
|
"${args.matchType.readableName}_Vs_${opponent}_[${tID}]-${gID}_${cID}",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inner class MatchArguments : Arguments() {
|
||||||
|
|
||||||
|
val matchType by enumChoice<MatchTypes> {
|
||||||
|
this.name = "match"
|
||||||
|
this.description = "The type of match"
|
||||||
|
this.typeName = "en_US"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val timeStamp by string {
|
||||||
|
this.name = "timestamp"
|
||||||
|
this.description = "The timestamp of the match. Format \"dd.MM.yyyy HH:mm\"."
|
||||||
|
}
|
||||||
|
|
||||||
|
val opponent by string {
|
||||||
|
this.name = "opponent"
|
||||||
|
this.description = "The opponent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,464 @@
|
||||||
|
/*
|
||||||
|
* 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.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 dev.kord.common.Color
|
||||||
|
import dev.kord.rest.builder.message.embed
|
||||||
|
import kotlinx.datetime.Clock
|
||||||
|
import net.moonleay.liljudd.data.api.splatoon3ink.Splatoon3ApiDataGrabber
|
||||||
|
import net.moonleay.liljudd.extensions.component.SplatoonOnlineMode
|
||||||
|
import net.moonleay.liljudd.util.TimeUtil
|
||||||
|
|
||||||
|
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 -> {
|
||||||
|
val regSched = Splatoon3ApiDataGrabber.getRegularMode(System.currentTimeMillis())
|
||||||
|
val regMaps = regSched.regularMatchSetting.vsStages
|
||||||
|
val regMap1 = regMaps[0]
|
||||||
|
val regMap2 = regMaps[1]
|
||||||
|
|
||||||
|
val serSched = Splatoon3ApiDataGrabber.getSeriesMode(System.currentTimeMillis())
|
||||||
|
val serMaps = serSched.bankaraMatchSettings!!.first().vsStages
|
||||||
|
val serMap1 = serMaps[0]
|
||||||
|
val serMap2 = serMaps[1]
|
||||||
|
|
||||||
|
val opnSched = Splatoon3ApiDataGrabber.getSeriesMode(System.currentTimeMillis())
|
||||||
|
val opnMaps = opnSched.bankaraMatchSettings!!.last().vsStages
|
||||||
|
val opnMap1 = opnMaps[0]
|
||||||
|
val opnMap2 = opnMaps[1]
|
||||||
|
|
||||||
|
val xSched = Splatoon3ApiDataGrabber.getXMode(System.currentTimeMillis())
|
||||||
|
val xMaps = xSched.xMatchSetting.vsStages
|
||||||
|
val xMap1 = xMaps[0]
|
||||||
|
val xMap2 = xMaps[1]
|
||||||
|
|
||||||
|
val salSched = Splatoon3ApiDataGrabber.getSalmonRun(System.currentTimeMillis())
|
||||||
|
val salMap = salSched.setting.coopStage.name
|
||||||
|
val salBoss = salSched.setting.boss.name
|
||||||
|
val salWeapons = salSched.setting.weapons
|
||||||
|
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.author {
|
||||||
|
this.name = "Current rotation for"
|
||||||
|
}
|
||||||
|
this.title = "All Modes"
|
||||||
|
this.description = "[[Open on website](https://splatoon3.ink/)]"
|
||||||
|
this.color = Color(0x1437FF)
|
||||||
|
|
||||||
|
this.thumbnail {
|
||||||
|
this.url = "https://static.moonleay.net/img/lilJudd/deepcut.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Regular (${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
regSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(regSched.endTime, "UTC")})"
|
||||||
|
this.value =
|
||||||
|
"${regSched.regularMatchSetting.vsRule.name} on ${regMap1.name} & ${regMap2.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Series (${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
serSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(serSched.endTime, "UTC")})"
|
||||||
|
this.value =
|
||||||
|
"${serSched.bankaraMatchSettings.first().vsRule.name} on ${serMap1.name} & ${serMap2.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Open (${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
opnSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(opnSched.endTime, "UTC")})"
|
||||||
|
this.value =
|
||||||
|
"${opnSched.bankaraMatchSettings.last().vsRule.name} on ${opnMap1.name} & ${opnMap2.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "X (${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
xSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(xSched.endTime, "UTC")})"
|
||||||
|
this.value = "${xSched.xMatchSetting.vsRule.name} on ${xMap1.name} & ${xMap2.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Salmon Run (${
|
||||||
|
TimeUtil.getTimeFromJSONTimeLong(
|
||||||
|
salSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTimeLong(salSched.endTime, "UTC")})"
|
||||||
|
this.value =
|
||||||
|
"${salBoss} on ${salMap} with ${salWeapons[0].name}, ${salWeapons[1].name}, ${salWeapons[2].name} & ${salWeapons[3].name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.timestamp = Clock.System.now()
|
||||||
|
this.footer {
|
||||||
|
this.text = "Data provided by splatoon3.ink"
|
||||||
|
this.icon = "https://fedi.splatoon3.ink/favicon.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SplatoonOnlineMode.REGULAR -> {
|
||||||
|
val regSched = Splatoon3ApiDataGrabber.getRegularMode(System.currentTimeMillis())
|
||||||
|
val regMaps = regSched.regularMatchSetting.vsStages
|
||||||
|
val regMap1 = regMaps[0]
|
||||||
|
val regMap2 = regMaps[1]
|
||||||
|
|
||||||
|
val regSched2 =
|
||||||
|
Splatoon3ApiDataGrabber.getRegularMode(System.currentTimeMillis() + 1000 * 60 * 60 * 2)
|
||||||
|
val regMaps2 = regSched2.regularMatchSetting.vsStages
|
||||||
|
val regMap12 = regMaps2[0]
|
||||||
|
val regMap22 = regMaps2[1]
|
||||||
|
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.author {
|
||||||
|
this.name = "Current rotation for"
|
||||||
|
}
|
||||||
|
this.title = "Regular Mode"
|
||||||
|
this.description = "[[Open on website](https://splatoon3.ink/)]"
|
||||||
|
this.color = Color(0x18c81b)
|
||||||
|
|
||||||
|
this.thumbnail {
|
||||||
|
this.url = "https://static.moonleay.net/img/lilJudd/regular.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Current (${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
regSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(regSched.endTime, "UTC")})"
|
||||||
|
this.value =
|
||||||
|
"${regSched.regularMatchSetting.vsRule.name} on ${regMap1.name} & ${regMap2.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
regSched2.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(regSched2.endTime, "UTC")}"
|
||||||
|
this.value =
|
||||||
|
"${regSched2.regularMatchSetting.vsRule.name} on ${regMap12.name} & ${regMap22.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.timestamp = Clock.System.now()
|
||||||
|
this.footer {
|
||||||
|
this.text = "Data provided by splatoon3.ink"
|
||||||
|
this.icon = "https://fedi.splatoon3.ink/favicon.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SplatoonOnlineMode.SERIES -> {
|
||||||
|
val serSched = Splatoon3ApiDataGrabber.getSeriesMode(System.currentTimeMillis())
|
||||||
|
val serMaps = serSched.bankaraMatchSettings!!.first().vsStages
|
||||||
|
val serMap1 = serMaps[0]
|
||||||
|
val serMap2 = serMaps[1]
|
||||||
|
|
||||||
|
val serSched2 =
|
||||||
|
Splatoon3ApiDataGrabber.getSeriesMode(System.currentTimeMillis() + 1000 * 60 * 60 * 2)
|
||||||
|
val serMaps2 = serSched2.bankaraMatchSettings!!.first().vsStages
|
||||||
|
val serMap12 = serMaps2[0]
|
||||||
|
val serMap22 = serMaps2[1]
|
||||||
|
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.author {
|
||||||
|
this.name = "Current rotation for"
|
||||||
|
}
|
||||||
|
this.title = "Ranked Series Mode"
|
||||||
|
this.description = "[[Open on website](https://splatoon3.ink/)]"
|
||||||
|
this.color = Color(0xE14412)
|
||||||
|
|
||||||
|
this.thumbnail {
|
||||||
|
this.url = "https://static.moonleay.net/img/lilJudd/bankara.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Current (${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
serSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(serSched.endTime, "UTC")})"
|
||||||
|
this.value =
|
||||||
|
"${serSched.bankaraMatchSettings.first().vsRule.name} on ${serMap1.name} & ${serMap2.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
serSched2.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(serSched2.endTime, "UTC")}"
|
||||||
|
this.value =
|
||||||
|
"${serSched2.bankaraMatchSettings.first().vsRule.name} on ${serMap12.name} & ${serMap22.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.timestamp = Clock.System.now()
|
||||||
|
this.footer {
|
||||||
|
this.text = "Data provided by splatoon3.ink"
|
||||||
|
this.icon = "https://fedi.splatoon3.ink/favicon.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SplatoonOnlineMode.OPEN -> {
|
||||||
|
val opnSched = Splatoon3ApiDataGrabber.getSeriesMode(System.currentTimeMillis())
|
||||||
|
val opnMaps = opnSched.bankaraMatchSettings!!.last().vsStages
|
||||||
|
val opnMap1 = opnMaps[0]
|
||||||
|
val opnMap2 = opnMaps[1]
|
||||||
|
|
||||||
|
val opnSched2 =
|
||||||
|
Splatoon3ApiDataGrabber.getSeriesMode(System.currentTimeMillis() + 1000 * 60 * 60 * 2)
|
||||||
|
val opnMaps2 = opnSched2.bankaraMatchSettings!!.last().vsStages
|
||||||
|
val opnMap12 = opnMaps2[0]
|
||||||
|
val opnMap22 = opnMaps2[1]
|
||||||
|
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.author {
|
||||||
|
this.name = "Current rotation for"
|
||||||
|
}
|
||||||
|
this.title = "Ranked Open Mode"
|
||||||
|
this.description = "[[Open on website](https://splatoon3.ink/)]"
|
||||||
|
this.color = Color(0xE14412)
|
||||||
|
|
||||||
|
this.thumbnail {
|
||||||
|
this.url = "https://static.moonleay.net/img/lilJudd/bankara.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Current (${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
opnSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(opnSched.endTime, "UTC")})"
|
||||||
|
this.value =
|
||||||
|
"${opnSched.bankaraMatchSettings.last().vsRule.name} on ${opnMap1.name} & ${opnMap2.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
opnSched2.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(opnSched2.endTime, "UTC")}"
|
||||||
|
this.value =
|
||||||
|
"${opnSched2.bankaraMatchSettings.last().vsRule.name} on ${opnMap12.name} & ${opnMap22.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.timestamp = Clock.System.now()
|
||||||
|
this.footer {
|
||||||
|
this.text = "Data provided by splatoon3.ink"
|
||||||
|
this.icon = "https://fedi.splatoon3.ink/favicon.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SplatoonOnlineMode.X -> {
|
||||||
|
val xSched = Splatoon3ApiDataGrabber.getXMode(System.currentTimeMillis())
|
||||||
|
val xMaps = xSched.xMatchSetting.vsStages
|
||||||
|
val xMap1 = xMaps[0]
|
||||||
|
val xMap2 = xMaps[1]
|
||||||
|
|
||||||
|
val xSched2 = Splatoon3ApiDataGrabber.getXMode(System.currentTimeMillis() + 1000 * 60 * 60 * 2)
|
||||||
|
val xMaps2 = xSched2.xMatchSetting.vsStages
|
||||||
|
val xMap12 = xMaps2[0]
|
||||||
|
val xMap22 = xMaps2[1]
|
||||||
|
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.author {
|
||||||
|
this.name = "Current rotation for"
|
||||||
|
}
|
||||||
|
this.title = "X Mode"
|
||||||
|
this.description = "[[Open on website](https://splatoon3.ink/)]"
|
||||||
|
this.color = Color(0x0ECB93)
|
||||||
|
|
||||||
|
this.thumbnail {
|
||||||
|
this.url = "https://static.moonleay.net/img/lilJudd/x.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Current (${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
xSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(xSched.endTime, "UTC")})"
|
||||||
|
this.value = "${xSched.xMatchSetting.vsRule.name} on ${xMap1.name} & ${xMap2.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "${
|
||||||
|
TimeUtil.getTimeFromJSONTime(
|
||||||
|
xSched2.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTime(xSched2.endTime, "UTC")}"
|
||||||
|
this.value =
|
||||||
|
"${xSched2.xMatchSetting.vsRule.name} on ${xMap12.name} & ${xMap22.name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.timestamp = Clock.System.now()
|
||||||
|
this.footer {
|
||||||
|
this.text = "Data provided by splatoon3.ink"
|
||||||
|
this.icon = "https://fedi.splatoon3.ink/favicon.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SplatoonOnlineMode.SALMON_RUN -> {
|
||||||
|
val salSched = Splatoon3ApiDataGrabber.getSalmonRun(System.currentTimeMillis())
|
||||||
|
val salMap = salSched.setting.coopStage.name
|
||||||
|
val salBoss = salSched.setting.boss.name
|
||||||
|
val salWeapons = salSched.setting.weapons
|
||||||
|
|
||||||
|
val salSched2 =
|
||||||
|
Splatoon3ApiDataGrabber.getSalmonRun(System.currentTimeMillis() + 1000 * 60 * 60 * 24 * 2)
|
||||||
|
val salMap2 = salSched2.setting.coopStage.name
|
||||||
|
val salBoss2 = salSched2.setting.boss.name
|
||||||
|
val salWeapons2 = salSched2.setting.weapons
|
||||||
|
|
||||||
|
this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.author {
|
||||||
|
this.name = "Current rotation for"
|
||||||
|
}
|
||||||
|
this.title = "Salmon Run"
|
||||||
|
this.description = "[[Open on website](https://splatoon3.ink/salmonrun)]"
|
||||||
|
this.color = Color(0xEA4F03)
|
||||||
|
|
||||||
|
this.thumbnail {
|
||||||
|
this.url = "https://static.moonleay.net/img/lilJudd/grizz.png"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "Current (${
|
||||||
|
TimeUtil.getTimeFromJSONTimeLong(
|
||||||
|
salSched.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTimeLong(salSched.endTime, "UTC")})"
|
||||||
|
this.value =
|
||||||
|
"${salBoss} on ${salMap} with ${salWeapons[0].name}, ${salWeapons[1].name}, ${salWeapons[2].name} & ${salWeapons[3].name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field {
|
||||||
|
this.name = "${
|
||||||
|
TimeUtil.getTimeFromJSONTimeLong(
|
||||||
|
salSched2.startTime,
|
||||||
|
"UTC"
|
||||||
|
)
|
||||||
|
} - ${TimeUtil.getTimeFromJSONTimeLong(salSched2.endTime, "UTC")}"
|
||||||
|
this.value =
|
||||||
|
"${salBoss2} on ${salMap2} with ${salWeapons2[0].name}, ${salWeapons2[1].name}, ${salWeapons2[2].name} & ${salWeapons2[3].name}"
|
||||||
|
this.inline = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.timestamp = Clock.System.now()
|
||||||
|
this.footer {
|
||||||
|
this.text = "Data provided by splatoon3.ink"
|
||||||
|
this.icon = "https://fedi.splatoon3.ink/favicon.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,145 @@
|
||||||
|
/*
|
||||||
|
* 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.extensions
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.extensions.Extension
|
||||||
|
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
|
||||||
|
import com.kotlindiscord.kord.extensions.utils.hasPermission
|
||||||
|
import dev.kord.common.entity.Permission
|
||||||
|
import dev.kord.core.behavior.channel.createMessage
|
||||||
|
import dev.kord.rest.builder.message.actionRow
|
||||||
|
import dev.kord.rest.builder.message.embed
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import net.moonleay.liljudd.Bot
|
||||||
|
import net.moonleay.liljudd.data.database.entry.TimePlanningMessagesData
|
||||||
|
import net.moonleay.liljudd.data.database.repository.TimePlanningMessagesRepository
|
||||||
|
import net.moonleay.liljudd.util.*
|
||||||
|
import java.time.ZoneId
|
||||||
|
import java.time.ZonedDateTime
|
||||||
|
|
||||||
|
/* This extension has no proper use.
|
||||||
|
It is used in testing to test stuff, without having to wait for certain events to trigger. */
|
||||||
|
class SendPlannerExtension : Extension() {
|
||||||
|
override val name = "sendplanner"
|
||||||
|
override val allowApplicationCommandInDMs: Boolean
|
||||||
|
get() = false
|
||||||
|
|
||||||
|
override suspend fun setup() {
|
||||||
|
publicSlashCommand {
|
||||||
|
name = "sendplanner"
|
||||||
|
description = "Send the planner for the current week"
|
||||||
|
this.action {
|
||||||
|
if (!this.member!!.asMember(this.guild!!.id)
|
||||||
|
.hasPermission(Permission.Administrator)
|
||||||
|
) {
|
||||||
|
val res = this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.color = EmbedColor.ERROR.color
|
||||||
|
this.title = "401: Not Authorized"
|
||||||
|
this.description =
|
||||||
|
"You need the Administrator permission to use this command."
|
||||||
|
this.footer {
|
||||||
|
this.icon = user.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(user)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.delete()
|
||||||
|
return@action
|
||||||
|
}
|
||||||
|
val res = this.respond {
|
||||||
|
this.embed {
|
||||||
|
this.color = EmbedColor.INFO.color
|
||||||
|
this.title = "200: Success"
|
||||||
|
this.description = "Sending the planner.\n" +
|
||||||
|
"This may take a while, please be patient."
|
||||||
|
this.footer {
|
||||||
|
this.icon = user.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(user)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.delete() // Delete the response
|
||||||
|
val c = this.getChannel().asChannel()
|
||||||
|
var msgStr = ""
|
||||||
|
var then =
|
||||||
|
ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withDayOfMonth(TimeUtil.getMondayDayOfMonth())
|
||||||
|
.withHour(4)
|
||||||
|
.withMinute(0).withSecond(0)
|
||||||
|
c.createMessage {
|
||||||
|
this.embed {
|
||||||
|
this.color = EmbedColor.INFO.color
|
||||||
|
this.title = "Time Planning Feature"
|
||||||
|
this.description = "Do you have time on the following Days?"
|
||||||
|
this.footer {
|
||||||
|
this.icon = Bot.bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delay(1000)
|
||||||
|
repeat(7) {
|
||||||
|
val eb = MessageUtil.getEmbedWithTable(
|
||||||
|
EmbedColor.INFO,
|
||||||
|
"",
|
||||||
|
"${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday",
|
||||||
|
mapOf(
|
||||||
|
"Is available" to listOf(),
|
||||||
|
"May be available" to listOf(),
|
||||||
|
"Is not available" to listOf()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
val msg = c.createMessage {
|
||||||
|
this.embed {
|
||||||
|
this.color = eb.color
|
||||||
|
this.title = eb.title
|
||||||
|
this.description = eb.description
|
||||||
|
this.fields = eb.fields
|
||||||
|
this.footer {
|
||||||
|
this.icon = Bot.bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.actionRow {
|
||||||
|
this.components.addAll(EmbedUtil.getTimePlannerButtons().components)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msgStr += "${it}:${msg.id.value};"
|
||||||
|
then = then.plusDays(1).withHour(4).withMinute(0).withSecond(0)
|
||||||
|
Logger.out("Finished sending day $it/ This was manually triggered")
|
||||||
|
delay(1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the message ids
|
||||||
|
TimePlanningMessagesRepository.write(
|
||||||
|
TimePlanningMessagesData(
|
||||||
|
-1,
|
||||||
|
c.data.guildId.value?.value!!.toLong(),
|
||||||
|
c.id.value.toLong(),
|
||||||
|
(TimeUtil.getWeekStamp().toEpochSecond()),
|
||||||
|
msgStr
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Logger.out("Finished with ${c.data.guildId.value}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -16,46 +16,60 @@
|
||||||
* 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.extensions
|
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 com.kotlindiscord.kord.extensions.types.respond
|
|
||||||
import com.kotlindiscord.kord.extensions.utils.hasPermission
|
import com.kotlindiscord.kord.extensions.utils.hasPermission
|
||||||
import dev.kord.common.entity.Permission
|
import dev.kord.common.entity.Permission
|
||||||
import dev.kord.gateway.PrivilegedIntent
|
import dev.kord.rest.builder.message.embed
|
||||||
import net.moonleay.lilJudd.features.AvailabilityManager
|
import net.moonleay.liljudd.features.AvailabilityManager
|
||||||
import net.moonleay.lilJudd.util.Logger
|
import net.moonleay.liljudd.util.EmbedColor
|
||||||
|
import net.moonleay.liljudd.util.Logger
|
||||||
|
import net.moonleay.liljudd.util.MessageUtil
|
||||||
|
|
||||||
class UpdateRolesExtension : Extension() {
|
class UpdateRolesExtension : Extension() {
|
||||||
override val name = "updateroles"
|
override val name = "updateroles"
|
||||||
override val allowApplicationCommandInDMs: Boolean
|
override val allowApplicationCommandInDMs: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
|
|
||||||
@OptIn(PrivilegedIntent::class)
|
|
||||||
override suspend fun setup() {
|
override suspend fun setup() {
|
||||||
publicSlashCommand() {
|
publicSlashCommand {
|
||||||
name = "updateroles"
|
name = "updateroles"
|
||||||
description = "Update the roles of the members in the current server"
|
description = "Update the roles of the members in the current server"
|
||||||
this.action {
|
this.action {
|
||||||
if (!this.member!!.asMember(this.guild!!.id)
|
if (!this.member!!.asMember(this.guild!!.id)
|
||||||
.hasPermission(Permission.Administrator)
|
.hasPermission(Permission.Administrator)
|
||||||
) {
|
) {
|
||||||
val res = this.respond {
|
this.respond {
|
||||||
this.content = "no."
|
this.embed {
|
||||||
|
this.color = EmbedColor.ERROR.color
|
||||||
|
this.title = "401: Not Authorized"
|
||||||
|
this.description =
|
||||||
|
"You need the Administrator permission to use this command."
|
||||||
|
this.footer {
|
||||||
|
this.icon = user.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(user)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.delete()
|
|
||||||
return@action
|
return@action
|
||||||
}
|
}
|
||||||
val res = this.respond {
|
this.respond {
|
||||||
this.content = "OK."
|
this.embed {
|
||||||
|
this.color = EmbedColor.INFO.color
|
||||||
|
this.title = "200: Success"
|
||||||
|
this.description = "Updating roles.\n" +
|
||||||
|
"This may take a while, please be patient."
|
||||||
|
this.footer {
|
||||||
|
this.icon = user.asUser().avatar?.cdnUrl?.toUrl()
|
||||||
|
this.text = MessageUtil.getFooter(user)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- below here is the code of the cronjob --
|
|
||||||
Logger.out("Starting to update roles...")
|
Logger.out("Starting to update roles...")
|
||||||
|
|
||||||
AvailabilityManager.runThread()
|
AvailabilityManager.updateInChannel(this.channel.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* lilJudd
|
* lilJudd
|
||||||
* Copyright (C) 2023 moonleay
|
* Copyright (C) 2024 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
|
||||||
|
@ -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.extensions.component
|
package net.moonleay.liljudd.extensions.component
|
||||||
|
|
||||||
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.ChoiceEnum
|
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.ChoiceEnum
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.extensions.component
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.commands.application.slash.converters.ChoiceEnum
|
||||||
|
|
||||||
|
enum class MatchTypes(override val readableName: String) : ChoiceEnum {
|
||||||
|
TOURNEY("Tourney Match"),
|
||||||
|
LADDER("Ladder Match"),
|
||||||
|
SCRIM("Scrim"),
|
||||||
|
LAN("LAN Match"),
|
||||||
|
OPEN("Anarchy Open");
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* 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.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"),
|
||||||
|
}
|
|
@ -0,0 +1,256 @@
|
||||||
|
/*
|
||||||
|
* 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.features
|
||||||
|
|
||||||
|
import com.kotlindiscord.kord.extensions.utils.isNullOrBot
|
||||||
|
import dev.inmo.krontab.buildSchedule
|
||||||
|
import dev.inmo.krontab.doInfinity
|
||||||
|
import dev.kord.common.entity.Snowflake
|
||||||
|
import dev.kord.core.behavior.UserBehavior
|
||||||
|
import dev.kord.core.behavior.createRole
|
||||||
|
import dev.kord.core.behavior.requestMembers
|
||||||
|
import dev.kord.core.entity.channel.Channel
|
||||||
|
import dev.kord.core.entity.channel.MessageChannel
|
||||||
|
import dev.kord.gateway.PrivilegedIntent
|
||||||
|
import dev.kord.rest.builder.message.EmbedBuilder
|
||||||
|
import net.moonleay.liljudd.Bot
|
||||||
|
import net.moonleay.liljudd.data.database.entry.PlanningNotifierRolesData
|
||||||
|
import net.moonleay.liljudd.data.database.entry.TimePlanningMessagesData
|
||||||
|
import net.moonleay.liljudd.data.database.repository.PlanningNotifierRolesRepository
|
||||||
|
import net.moonleay.liljudd.data.database.repository.TimePlanningMessagesRepository
|
||||||
|
import net.moonleay.liljudd.extensions.FeatureManageExtension
|
||||||
|
import net.moonleay.liljudd.features.component.FeatureEnum
|
||||||
|
import net.moonleay.liljudd.features.component.IFeature
|
||||||
|
import net.moonleay.liljudd.util.*
|
||||||
|
import java.time.ZonedDateTime
|
||||||
|
|
||||||
|
object AvailabilityManager : IFeature {
|
||||||
|
|
||||||
|
// This runs during the cronjob.
|
||||||
|
suspend fun runThread() {
|
||||||
|
Logger.out("Updating match roles")
|
||||||
|
|
||||||
|
// ChannelID, Data
|
||||||
|
val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond())
|
||||||
|
.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) {
|
||||||
|
val snf = Snowflake(id) // snf = Snowflake
|
||||||
|
val data = messages[id]!! // this is the data of the table
|
||||||
|
if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) {
|
||||||
|
// This channel does not exist anymore.
|
||||||
|
Logger.out("Warning: Channel ${data.channelID} does not exist anymore. Skipping.")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val roleData = targetedRoles[data.channelID] // Get the role data
|
||||||
|
if (roleData == null) {
|
||||||
|
Logger.out("Role for channel ${data.channelID} does not exist")
|
||||||
|
continue // this took way to long to find out that this was the issue
|
||||||
|
}
|
||||||
|
this.updateInChannel(snf, data, roleData)
|
||||||
|
}
|
||||||
|
Logger.out("Finished updating roles")
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun updateInChannel(snf: Snowflake) {
|
||||||
|
val stamp = TimeUtil.getWeekStamp().toEpochSecond()
|
||||||
|
Logger.out("Weekstamp: $stamp")
|
||||||
|
val messageData = TimePlanningMessagesRepository.getWeekInChannel(
|
||||||
|
stamp,
|
||||||
|
snf.value.toLong()
|
||||||
|
)
|
||||||
|
if (messageData == null) {
|
||||||
|
Logger.out("Could not find data for channel ${snf.value}")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong())
|
||||||
|
if (roleData == null) {
|
||||||
|
Logger.out("Role for channel ${messageData.channelID} does not exist")
|
||||||
|
return // this took way to long to find out that this was the issue
|
||||||
|
}
|
||||||
|
updateInChannel(snf, messageData, roleData)
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(PrivilegedIntent::class)
|
||||||
|
suspend fun updateInChannel(snf: Snowflake, tpmd: TimePlanningMessagesData, pnrd: PlanningNotifierRolesData) {
|
||||||
|
if (Bot.bot.kordRef.getChannel(snf) == null)
|
||||||
|
return // This channel does not exist anymore.
|
||||||
|
val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(snf)!! // Get the channel as MessageChannel
|
||||||
|
val weekday = ZonedDateTime.now().dayOfWeek // The current week day
|
||||||
|
val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() // The current week time stamp
|
||||||
|
Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.")
|
||||||
|
val g = Bot.bot.kordRef.getGuild(Snowflake(tpmd.serverID))
|
||||||
|
// Get all members with the role
|
||||||
|
val mce = g.requestMembers {
|
||||||
|
this.requestAllMembers()
|
||||||
|
}
|
||||||
|
mce.collect { memberchunkevent ->
|
||||||
|
memberchunkevent.members.forEach {
|
||||||
|
if (!it.isNullOrBot()) { // Check if the member is a bot
|
||||||
|
Logger.out("Checking member ${it.id.value} (${it.username})")
|
||||||
|
if (it.roleIds.contains(Snowflake(pnrd.hasTimeRoleID))) {
|
||||||
|
it.removeRole(Snowflake(pnrd.hasTimeRoleID))
|
||||||
|
Logger.out("Removed role from ${it.username}") // Removed the role
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// I cant use continue here, because it does not work with .forEach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.out("Got through all members")
|
||||||
|
// This stores the ids of the messages.
|
||||||
|
// The format is weekdaNR:ID
|
||||||
|
// The last entry (nr 8) is empty, so we can ignore it
|
||||||
|
val messageIdSplit = tpmd.messageIDs.split(";").subList(0, 7)
|
||||||
|
for (mid in messageIdSplit) {
|
||||||
|
Logger.out("Checking id $mid")
|
||||||
|
if (!mid.startsWith((TimeUtil.getDayOfMonthInt(weekday) - 1).toString(), true))
|
||||||
|
continue// This is not the right message, check the next one
|
||||||
|
val idFiltered = mid.split(":")[1] // This is the target message id
|
||||||
|
val message = c.getMessageOrNull(Snowflake(idFiltered)) // Get the message from the channel
|
||||||
|
if (message == null) {
|
||||||
|
Logger.out("Could not find message.")
|
||||||
|
return // This message does not exist anymore. Nothing we can do about that.
|
||||||
|
}
|
||||||
|
if (message.data.embeds.isEmpty()) {
|
||||||
|
Logger.out("There are no embeds.")
|
||||||
|
return // There are no embeds or there are not enough embeds
|
||||||
|
}
|
||||||
|
val targets = EmbedUtil.getAllUsersInTheFirstXTables(2, message.embeds[0])
|
||||||
|
for (tid in targets) {
|
||||||
|
Logger.out("Checking id $tid")
|
||||||
|
if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverID))!!
|
||||||
|
.getMemberOrNull(Snowflake(tid)) == null
|
||||||
|
)
|
||||||
|
continue// This member does not exist anymore.
|
||||||
|
val member = Bot.bot.kordRef.getGuild(Snowflake(tpmd.serverID))
|
||||||
|
.getMember(Snowflake(tid)) // Get the member
|
||||||
|
if (member.roleIds.contains(Snowflake(pnrd.hasTimeRoleID)))
|
||||||
|
continue // This member already has the role
|
||||||
|
member.addRole(Snowflake(pnrd.hasTimeRoleID)) // Add the role
|
||||||
|
Logger.out("Added role to ${member.username}")
|
||||||
|
}
|
||||||
|
Logger.out("Done with message. Moving on...")
|
||||||
|
// We found the right message. We don't need to check the others.
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override val feat: FeatureEnum
|
||||||
|
get() = FeatureEnum.PLANNINGROLES
|
||||||
|
|
||||||
|
// Register the cronjob to run at 1AM UTC every day
|
||||||
|
override suspend fun registerThread() {
|
||||||
|
Logger.out("Registering daily planning message role update coroutine")
|
||||||
|
val scheduler = buildSchedule("0 0 2 * * *") // 0 0 4 * * * 0o 1w // 0o is UTC
|
||||||
|
scheduler.doInfinity {
|
||||||
|
this.runThread()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun enable(
|
||||||
|
u: UserBehavior,
|
||||||
|
gID: Long,
|
||||||
|
cID: Long,
|
||||||
|
ch: Channel,
|
||||||
|
args: FeatureManageExtension.FeatureManagerArgs
|
||||||
|
): EmbedBuilder {
|
||||||
|
val alreadyExists = PlanningNotifierRolesRepository.existsInChannel(cID)
|
||||||
|
// Check if the channel and guild already exist in the db
|
||||||
|
if (!alreadyExists) {
|
||||||
|
// Create the roles in Discord
|
||||||
|
val hasTimeRole = Bot.bot.kordRef.getGuild(Snowflake(gID)).createRole {
|
||||||
|
this.name = "available [${ch.data.name.value}]"
|
||||||
|
this.mentionable = true
|
||||||
|
}
|
||||||
|
val htr = hasTimeRole.id.value.toLong()
|
||||||
|
|
||||||
|
val wantsNotifsRole = Bot.bot.kordRef.getGuild(Snowflake(gID)).createRole {
|
||||||
|
this.name = "notifications [${ch.data.name.value}]"
|
||||||
|
this.mentionable = true
|
||||||
|
}
|
||||||
|
val wnr = wantsNotifsRole.id.value.toLong()
|
||||||
|
|
||||||
|
// Save the role ids to db
|
||||||
|
PlanningNotifierRolesRepository.write(
|
||||||
|
PlanningNotifierRolesData(
|
||||||
|
id = -1,
|
||||||
|
serverID = gID,
|
||||||
|
channelID = cID,
|
||||||
|
hasTimeRoleID = htr,
|
||||||
|
wantsToBeNotifiedID = wnr
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return MessageUtil.getEmbed(
|
||||||
|
EmbedColor.SUCCESS,
|
||||||
|
"200: Success",
|
||||||
|
"The feature was enabled in channel ${args.channel.data.name.value} with roles ${hasTimeRole.mention} & ${wantsNotifsRole.mention}.",
|
||||||
|
u.asUser().username + "#" + u.asUser().discriminator
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// They exist, do not add them
|
||||||
|
return MessageUtil.getEmbed(
|
||||||
|
EmbedColor.ERROR,
|
||||||
|
"403: Forbidden",
|
||||||
|
"The feature is already enabled in this channel.",
|
||||||
|
u.asUser().username + "#" + u.asUser().discriminator
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun disable(
|
||||||
|
u: UserBehavior,
|
||||||
|
gID: Long,
|
||||||
|
cID: Long,
|
||||||
|
ch: Channel,
|
||||||
|
args: FeatureManageExtension.FeatureManagerArgs
|
||||||
|
): EmbedBuilder {
|
||||||
|
// Check if entry exists in db
|
||||||
|
if (PlanningNotifierRolesRepository.existsInChannelFromSever(cID, gID)) {
|
||||||
|
val entry = PlanningNotifierRolesRepository.getForChannelInServer(cID, gID)!!
|
||||||
|
// delete all entries for this guild and channel combo
|
||||||
|
Bot.bot.kordRef.getGuild(Snowflake(gID))
|
||||||
|
.getRoleOrNull(Snowflake(entry.hasTimeRoleID))?.delete()
|
||||||
|
Bot.bot.kordRef.getGuild(Snowflake(gID))
|
||||||
|
.getRoleOrNull(Snowflake(entry.wantsToBeNotifiedID))?.delete()
|
||||||
|
|
||||||
|
// delete all found entries
|
||||||
|
PlanningNotifierRolesRepository.delete(entry.id)
|
||||||
|
return MessageUtil.getEmbed(
|
||||||
|
EmbedColor.SUCCESS,
|
||||||
|
"200: Success",
|
||||||
|
"The feature was disabled.",
|
||||||
|
u.asUser().username + "#" + u.asUser().discriminator
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// not in db, do nothing
|
||||||
|
return MessageUtil.getEmbed(
|
||||||
|
EmbedColor.ERROR,
|
||||||
|
"403: Forbidden",
|
||||||
|
"The feature is already disabled in this channel.",
|
||||||
|
u.asUser().username + "#" + u.asUser().discriminator
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue