3 Commits
0.1.5 ... 0.2.0

Author SHA1 Message Date
dalbodeule
80d777dad5 chzzkChat only connected on live 2024-07-02 10:04:23 +09:00
dalbodeule
d2071b323e register command in chat some fix (4x) 2024-06-29 21:58:50 +09:00
dalbodeule
f2b30c8b00 register command in chat some fix (3x) 2024-06-29 21:44:18 +09:00
2 changed files with 16 additions and 20 deletions

View File

@@ -116,11 +116,6 @@ class UserHandler(
}) })
.build() .build()
init {
logger.info("ChzzkChat connecting... ${channel.channelName} - ${channel.channelId}")
listener.connectAsync()
}
internal fun disable() { internal fun disable() {
listener.closeAsync() listener.closeAsync()
} }
@@ -140,6 +135,10 @@ class UserHandler(
_isActive = value _isActive = value
if(value) { if(value) {
logger.info("${user.username} is live.") 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) { if(user.liveAlertMessage != "" && user.liveAlertGuild != null && user.liveAlertChannel != null) {
val channel = discord.getChannel(user.liveAlertGuild!!, user.liveAlertChannel!!) ?: throw RuntimeException("${user.liveAlertChannel} is not valid.") val channel = discord.getChannel(user.liveAlertGuild!!, user.liveAlertChannel!!) ?: throw RuntimeException("${user.liveAlertChannel} is not valid.")
@@ -164,6 +163,7 @@ class UserHandler(
} }
} else { } else {
logger.info("${user.username} is offline.") logger.info("${user.username} is offline.")
listener.closeAsync()
listener.sendChat("${user.username} 님! 방송 수고하셨습니다.") listener.sendChat("${user.username} 님! 방송 수고하셨습니다.")
} }

View File

@@ -1,7 +1,6 @@
package space.mori.chzzk_bot.chzzk package space.mori.chzzk_bot.chzzk
import org.slf4j.Logger import org.slf4j.Logger
import space.mori.chzzk_bot.models.Command
import space.mori.chzzk_bot.models.User import space.mori.chzzk_bot.models.User
import space.mori.chzzk_bot.services.CommandService import space.mori.chzzk_bot.services.CommandService
import space.mori.chzzk_bot.services.CounterService import space.mori.chzzk_bot.services.CounterService
@@ -64,7 +63,7 @@ class MessageHandler(
listener.sendChat("명령어 추가 형식은 '!명령어추가 명령어 내용'입니다.") listener.sendChat("명령어 추가 형식은 '!명령어추가 명령어 내용'입니다.")
return return
} }
if (commands.containsKey(parts[0])) { if (commands.containsKey(parts[1])) {
listener.sendChat("${parts[1]} 명령어는 이미 있는 명령어입니다.") listener.sendChat("${parts[1]} 명령어는 이미 있는 명령어입니다.")
return return
} }
@@ -85,7 +84,7 @@ class MessageHandler(
listener.sendChat("명령어 수정 형식은 '!명령어수정 명령어 내용'입니다.") listener.sendChat("명령어 수정 형식은 '!명령어수정 명령어 내용'입니다.")
return return
} }
if (!commands.containsKey(parts[0])) { if (!commands.containsKey(parts[1])) {
listener.sendChat("${parts[1]} 명령어는 없는 명령어입니다.") listener.sendChat("${parts[1]} 명령어는 없는 명령어입니다.")
return return
} }
@@ -121,16 +120,6 @@ class MessageHandler(
var result = chat.first var result = chat.first
var isFail = false var isFail = false
result = counterPattern.replace(result) {
val name = it.groupValues[1]
CounterService.updateCounterValue(name, 1, user).toString()
}
result = personalCounterPattern.replace(result) {
val name = it.groupValues[1]
CounterService.updatePersonalCounterValue(name, msg.userId, 1, user).toString()
}
result = dailyCounterPattern.replace(result) { result = dailyCounterPattern.replace(result) {
val name = it.groupValues[1] val name = it.groupValues[1]
val dailyCounter = CounterService.getDailyCounterValue(name, msg.userId, user) val dailyCounter = CounterService.getDailyCounterValue(name, msg.userId, user)
@@ -167,8 +156,15 @@ class MessageHandler(
val period = Period.between(pastDate, today) val period = Period.between(pastDate, today)
period.days.toString() period.days.toString()
} }
if(isFail) {
return chat.second result = counterPattern.replace(result) {
val name = it.groupValues[1]
CounterService.updateCounterValue(name, 1, user).toString()
}
result = personalCounterPattern.replace(result) {
val name = it.groupValues[1]
CounterService.updatePersonalCounterValue(name, msg.userId, 1, user).toString()
} }
result = namePattern.replace(result, userName) result = namePattern.replace(result, userName)