Merge pull request #58 from dalbodeule/develop

fix somes.
This commit is contained in:
JinU Choi 2024-08-10 21:54:19 +09:00 committed by GitHub
commit 2293596459
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 35 additions and 11 deletions

View File

@ -58,7 +58,7 @@ class MessageHandler(
"!명령어삭제" to this::manageRemoveCommand,
"!명령어수정" to this::manageUpdateCommand,
"!시간" to this::timerCommand,
"!노래추가" to this::songAddCommand,
"!신청곡" to this::songAddCommand,
"!노래목록" to this::songListCommand,
"!노래시작" to this::songStartCommand
)
@ -205,7 +205,11 @@ class MessageHandler(
// songs
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) {
listener.sendChat("유튜브 URL을 입력해주세요!")
return
@ -274,6 +278,10 @@ class MessageHandler(
}
private fun songListCommand(msg: ChatMessage, user: User) {
if(SongConfigService.getConfig(user).disabled) {
return
}
listener.sendChat("리스트는 여기입니다. https://nabot.mori.space/songs/${user.token}")
}
@ -283,16 +291,16 @@ class MessageHandler(
return
}
val session = "${UUID.randomUUID()}${UUID.randomUUID()}".replace("-", "")
user.discord?.let {
bot.retrieveUserById(it).queue { discordUser ->
if(user.discord != null) {
bot.retrieveUserById(user.discord!!).queue { discordUser ->
discordUser?.openPrivateChannel()?.queue { channel ->
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
.queue()
}
}
} else {
listener.sendChat("나봇 홈페이지의 노래목록 페이지를 이용해주세요! 디스코드 연동을 하시면 DM으로 바로 전송됩니다.")
}
}

View File

@ -12,6 +12,7 @@ object SongConfigs: IntIdTable("song_config") {
val streamerOnly = bool("streamer_only").default(false)
val queueLimit = integer("queue_limit").default(50)
val personalLimit = integer("personal_limit").default(5)
val disabled = bool("disabled").default(false)
}
class SongConfig(id: EntityID<Int>) : IntEntity(id) {
companion object : IntEntityClass<SongConfig>(SongConfigs)
@ -21,4 +22,5 @@ class SongConfig(id: EntityID<Int>) : IntEntity(id) {
var streamerOnly by SongConfigs.streamerOnly
var queueLimit by SongConfigs.queueLimit
var personalLimit by SongConfigs.personalLimit
var disabled by SongConfigs.disabled
}

View File

@ -58,4 +58,16 @@ object SongConfigService {
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
}
}
}

View File

@ -36,6 +36,7 @@ data class GetSessionDTO(
val maxQueueSize: Int,
val maxUserSize: Int,
val isStreamerOnly: Boolean,
val isDisabled: Boolean
)
@Serializable
@ -112,7 +113,8 @@ fun Routing.apiRoutes() {
status.content!!.channel.channelImageUrl,
songConfig.queueLimit,
songConfig.personalLimit,
songConfig.streamerOnly
songConfig.streamerOnly,
songConfig.disabled
))
}
post {

View File

@ -60,7 +60,7 @@ fun Routing.wsSongListRoutes() {
null,
null,
null,
null
null,
))
}
removeSession(uid, this)
@ -75,6 +75,7 @@ fun Routing.wsSongListRoutes() {
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.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) {
try {
@ -173,8 +174,6 @@ fun Routing.wsSongListRoutes() {
CoroutineScope(Dispatchers.Default).launch {
val user = UserService.getUser(it.uid)
if(user != null) {
val session = SongConfigService.getConfig(user)
sessions[user.token]?.forEach { ws ->
ws.sendSerialized(
SongResponse(
@ -203,5 +202,6 @@ data class SongRequest(
val maxQueue: Int?,
val maxUserLimit: Int?,
val isStreamerOnly: Boolean?,
val remove: Int?
val remove: Int?,
val isDisabled: Boolean?,
)