mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
Compare commits
No commits in common. "c86f0b2ab36d7d0d20afba64cc3ecf555a1e1f1d" and "593b98b7fb055bf794b5dd44222093be9c9bdef2" have entirely different histories.
c86f0b2ab3
...
593b98b7fb
41
README.md
41
README.md
@ -1,6 +1,6 @@
|
||||
# chibot_chzzk_bot
|
||||
# nabot_chzzk_bot
|
||||
|
||||
[](https://discord.gg/up8ANZegmy) [](https://teamcity.mori.space/project/NabotChzzkBot)
|
||||
[](https://discord.gg/up8ANZegmy) [](https://teamcity.mori.space/project/NabotChzzkBot) [](https://hub.docker.com/repository/docker/dalbodeule/chzzkbot/general)
|
||||
|
||||
## Chzzk Chatbot with [JDA5](https://github.com/discord-jda/JDA), [chzzk4j](https://github.com/R2turnTrue/chzzk4j)
|
||||
|
||||
@ -17,6 +17,17 @@
|
||||
- [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] !명령어수정 \[명령어] \[내용]
|
||||
@ -31,6 +42,32 @@
|
||||
- [ ] !노래삭제 \[번호]
|
||||
- [ ] !노래설정 \[내용] \[켜기/끄기]
|
||||
|
||||
### 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)
|
||||
|
@ -11,8 +11,10 @@ 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
|
||||
@ -60,7 +62,6 @@ class MessageHandler(
|
||||
"!신청곡" to this::songAddCommand,
|
||||
"!노래목록" to this::songListCommand,
|
||||
"!노래시작" to this::songStartCommand,
|
||||
"!카테고리" to this::categoryChangeCommand,
|
||||
)
|
||||
|
||||
manageCommands.forEach { (commandName, command) ->
|
||||
@ -83,11 +84,11 @@ class MessageHandler(
|
||||
}
|
||||
|
||||
private fun commandListCommand(msg: SessionChatMessage, user: User) {
|
||||
handler.sendChat("리스트는 여기입니다. https://chibot.mori.space/commands/${user.token}")
|
||||
handler.sendChat("리스트는 여기입니다. https://nabot.mori.space/commands/${user.token}")
|
||||
}
|
||||
|
||||
private fun manageAddCommand(msg: SessionChatMessage, user: User) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
|
||||
handler.sendChat("매니저만 명령어를 추가할 수 있습니다.")
|
||||
return
|
||||
}
|
||||
@ -108,7 +109,7 @@ class MessageHandler(
|
||||
}
|
||||
|
||||
private fun manageUpdateCommand(msg: SessionChatMessage, user: User) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
|
||||
handler.sendChat("매니저만 명령어를 추가할 수 있습니다.")
|
||||
return
|
||||
}
|
||||
@ -130,7 +131,7 @@ class MessageHandler(
|
||||
}
|
||||
|
||||
private fun manageRemoveCommand(msg: SessionChatMessage, user: User) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
|
||||
handler.sendChat("매니저만 명령어를 삭제할 수 있습니다.")
|
||||
return
|
||||
}
|
||||
@ -147,7 +148,7 @@ class MessageHandler(
|
||||
}
|
||||
|
||||
private fun timerCommand(msg: SessionChatMessage, user: User) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
|
||||
handler.sendChat("매니저만 이 명령어를 사용할 수 있습니다.")
|
||||
return
|
||||
}
|
||||
@ -226,7 +227,7 @@ class MessageHandler(
|
||||
|
||||
val config = SongConfigService.getConfig(user)
|
||||
|
||||
if(config.streamerOnly && msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
|
||||
if(config.streamerOnly && msg.profile.badges.none { it.imageUrl.contains("manager") }) {
|
||||
handler.sendChat("매니저만 이 명령어를 사용할 수 있습니다.")
|
||||
return
|
||||
}
|
||||
@ -293,11 +294,11 @@ class MessageHandler(
|
||||
return
|
||||
}
|
||||
|
||||
handler.sendChat("리스트는 여기입니다. https://chibot.mori.space/songs/${user.token}")
|
||||
handler.sendChat("리스트는 여기입니다. https://nabot.mori.space/songs/${user.token}")
|
||||
}
|
||||
|
||||
private fun songStartCommand(msg: SessionChatMessage, user: User) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") || it.imageUrl.contains("streamer") }) {
|
||||
if (msg.profile.badges.none { it.imageUrl.contains("manager") }) {
|
||||
handler.sendChat("매니저만 이 명령어를 사용할 수 있습니다.")
|
||||
return
|
||||
}
|
||||
@ -306,7 +307,7 @@ class MessageHandler(
|
||||
if(user.discord != null) {
|
||||
bot.retrieveUserById(user.discord!!).queue { discordUser ->
|
||||
discordUser?.openPrivateChannel()?.queue { channel ->
|
||||
channel.sendMessage("여기로 접속해주세요! ||https://chibot.mori.space/songlist||.")
|
||||
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
|
||||
.queue()
|
||||
}
|
||||
}
|
||||
@ -315,39 +316,6 @@ 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user