mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-08-07 21:01:14 +00:00
add TimerConfig.kt, TimerConfigService
This commit is contained in:
@@ -13,6 +13,7 @@ import space.mori.chzzk_bot.common.events.CoroutinesEventBus
|
||||
import space.mori.chzzk_bot.common.events.TimerEvent
|
||||
import space.mori.chzzk_bot.common.events.TimerType
|
||||
import space.mori.chzzk_bot.common.models.User
|
||||
import space.mori.chzzk_bot.common.services.TimerConfigService
|
||||
import space.mori.chzzk_bot.common.services.UserService
|
||||
import space.mori.chzzk_bot.common.utils.convertChzzkDateToLocalDateTime
|
||||
import space.mori.chzzk_bot.common.utils.getUptime
|
||||
@@ -152,11 +153,19 @@ class UserHandler(
|
||||
streamStartTime = convertChzzkDateToLocalDateTime(status.content.openDate)
|
||||
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
dispatcher.post(TimerEvent(
|
||||
channel.channelId,
|
||||
TimerType.UPTIME,
|
||||
getUptime(streamStartTime!!)
|
||||
))
|
||||
when(TimerConfigService.getConfig(UserService.getUser(channel.channelId)!!)?.option) {
|
||||
TimerType.UPTIME.value -> dispatcher.post(TimerEvent(
|
||||
channel.channelId,
|
||||
TimerType.UPTIME,
|
||||
getUptime(streamStartTime!!)
|
||||
))
|
||||
else -> dispatcher.post(TimerEvent(
|
||||
channel.channelId,
|
||||
TimerType.REMOVE,
|
||||
""
|
||||
))
|
||||
}
|
||||
|
||||
delay(5000L)
|
||||
listener.sendChat("${user.username} 님! 오늘도 열심히 방송하세요!")
|
||||
Discord.sendDiscord(user, status)
|
||||
|
@@ -10,6 +10,7 @@ import space.mori.chzzk_bot.common.events.TimerType
|
||||
import space.mori.chzzk_bot.common.models.User
|
||||
import space.mori.chzzk_bot.common.services.CommandService
|
||||
import space.mori.chzzk_bot.common.services.CounterService
|
||||
import space.mori.chzzk_bot.common.services.TimerConfigService
|
||||
import space.mori.chzzk_bot.common.services.UserService
|
||||
import space.mori.chzzk_bot.common.utils.getUptime
|
||||
import xyz.r2turntrue.chzzk4j.chat.ChatMessage
|
||||
@@ -125,7 +126,7 @@ class MessageHandler(
|
||||
return
|
||||
}
|
||||
|
||||
val parts = msg.content.split(" ", limit = 2)
|
||||
val parts = msg.content.split(" ", limit = 3)
|
||||
if (parts.size < 2) {
|
||||
listener.sendChat("타이머 명령어 형식을 잘 찾아봐주세요!")
|
||||
return
|
||||
@@ -152,6 +153,19 @@ class MessageHandler(
|
||||
dispatcher.post(TimerEvent(user.token, TimerType.REMOVE, ""))
|
||||
}
|
||||
}
|
||||
"설정" -> {
|
||||
when (parts[2]) {
|
||||
"업타임" -> {
|
||||
TimerConfigService.saveOrUpdateConfig(user, TimerType.UPTIME)
|
||||
listener.sendChat("기본 타이머 설정이 업타임으로 바뀌었습니다.")
|
||||
}
|
||||
"삭제" -> {
|
||||
TimerConfigService.saveOrUpdateConfig(user, TimerType.REMOVE)
|
||||
listener.sendChat("기본 타이머 설정이 삭제로 바뀌었습니다.")
|
||||
}
|
||||
else -> listener.sendChat("!타이머 설정 (업타임/삭제) 형식으로 써주세요!")
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
logger.debug("${user.token} / 그외")
|
||||
try {
|
||||
|
Reference in New Issue
Block a user