Merge pull request #6 from dalbodeule/develop

v1.0.0

- add managers (in discord)
- manager can add/remove/modify commands
- update some packages.
This commit is contained in:
JinU Choi 2024-07-27 10:23:50 +09:00 committed by GitHub
commit 34ec0f29ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 58 additions and 36 deletions

View File

@ -1,23 +1,10 @@
# Stage 1: Build the JAR file # Use a base image with JDK 21 for the final image
FROM gradle:jdk21 as build
WORKDIR /app
# Copy the Gradle files and source code
COPY build.gradle.kts settings.gradle.kts gradlew gradle.properties ./
COPY gradle gradle
COPY src src
# Build the project using Gradle
RUN ./gradlew build
# Stage 2: Run the JAR file using JDK 21
FROM openjdk:21-jdk FROM openjdk:21-jdk
WORKDIR /app WORKDIR /app
# Copy the JAR file from the build stage # Copy the JAR file from the TeamCity build artifacts
COPY --from=build /app/build/libs/*.jar app.jar COPY build/libs/chzzk_bot-*.jar app.jar
# Set the entry point # Set the entry point
ENTRYPOINT ["java", "-jar", "app.jar"] ENTRYPOINT ["java", "-jar", "app.jar"]

View File

@ -29,22 +29,23 @@ repositories {
dependencies { dependencies {
// https://mvnrepository.com/artifact/net.dv8tion/JDA // https://mvnrepository.com/artifact/net.dv8tion/JDA
implementation("net.dv8tion:JDA:5.0.0-beta.24") { implementation("net.dv8tion:JDA:5.0.1") {
exclude(module = "opus-java") exclude(module = "opus-java")
} }
// https://mvnrepository.com/artifact/io.github.R2turnTrue/chzzk4j // https://mvnrepository.com/artifact/io.github.R2turnTrue/chzzk4j
implementation("io.github.R2turnTrue:chzzk4j:0.0.8") implementation("io.github.R2turnTrue:chzzk4j:0.0.9")
implementation("ch.qos.logback:logback-classic:1.4.14") // https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
implementation("ch.qos.logback:logback-classic:1.5.6")
// https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed-core // https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed-core
implementation("org.jetbrains.exposed:exposed-core:0.51.1") implementation("org.jetbrains.exposed:exposed-core:0.52.0")
// https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed-dao // https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed-dao
implementation("org.jetbrains.exposed:exposed-dao:0.51.1") implementation("org.jetbrains.exposed:exposed-dao:0.52.0")
// https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed-jdbc // https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed-jdbc
implementation("org.jetbrains.exposed:exposed-jdbc:0.51.1") implementation("org.jetbrains.exposed:exposed-jdbc:0.52.0")
// https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed-kotlin-datetime // https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed-kotlin-datetime
implementation("org.jetbrains.exposed:exposed-java-time:0.51.1") implementation("org.jetbrains.exposed:exposed-java-time:0.52.0")
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP // https://mvnrepository.com/artifact/com.zaxxer/HikariCP
implementation("com.zaxxer:HikariCP:5.1.0") implementation("com.zaxxer:HikariCP:5.1.0")
@ -54,11 +55,13 @@ dependencies {
// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-reflect // https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-reflect
implementation("org.jetbrains.kotlin:kotlin-reflect:2.0.0") implementation("org.jetbrains.kotlin:kotlin-reflect:2.0.0")
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation("com.google.code.gson:gson:2.11.0") implementation("com.google.code.gson:gson:2.11.0")
// https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client // https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client
implementation("org.mariadb.jdbc:mariadb-java-client:3.4.0") implementation("org.mariadb.jdbc:mariadb-java-client:3.4.1")
// https://mvnrepository.com/artifact/io.github.cdimascio/dotenv-kotlin
implementation("io.github.cdimascio:dotenv-kotlin:6.4.1") implementation("io.github.cdimascio:dotenv-kotlin:6.4.1")
kotlin("stdlib") kotlin("stdlib")

View File

@ -10,6 +10,7 @@ import space.mori.chzzk_bot.chzzk.ChzzkHandler
import space.mori.chzzk_bot.chzzk.Connector import space.mori.chzzk_bot.chzzk.Connector
import space.mori.chzzk_bot.discord.CommandInterface import space.mori.chzzk_bot.discord.CommandInterface
import space.mori.chzzk_bot.services.CommandService import space.mori.chzzk_bot.services.CommandService
import space.mori.chzzk_bot.services.ManagerService
import space.mori.chzzk_bot.services.UserService import space.mori.chzzk_bot.services.UserService
object AddCommand : CommandInterface { object AddCommand : CommandInterface {
@ -30,12 +31,18 @@ object AddCommand : CommandInterface {
return return
} }
val user = UserService.getUser(event.user.idLong) var user = UserService.getUser(event.user.idLong)
if(user == null) { val manager = event.guild?.idLong?.let { ManagerService.getUser(it, event.user.idLong) }
event.hook.sendMessage("치지직 계정을 찾을 수 없습니다.").queue() if(user == null && manager == null) {
event.hook.sendMessage("당신은 이 명령어를 사용할 수 없습니다.").queue()
return return
} }
if (user == null) {
user = manager!!.user
ManagerService.updateManager(user, event.user.idLong, event.user.effectiveName)
}
val commands = CommandService.getCommands(user) val commands = CommandService.getCommands(user)
if (commands.any { it.command == label }) { if (commands.any { it.command == label }) {
event.hook.sendMessage("$label 명령어는 이미 있습니다! 업데이트 명령어를 써주세요.").queue() event.hook.sendMessage("$label 명령어는 이미 있습니다! 업데이트 명령어를 써주세요.").queue()

View File

@ -36,6 +36,8 @@ object AddManagerCommand : CommandInterface {
try { try {
ManagerService.saveManager(user, manager.idLong, manager.effectiveName) ManagerService.saveManager(user, manager.idLong, manager.effectiveName)
if(user.liveAlertGuild == null)
UserService.updateLiveAlert(user.id.value, event.guild!!.idLong, event.channelIdLong, "")
event.hook.sendMessage("등록이 완료되었습니다. ${manager.effectiveName}").queue() event.hook.sendMessage("등록이 완료되었습니다. ${manager.effectiveName}").queue()
} catch (e: Exception) { } catch (e: Exception) {
event.hook.sendMessage("에러가 발생했습니다.").queue() event.hook.sendMessage("에러가 발생했습니다.").queue()

View File

@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory
import space.mori.chzzk_bot.chzzk.ChzzkHandler import space.mori.chzzk_bot.chzzk.ChzzkHandler
import space.mori.chzzk_bot.chzzk.Connector import space.mori.chzzk_bot.chzzk.Connector
import space.mori.chzzk_bot.discord.CommandInterface import space.mori.chzzk_bot.discord.CommandInterface
import space.mori.chzzk_bot.services.ManagerService
import space.mori.chzzk_bot.services.UserService import space.mori.chzzk_bot.services.UserService
object AlertCommand : CommandInterface { object AlertCommand : CommandInterface {
@ -22,12 +23,18 @@ object AlertCommand : CommandInterface {
val channel = event.getOption("channel")?.asChannel val channel = event.getOption("channel")?.asChannel
val content = event.getOption("content")?.asString val content = event.getOption("content")?.asString
val user = UserService.getUser(event.user.idLong) var user = UserService.getUser(event.user.idLong)
if(user == null) { val manager = event.guild?.idLong?.let { ManagerService.getUser(it, event.user.idLong) }
event.hook.sendMessage("치지직 계정을 찾을 수 없습니다.").queue() if(user == null && manager == null) {
event.hook.sendMessage("당신은 이 명령어를 사용할 수 없습니다.").queue()
return return
} }
if (user == null) {
user = manager!!.user
ManagerService.updateManager(user, event.user.idLong, event.user.effectiveName)
}
val chzzkChannel = Connector.getChannel(user.token) val chzzkChannel = Connector.getChannel(user.token)
try { try {

View File

@ -10,6 +10,7 @@ import space.mori.chzzk_bot.chzzk.ChzzkHandler
import space.mori.chzzk_bot.chzzk.Connector import space.mori.chzzk_bot.chzzk.Connector
import space.mori.chzzk_bot.discord.CommandInterface import space.mori.chzzk_bot.discord.CommandInterface
import space.mori.chzzk_bot.services.CommandService import space.mori.chzzk_bot.services.CommandService
import space.mori.chzzk_bot.services.ManagerService
import space.mori.chzzk_bot.services.UserService import space.mori.chzzk_bot.services.UserService
object RemoveCommand : CommandInterface { object RemoveCommand : CommandInterface {
@ -26,11 +27,18 @@ object RemoveCommand : CommandInterface {
return return
} }
val user = UserService.getUser(event.user.idLong) var user = UserService.getUser(event.user.idLong)
if(user == null) { val manager = event.guild?.idLong?.let { ManagerService.getUser(it, event.user.idLong) }
event.hook.sendMessage("치지직 계정을 찾을 수 없습니다.").queue() if(user == null && manager == null) {
event.hook.sendMessage("당신은 이 명령어를 사용할 수 없습니다.").queue()
return return
} }
if (user == null) {
user = manager!!.user
ManagerService.updateManager(user, event.user.idLong, event.user.effectiveName)
}
val chzzkChannel = Connector.getChannel(user.token) val chzzkChannel = Connector.getChannel(user.token)
try { try {

View File

@ -10,6 +10,7 @@ import space.mori.chzzk_bot.chzzk.ChzzkHandler
import space.mori.chzzk_bot.chzzk.Connector import space.mori.chzzk_bot.chzzk.Connector
import space.mori.chzzk_bot.discord.CommandInterface import space.mori.chzzk_bot.discord.CommandInterface
import space.mori.chzzk_bot.services.CommandService import space.mori.chzzk_bot.services.CommandService
import space.mori.chzzk_bot.services.ManagerService
import space.mori.chzzk_bot.services.UserService import space.mori.chzzk_bot.services.UserService
object UpdateCommand : CommandInterface { object UpdateCommand : CommandInterface {
@ -30,11 +31,18 @@ object UpdateCommand : CommandInterface {
return return
} }
val user = UserService.getUser(event.user.idLong) var user = UserService.getUser(event.user.idLong)
if(user == null) { val manager = event.guild?.idLong?.let { ManagerService.getUser(it, event.user.idLong) }
event.hook.sendMessage("치지직 계정을 찾을 수 없습니다.").queue() if(user == null && manager == null) {
event.hook.sendMessage("당신은 이 명령어를 사용할 수 없습니다.").queue()
return return
} }
if (user == null) {
user = manager!!.user
ManagerService.updateManager(user, event.user.idLong, event.user.effectiveName)
}
val chzzkChannel = Connector.getChannel(user.token) val chzzkChannel = Connector.getChannel(user.token)
try { try {