Compare commits

..

6 Commits

Author SHA1 Message Date
dalbodeule
c86f0b2ab3
[hotfix] role hotfix 2025-06-08 16:20:27 +09:00
dalbodeule
27cfbd9087
[hotfix] category command announcement added. 2025-06-08 16:16:17 +09:00
dalbodeule
9ce07a025a
[hotfix] category command announcement added. 2025-06-08 16:15:36 +09:00
dalbodeule
073b50b9cd
[hotfix] category command some fixed. 2025-06-08 16:11:11 +09:00
dalbodeule
f37dd2c59a
[hotfix] add category command. 2025-06-08 16:02:22 +09:00
dalbodeule
864ba3748d
[hotfix] readme and some url changed. 2025-06-08 15:50:49 +09:00
2 changed files with 46 additions and 51 deletions

View File

@ -1,6 +1,6 @@
# nabot_chzzk_bot
# chibot_chzzk_bot
[![Discord](https://img.shields.io/discord/1250093195870867577)](https://discord.gg/up8ANZegmy)   [![Build Status](https://teamcity.mori.space/app/rest/builds/buildType:NabotChzzkBot_Build/statusIcon)](https://teamcity.mori.space/project/NabotChzzkBot)   [![Docker Image Version](https://img.shields.io/docker/v/dalbodeule/chzzkbot)](https://hub.docker.com/repository/docker/dalbodeule/chzzkbot/general)
[![Discord](https://img.shields.io/discord/1250093195870867577)](https://discord.gg/up8ANZegmy)   [![Build Status](https://teamcity.mori.space/app/rest/builds/buildType:NabotChzzkBot_Build/statusIcon)](https://teamcity.mori.space/project/NabotChzzkBot)
## Chzzk Chatbot with [JDA5](https://github.com/discord-jda/JDA), [chzzk4j](https://github.com/R2turnTrue/chzzk4j)
@ -17,17 +17,6 @@
- [x] \<daily_counter:counter_name>
- [x] \<days:yyyy-mm-dd>
### 관리 명령어 (on Discord)
- [x] /hook token: \[디스코드 연동 페이지에서 받은 Token]
- [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] !명령어수정 \[명령어] \[내용]
@ -42,32 +31,6 @@
- [ ] !노래삭제 \[번호]
- [ ] !노래설정 \[내용] \[켜기/끄기]
### Envs
- DISCORD_TOKEN
- DB_URL
- DB_USER
- DB_PASS
- RUN_AGENT = `false`
- NID_AUT
- NID_SES
### 사용 예시
- 팔로우
- `/add label: !팔로우 content: <name>님은 오늘로 <following>일째 팔로우네요!`
- 출첵
- `/add label: !출첵 content: <name>님의 <daily_counter:attendance>번째 출석! fail_content: <name>님은 오늘 이미 출석했어요! <daily_counter:attendance>번 했네요?`
- `/add label: ? content: <name>님이 <counter:hook>개째 갈고리 수집`
- ㄱㅇㅇ
- `/add label: ㄱㅇㅇ content: <counter:cute>번째 ㄱㅇㅇ`
- `/add label: ㄱㅇㅇ content: 나누 귀여움 +<counter:cute>`
- 풉
- `/add label: 풉 content: <counter:poop>번째 비웃음?`
- `/add label: 풉키풉키 content: <counter:poop>번째 비웃음?`
- 바보
- `/add label: 바보 content: 나 바보 아니다?`
- `/add label: 바보 content: <counter:fool> 번째 바보? 나 바보 아니다?`
- 첫방송
- `/add label: 첫방송 content: 24년 7월 23일부터 <days:2024-07-23>일 째 방송중!`
## 사용 기술스택
- [Exposed](https://github.com/JetBrains/Exposed)

View File

@ -11,10 +11,8 @@ import space.mori.chzzk_bot.common.services.*
import space.mori.chzzk_bot.common.utils.getFollowDate
import space.mori.chzzk_bot.common.utils.getUptime
import space.mori.chzzk_bot.common.utils.getYoutubeVideo
import xyz.r2turntrue.chzzk4j.chat.ChatMessage
import xyz.r2turntrue.chzzk4j.chat.ChzzkChat
import xyz.r2turntrue.chzzk4j.session.ChzzkUserSession
import xyz.r2turntrue.chzzk4j.session.message.SessionChatMessage
import xyz.r2turntrue.chzzk4j.types.channel.live.ChzzkLiveSettings
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
@ -62,6 +60,7 @@ class MessageHandler(
"!신청곡" to this::songAddCommand,
"!노래목록" to this::songListCommand,
"!노래시작" to this::songStartCommand,
"!카테고리" to this::categoryChangeCommand,
)
manageCommands.forEach { (commandName, command) ->
@ -84,11 +83,11 @@ class MessageHandler(
}
private fun commandListCommand(msg: SessionChatMessage, user: User) {
handler.sendChat("리스트는 여기입니다. https://nabot.mori.space/commands/${user.token}")
handler.sendChat("리스트는 여기입니다. https://chibot.mori.space/commands/${user.token}")
}
private fun manageAddCommand(msg: SessionChatMessage, user: User) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
handler.sendChat("매니저만 명령어를 추가할 수 있습니다.")
return
}
@ -109,7 +108,7 @@ class MessageHandler(
}
private fun manageUpdateCommand(msg: SessionChatMessage, user: User) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
handler.sendChat("매니저만 명령어를 추가할 수 있습니다.")
return
}
@ -131,7 +130,7 @@ class MessageHandler(
}
private fun manageRemoveCommand(msg: SessionChatMessage, user: User) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
handler.sendChat("매니저만 명령어를 삭제할 수 있습니다.")
return
}
@ -148,7 +147,7 @@ class MessageHandler(
}
private fun timerCommand(msg: SessionChatMessage, user: User) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
handler.sendChat("매니저만 이 명령어를 사용할 수 있습니다.")
return
}
@ -227,7 +226,7 @@ class MessageHandler(
val config = SongConfigService.getConfig(user)
if(config.streamerOnly && msg.profile.badges.none { it.imageUrl.contains("manager") }) {
if(config.streamerOnly && msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
handler.sendChat("매니저만 이 명령어를 사용할 수 있습니다.")
return
}
@ -294,11 +293,11 @@ class MessageHandler(
return
}
handler.sendChat("리스트는 여기입니다. https://nabot.mori.space/songs/${user.token}")
handler.sendChat("리스트는 여기입니다. https://chibot.mori.space/songs/${user.token}")
}
private fun songStartCommand(msg: SessionChatMessage, user: User) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
handler.sendChat("매니저만 이 명령어를 사용할 수 있습니다.")
return
}
@ -307,7 +306,7 @@ class MessageHandler(
if(user.discord != null) {
bot.retrieveUserById(user.discord!!).queue { discordUser ->
discordUser?.openPrivateChannel()?.queue { channel ->
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
channel.sendMessage("여기로 접속해주세요! ||https://chibot.mori.space/songlist||.")
.queue()
}
}
@ -316,6 +315,39 @@ class MessageHandler(
}
}
private fun categoryChangeCommand(msg: SessionChatMessage, user: User) {
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
handler.sendChat("매니저만 이 명령어를 사용할 수 있습니다.")
return
}
val parts = msg.content.split(" ", limit = 2)
if(parts.size <= 1) {
handler.sendChat("카테고리가 없습니다.")
return
}
val category = parts[1].let {
return@let when(it) {
"저챗", "토크", "JustChatting", "Just Chatting", "" -> "talk"
else -> it
}
}
handler.sendChat("$category 카테고리로 수정을 시도해볼게요!")
handler.client.searchCategories(category).handle { result, _ ->
if(result.size == 0) {
handler.sendChat("$category 카테고리는 없습니다.")
return@handle
}
val settings = ChzzkLiveSettings()
settings.category = result.first {
it.categoryValue == category
} ?: result[0]
handler.client.modifyLiveSettings(settings)
handler.sendChat("$category 로 수정했어요!")
}
}
internal fun handle(msg: SessionChatMessage, user: User) {
if(msg.senderChannelId == ChzzkHandler.botUid) return