From 80d777dad556448e666082c02d89762aee8bce54 Mon Sep 17 00:00:00 2001 From: dalbodeule <11470513+dalbodeule@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:04:23 +0900 Subject: [PATCH] chzzkChat only connected on live --- .../kotlin/space/mori/chzzk_bot/chzzk/ChzzkHandler.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/space/mori/chzzk_bot/chzzk/ChzzkHandler.kt b/src/main/kotlin/space/mori/chzzk_bot/chzzk/ChzzkHandler.kt index 5e7b6e1..b2fa90b 100644 --- a/src/main/kotlin/space/mori/chzzk_bot/chzzk/ChzzkHandler.kt +++ b/src/main/kotlin/space/mori/chzzk_bot/chzzk/ChzzkHandler.kt @@ -116,11 +116,6 @@ class UserHandler( }) .build() - init { - logger.info("ChzzkChat connecting... ${channel.channelName} - ${channel.channelId}") - listener.connectAsync() - } - internal fun disable() { listener.closeAsync() } @@ -140,6 +135,10 @@ class UserHandler( _isActive = value if(value) { logger.info("${user.username} is live.") + + logger.info("ChzzkChat connecting... ${channel.channelName} - ${channel.channelId}") + listener.connectAsync() + if(user.liveAlertMessage != "" && user.liveAlertGuild != null && user.liveAlertChannel != null) { val channel = discord.getChannel(user.liveAlertGuild!!, user.liveAlertChannel!!) ?: throw RuntimeException("${user.liveAlertChannel} is not valid.") @@ -164,6 +163,7 @@ class UserHandler( } } else { logger.info("${user.username} is offline.") + listener.closeAsync() listener.sendChat("${user.username} 님! 방송 수고하셨습니다.") }