mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
debug some codes.
This commit is contained in:
parent
9a91537e59
commit
b12e29674a
@ -54,6 +54,9 @@ object ChzzkHandler {
|
|||||||
addUser(channel, user)
|
addUser(channel, user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dispatcher.subscribe(CommandReloadEvent::class) {
|
||||||
|
handlers.firstOrNull { handlers -> handlers.channel.channelId == it.uid }?.reloadCommand()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun disable() {
|
fun disable() {
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package space.mori.chzzk_bot.common.events
|
||||||
|
|
||||||
|
data class CommandReloadEvent(
|
||||||
|
val uid: String
|
||||||
|
): Event {
|
||||||
|
val TAG = javaClass.simpleName
|
||||||
|
}
|
@ -97,7 +97,7 @@ val server = embeddedServer(Netty, port = 8080, ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
call.respondRedirect(dotenv["FRONTEND"])
|
call.respondRedirect("${ if(dotenv["FRONTEND_HTTPS"].toBoolean()) "https://" else "http://" }${dotenv["FRONTEND"]}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get("/logout") {
|
get("/logout") {
|
||||||
|
@ -6,12 +6,20 @@ import io.ktor.server.request.*
|
|||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
import io.ktor.server.sessions.*
|
import io.ktor.server.sessions.*
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
import org.koin.java.KoinJavaComponent.inject
|
||||||
|
import space.mori.chzzk_bot.common.events.CommandReloadEvent
|
||||||
|
import space.mori.chzzk_bot.common.events.CoroutinesEventBus
|
||||||
import space.mori.chzzk_bot.common.services.CommandService
|
import space.mori.chzzk_bot.common.services.CommandService
|
||||||
import space.mori.chzzk_bot.common.services.UserService
|
import space.mori.chzzk_bot.common.services.UserService
|
||||||
import space.mori.chzzk_bot.webserver.UserSession
|
import space.mori.chzzk_bot.webserver.UserSession
|
||||||
|
|
||||||
fun Routing.apiCommandRoutes() {
|
fun Routing.apiCommandRoutes() {
|
||||||
|
val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
||||||
|
|
||||||
route("/commands") {
|
route("/commands") {
|
||||||
get("/{uid}") {
|
get("/{uid}") {
|
||||||
val uid = call.parameters["uid"]
|
val uid = call.parameters["uid"]
|
||||||
@ -52,6 +60,9 @@ fun Routing.apiCommandRoutes() {
|
|||||||
commandRequest.content,
|
commandRequest.content,
|
||||||
commandRequest.failContent ?: ""
|
commandRequest.failContent ?: ""
|
||||||
)
|
)
|
||||||
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
|
dispatcher.post(CommandReloadEvent(user.token ?: ""))
|
||||||
|
}
|
||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +87,9 @@ fun Routing.apiCommandRoutes() {
|
|||||||
commandRequest.content,
|
commandRequest.content,
|
||||||
commandRequest.failContent ?: ""
|
commandRequest.failContent ?: ""
|
||||||
)
|
)
|
||||||
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
|
dispatcher.post(CommandReloadEvent(user.token ?: ""))
|
||||||
|
}
|
||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
} catch(e: Exception) {
|
} catch(e: Exception) {
|
||||||
call.respond(HttpStatusCode.BadRequest)
|
call.respond(HttpStatusCode.BadRequest)
|
||||||
@ -98,6 +112,9 @@ fun Routing.apiCommandRoutes() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
CommandService.removeCommand(user, commandRequest.label)
|
CommandService.removeCommand(user, commandRequest.label)
|
||||||
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
|
dispatcher.post(CommandReloadEvent(user.token ?: ""))
|
||||||
|
}
|
||||||
call.respond(HttpStatusCode.OK)
|
call.respond(HttpStatusCode.OK)
|
||||||
} catch(e: Exception) {
|
} catch(e: Exception) {
|
||||||
call.respond(HttpStatusCode.BadRequest)
|
call.respond(HttpStatusCode.BadRequest)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user