Skip to content

Commit

Permalink
Add logging to HTTP API server, fix send voice incomplete problem. Close
Browse files Browse the repository at this point in the history
  • Loading branch information
yyuueexxiinngg committed Aug 23, 2020
1 parent 25e0e75 commit ae26c50
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/tech/mihoyo/mirai/util/CQMessgeParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ suspend fun tryResolveMedia(type: String, contact: Contact?, args: Map<String, S
}
if (media == null || !useCache) {
mediaBytes = HttpClient.getBytes(mediaUrl!!)
media = HttpClient.getInputStream(mediaUrl!!)
media = ByteArrayInputStream(mediaBytes)
.let { stream ->
contact?.let { (it as Group).uploadVoice(stream) }
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/tech/mihoyo/mirai/web/http/HttpApiModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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) {
Expand Down

0 comments on commit ae26c50

Please sign in to comment.