some change on LiveStatus logics

- add LiveStatus table
- in ChzzkHandler.kt (UserHandler), _isActive variable to bind LiveStatusService
This commit is contained in:
dalbodeule
2024-08-03 23:44:10 +09:00
parent d323bf28db
commit 1be1b69425
5 changed files with 57 additions and 3 deletions

View File

@@ -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.LiveStatusService
import space.mori.chzzk_bot.common.services.TimerConfigService
import space.mori.chzzk_bot.common.services.UserService
import space.mori.chzzk_bot.common.utils.convertChzzkDateToLocalDateTime
@@ -96,11 +97,15 @@ class UserHandler(
val channel: ChzzkChannel,
val logger: Logger,
private var user: User,
private var _isActive: Boolean = false,
var streamStartTime: LocalDateTime?,
) {
private lateinit var messageHandler: MessageHandler
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
private var _isActive: Boolean
get() = LiveStatusService.getLiveStatus(user)?.status ?: false
set(value) {
LiveStatusService.updateOrCreate(user, value)
}
var listener: ChzzkChat = chzzk.chat(channel.channelId)
.withAutoReconnect(true)

View File

@@ -40,7 +40,6 @@ class Discord: ListenerAdapter() {
val embed = EmbedBuilder()
embed.setTitle(status.content.liveTitle, "https://chzzk.naver.com/live/${user.token}")
embed.setDescription("${user.username} 님이 방송을 시작했습니다.")
embed.setUrl(status.content.channel.channelImageUrl)
embed.setTimestamp(Instant.now())
embed.setAuthor(user.username, "https://chzzk.naver.com/live/${user.token}", status.content.channel.channelImageUrl)
embed.addField("카테고리", status.content.liveCategoryValue, true)