mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-08-07 12:51:13 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d2071b323e | ||
|
f2b30c8b00 | ||
|
947e6d4bb3 |
@@ -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
|
||||||
@@ -54,7 +53,7 @@ class MessageHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun manageAddCommand(msg: ChatMessage, user: User) {
|
private fun manageAddCommand(msg: ChatMessage, user: User) {
|
||||||
if (msg.profile?.userRoleCode != "streaming_channel_manager" && msg.profile?.userRoleCode != "streamer") {
|
if (msg.profile?.userRoleCode == "common_user") {
|
||||||
listener.sendChat("매니저만 명령어를 추가할 수 있습니다.")
|
listener.sendChat("매니저만 명령어를 추가할 수 있습니다.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
@@ -75,7 +74,7 @@ class MessageHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun manageUpdateCommand(msg: ChatMessage, user: User) {
|
private fun manageUpdateCommand(msg: ChatMessage, user: User) {
|
||||||
if (msg.profile?.userRoleCode != "streaming_channel_manager" && msg.profile?.userRoleCode != "streamer") {
|
if (msg.profile?.userRoleCode == "common_user") {
|
||||||
listener.sendChat("매니저만 명령어를 추가할 수 있습니다.")
|
listener.sendChat("매니저만 명령어를 추가할 수 있습니다.")
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -96,7 +95,7 @@ class MessageHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun manageRemoveCommand(msg: ChatMessage, user: User) {
|
private fun manageRemoveCommand(msg: ChatMessage, user: User) {
|
||||||
if (msg.profile?.userRoleCode != "streaming_channel_manager" && msg.profile?.userRoleCode != "streamer") {
|
if (msg.profile?.userRoleCode == "common_user") {
|
||||||
listener.sendChat("매니저만 명령어를 삭제할 수 있습니다.")
|
listener.sendChat("매니저만 명령어를 삭제할 수 있습니다.")
|
||||||
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)
|
||||||
|
Reference in New Issue
Block a user