mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
commit
2293596459
@ -58,7 +58,7 @@ class MessageHandler(
|
|||||||
"!명령어삭제" to this::manageRemoveCommand,
|
"!명령어삭제" to this::manageRemoveCommand,
|
||||||
"!명령어수정" to this::manageUpdateCommand,
|
"!명령어수정" to this::manageUpdateCommand,
|
||||||
"!시간" to this::timerCommand,
|
"!시간" to this::timerCommand,
|
||||||
"!노래추가" to this::songAddCommand,
|
"!신청곡" to this::songAddCommand,
|
||||||
"!노래목록" to this::songListCommand,
|
"!노래목록" to this::songListCommand,
|
||||||
"!노래시작" to this::songStartCommand
|
"!노래시작" to this::songStartCommand
|
||||||
)
|
)
|
||||||
@ -205,7 +205,11 @@ class MessageHandler(
|
|||||||
|
|
||||||
// songs
|
// songs
|
||||||
private fun songAddCommand(msg: ChatMessage, user: User) {
|
private fun songAddCommand(msg: ChatMessage, user: User) {
|
||||||
val parts = msg.content.split(" ", limit = 3)
|
if(SongConfigService.getConfig(user).disabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val parts = msg.content.split(" ", limit = 2)
|
||||||
if (parts.size < 2) {
|
if (parts.size < 2) {
|
||||||
listener.sendChat("유튜브 URL을 입력해주세요!")
|
listener.sendChat("유튜브 URL을 입력해주세요!")
|
||||||
return
|
return
|
||||||
@ -274,6 +278,10 @@ class MessageHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun songListCommand(msg: ChatMessage, user: User) {
|
private fun songListCommand(msg: ChatMessage, user: User) {
|
||||||
|
if(SongConfigService.getConfig(user).disabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
listener.sendChat("리스트는 여기입니다. https://nabot.mori.space/songs/${user.token}")
|
listener.sendChat("리스트는 여기입니다. https://nabot.mori.space/songs/${user.token}")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,16 +291,16 @@ class MessageHandler(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val session = "${UUID.randomUUID()}${UUID.randomUUID()}".replace("-", "")
|
|
||||||
|
|
||||||
|
if(user.discord != null) {
|
||||||
user.discord?.let {
|
bot.retrieveUserById(user.discord!!).queue { discordUser ->
|
||||||
bot.retrieveUserById(it).queue { discordUser ->
|
|
||||||
discordUser?.openPrivateChannel()?.queue { channel ->
|
discordUser?.openPrivateChannel()?.queue { channel ->
|
||||||
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
|
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
|
||||||
.queue()
|
.queue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
listener.sendChat("나봇 홈페이지의 노래목록 페이지를 이용해주세요! 디스코드 연동을 하시면 DM으로 바로 전송됩니다.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ object SongConfigs: IntIdTable("song_config") {
|
|||||||
val streamerOnly = bool("streamer_only").default(false)
|
val streamerOnly = bool("streamer_only").default(false)
|
||||||
val queueLimit = integer("queue_limit").default(50)
|
val queueLimit = integer("queue_limit").default(50)
|
||||||
val personalLimit = integer("personal_limit").default(5)
|
val personalLimit = integer("personal_limit").default(5)
|
||||||
|
val disabled = bool("disabled").default(false)
|
||||||
}
|
}
|
||||||
class SongConfig(id: EntityID<Int>) : IntEntity(id) {
|
class SongConfig(id: EntityID<Int>) : IntEntity(id) {
|
||||||
companion object : IntEntityClass<SongConfig>(SongConfigs)
|
companion object : IntEntityClass<SongConfig>(SongConfigs)
|
||||||
@ -21,4 +22,5 @@ class SongConfig(id: EntityID<Int>) : IntEntity(id) {
|
|||||||
var streamerOnly by SongConfigs.streamerOnly
|
var streamerOnly by SongConfigs.streamerOnly
|
||||||
var queueLimit by SongConfigs.queueLimit
|
var queueLimit by SongConfigs.queueLimit
|
||||||
var personalLimit by SongConfigs.personalLimit
|
var personalLimit by SongConfigs.personalLimit
|
||||||
|
var disabled by SongConfigs.disabled
|
||||||
}
|
}
|
@ -58,4 +58,16 @@ object SongConfigService {
|
|||||||
songConfig
|
songConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateDisabled(user: User, config: Boolean): SongConfig {
|
||||||
|
return transaction {
|
||||||
|
var songConfig = SongConfig.find(SongConfigs.user eq user.id).firstOrNull()
|
||||||
|
if (songConfig == null) {
|
||||||
|
songConfig = initConfig(user)
|
||||||
|
}
|
||||||
|
songConfig.disabled = config
|
||||||
|
|
||||||
|
songConfig
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -36,6 +36,7 @@ data class GetSessionDTO(
|
|||||||
val maxQueueSize: Int,
|
val maxQueueSize: Int,
|
||||||
val maxUserSize: Int,
|
val maxUserSize: Int,
|
||||||
val isStreamerOnly: Boolean,
|
val isStreamerOnly: Boolean,
|
||||||
|
val isDisabled: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -112,7 +113,8 @@ fun Routing.apiRoutes() {
|
|||||||
status.content!!.channel.channelImageUrl,
|
status.content!!.channel.channelImageUrl,
|
||||||
songConfig.queueLimit,
|
songConfig.queueLimit,
|
||||||
songConfig.personalLimit,
|
songConfig.personalLimit,
|
||||||
songConfig.streamerOnly
|
songConfig.streamerOnly,
|
||||||
|
songConfig.disabled
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
|
@ -60,7 +60,7 @@ fun Routing.wsSongListRoutes() {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null
|
null,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
removeSession(uid, this)
|
removeSession(uid, this)
|
||||||
@ -75,6 +75,7 @@ fun Routing.wsSongListRoutes() {
|
|||||||
if(data.maxQueue != null && data.maxQueue > 0) SongConfigService.updateQueueLimit(user, data.maxQueue)
|
if(data.maxQueue != null && data.maxQueue > 0) SongConfigService.updateQueueLimit(user, data.maxQueue)
|
||||||
if(data.maxUserLimit != null && data.maxUserLimit > 0) SongConfigService.updatePersonalLimit(user, data.maxUserLimit)
|
if(data.maxUserLimit != null && data.maxUserLimit > 0) SongConfigService.updatePersonalLimit(user, data.maxUserLimit)
|
||||||
if(data.isStreamerOnly != null) SongConfigService.updateStreamerOnly(user, data.isStreamerOnly)
|
if(data.isStreamerOnly != null) SongConfigService.updateStreamerOnly(user, data.isStreamerOnly)
|
||||||
|
if(data.isDisabled != null) SongConfigService.updateDisabled(user, data.isDisabled)
|
||||||
|
|
||||||
if(data.type == SongType.ADD.value && data.url != null) {
|
if(data.type == SongType.ADD.value && data.url != null) {
|
||||||
try {
|
try {
|
||||||
@ -173,8 +174,6 @@ fun Routing.wsSongListRoutes() {
|
|||||||
CoroutineScope(Dispatchers.Default).launch {
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
val user = UserService.getUser(it.uid)
|
val user = UserService.getUser(it.uid)
|
||||||
if(user != null) {
|
if(user != null) {
|
||||||
val session = SongConfigService.getConfig(user)
|
|
||||||
|
|
||||||
sessions[user.token]?.forEach { ws ->
|
sessions[user.token]?.forEach { ws ->
|
||||||
ws.sendSerialized(
|
ws.sendSerialized(
|
||||||
SongResponse(
|
SongResponse(
|
||||||
@ -203,5 +202,6 @@ data class SongRequest(
|
|||||||
val maxQueue: Int?,
|
val maxQueue: Int?,
|
||||||
val maxUserLimit: Int?,
|
val maxUserLimit: Int?,
|
||||||
val isStreamerOnly: Boolean?,
|
val isStreamerOnly: Boolean?,
|
||||||
val remove: Int?
|
val remove: Int?,
|
||||||
|
val isDisabled: Boolean?,
|
||||||
)
|
)
|
Loading…
x
Reference in New Issue
Block a user