6 Commits
1.0.0 ... 1.0.3

Author SHA1 Message Date
JinU Choi
1d23ac5121 Merge pull request #10 from dalbodeule/develop
BUG FIX: fix #9
2024-07-29 16:01:30 +09:00
dalbodeule
8f8d2f895a BUG FIX: fix #9 2024-07-29 15:58:50 +09:00
JinU Choi
47b4b8252f Merge pull request #8 from dalbodeule/develop
BUG FIX: daily counter with update updated_at column
2024-07-27 21:09:48 +09:00
dalbodeule
64880318e8 BUG FIX: daily counter with update updated_at column 2024-07-27 21:06:56 +09:00
JinU Choi
cec07f9859 Merge pull request #7 from dalbodeule/develop
add guild update, update document, update version to 1.0.1
2024-07-27 11:38:26 +09:00
dalbodeule
18ee27e567 add guild update, update document, update version to 1.0.1 2024-07-27 11:36:17 +09:00
8 changed files with 52 additions and 25 deletions

View File

@@ -21,13 +21,27 @@
- [x] /register chzzk_id: \[치지직 고유ID]
- [x] /alert channel: \[디스코드 Channel ID] content: \[알림 내용]
- [x] /add label: \[명령어] content: \[내용]
- [ ] /list
- [x] /update label: \[명령어] content: \[내용]
- [x] /delete label: \[명령어]
### 매니저 명령어 (on Discord)
- [x] /addmanager user: \[Discord user]
- [x] /listmanager
- [x] /removemanager user: \[Discord user]
### 관리 명령어 (on Chzzk chat)
- [x] !명령어추가 \[명령어] \[내용]
- [x] !명령어수정 \[명령어] \[내용]
- [x] !명령어삭제 \[명령어]
### Envs
- DISCORD_TOKEN
- DB_URL
- DB_USER
- DB_PASS
- RUN_AGENT = `false`
- NID_AUT
- NID_SES
### 사용 예시
- 팔로우
- `/add label: !팔로우 content: <name>님은 오늘로 <following>일째 팔로우네요!`

View File

@@ -1,6 +1,6 @@
kotlin.code.style=official
group = space.mori
version = 1.0.0
version = 1.0.3
org.gradle.jvmargs=-Dfile.encoding=UTF-8
org.gradle.console=plain

View File

@@ -4,6 +4,7 @@ import net.dv8tion.jda.api.JDA
import net.dv8tion.jda.api.JDABuilder
import net.dv8tion.jda.api.entities.Activity
import net.dv8tion.jda.api.entities.Guild
import net.dv8tion.jda.api.events.guild.GuildJoinEvent
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter
@@ -40,6 +41,26 @@ class Discord: ListenerAdapter() {
event.member?.let { ManagerService.deleteManager(event.guild.idLong, it.idLong) }
}
override fun onGuildJoin(event: GuildJoinEvent) {
commandUpdate(event.guild)
}
private fun commandUpdate(guild: Guild) {
guild.updateCommands().addCommands(* commands.map { it.command}.toTypedArray())
.onSuccess {
logger.info("Command update on guild success!")
}
.queue()
}
private fun commandUpdate(bot: JDA) {
bot.updateCommands().addCommands(* commands.map { it.command}.toTypedArray())
.onSuccess {
logger.info("Command update bot boot success!")
}
.queue()
}
internal fun enable() {
val thread = Thread {
try {
@@ -50,18 +71,9 @@ class Discord: ListenerAdapter() {
guild = bot.getGuildById(dotenv["GUILD_ID"])
bot.updateCommands()
.addCommands(* commands.map { it.command }.toTypedArray())
.onSuccess {
logger.info("Command update success!")
logger.debug("Command list: ${commands.joinToString("/ ") { it.name }}")
}
.queue()
if (guild == null) {
logger.info("No guild found!")
this.disable()
commandUpdate(bot)
bot.guilds.forEach {
commandUpdate(it)
}
} catch (e: Exception) {
logger.info("Could not enable Discord!")

View File

@@ -38,12 +38,12 @@ object AddCommand : CommandInterface {
return
}
if (user == null) {
user = manager!!.user
if (manager != 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 }) {
event.hook.sendMessage("$label 명령어는 이미 있습니다! 업데이트 명령어를 써주세요.").queue()
return

View File

@@ -30,12 +30,12 @@ object AlertCommand : CommandInterface {
return
}
if (user == null) {
user = manager!!.user
if (manager != 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 {
val newUser = UserService.updateLiveAlert(user.id.value, channel?.guild?.idLong ?: 0L, channel?.idLong ?: 0L, content ?: "")

View File

@@ -34,12 +34,12 @@ object RemoveCommand : CommandInterface {
return
}
if (user == null) {
user = manager!!.user
if (manager != 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 {
CommandService.removeCommand(user, label)

View File

@@ -38,12 +38,12 @@ object UpdateCommand : CommandInterface {
return
}
if (user == null) {
user = manager!!.user
if (manager != 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 {
CommandService.updateCommand(user, label, content, failContent ?: "")

View File

@@ -96,6 +96,7 @@ object CounterService {
Pair(counter.value, false)
else {
counter.value += increment
counter.updatedAt = today
Pair(counter.value, true)
}
}