From ae26c5067fa5b386ee68189917115259888d4e79 Mon Sep 17 00:00:00 2001 From: yyuueexxiinngg Date: Sun, 23 Aug 2020 12:59:24 +0800 Subject: [PATCH] Add logging to HTTP API server, fix send voice incomplete problem. Close #59 --- build.gradle.kts | 1 + src/main/kotlin/tech/mihoyo/mirai/util/CQMessgeParser.kt | 2 +- src/main/kotlin/tech/mihoyo/mirai/web/http/HttpApiModule.kt | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9dd5c2c..ada4169 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,6 +32,7 @@ dependencies { compileOnly(kotlin("serialization", kotlinVersion)) implementation(kotlinx("serialization-cbor", kotlinSerializationVersion)) + implementation("ch.qos.logback:logback-classic:1.2.3") api(ktor("server-cio")) api(ktor("client-cio")) diff --git a/src/main/kotlin/tech/mihoyo/mirai/util/CQMessgeParser.kt b/src/main/kotlin/tech/mihoyo/mirai/util/CQMessgeParser.kt index 06b8fc4..1d92490 100644 --- a/src/main/kotlin/tech/mihoyo/mirai/util/CQMessgeParser.kt +++ b/src/main/kotlin/tech/mihoyo/mirai/util/CQMessgeParser.kt @@ -413,7 +413,7 @@ suspend fun tryResolveMedia(type: String, contact: Contact?, args: Map contact?.let { (it as Group).uploadVoice(stream) } } diff --git a/src/main/kotlin/tech/mihoyo/mirai/web/http/HttpApiModule.kt b/src/main/kotlin/tech/mihoyo/mirai/web/http/HttpApiModule.kt index 0301ff6..9b61af6 100644 --- a/src/main/kotlin/tech/mihoyo/mirai/web/http/HttpApiModule.kt +++ b/src/main/kotlin/tech/mihoyo/mirai/web/http/HttpApiModule.kt @@ -10,6 +10,7 @@ package tech.mihoyo.mirai.web.http import io.ktor.application.* +import io.ktor.features.* import io.ktor.http.* import io.ktor.request.* import io.ktor.response.* @@ -31,6 +32,7 @@ import java.nio.charset.Charset import kotlin.coroutines.EmptyCoroutineContext fun Application.cqHttpApiServer(session: BotSession, serviceConfig: HttpApiServerServiceConfig) { + install(CallLogging) // it.second -> if is async call routing { cqHttpApi("/send_msg", serviceConfig) {