Commit f3f8be5f authored by Him188's avatar Him188

Simplify code

parent a5853ba2
...@@ -132,20 +132,19 @@ suspend fun main() { ...@@ -132,20 +132,19 @@ suspend fun main() {
} }
has<Image> { has<Image> {
if (this is FriendMessage || (this is GroupMessage && this.permission == MemberPermission.ADMINISTRATOR)) { if (this is FriendMessage || (this is GroupMessage && this.permission == MemberPermission.ADMINISTRATOR)) withContext(IO) {
withContext(IO) { val image: Image by message
val image: Image by message // 等同于 val image = message[Image]
// 等同于 val image = message[Image]
try {
try { image.downloadTo(newTestTempFile(suffix = ".png").also { reply("Temp file: ${it.absolutePath}") })
image.downloadTo(newTestTempFile(suffix = ".png").also { reply("Temp file: ${it.absolutePath}") }) reply(image.id.value + " downloaded")
reply(image.id.value + " downloaded") } catch (e: Exception) {
} catch (e: Exception) { e.printStackTrace()
e.printStackTrace() reply(e.message ?: e::class.java.simpleName)
reply(e.message ?: e::class.java.simpleName)
}
} }
} }
} }
startsWith("上传图片", removePrefix = true) handler@{ startsWith("上传图片", removePrefix = true) handler@{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment