Commit f3f8be5f authored by Him188's avatar Him188

Simplify code

parent a5853ba2
......@@ -132,20 +132,19 @@ suspend fun main() {
}
has<Image> {
if (this is FriendMessage || (this is GroupMessage && this.permission == MemberPermission.ADMINISTRATOR)) {
withContext(IO) {
val image: Image by message
// 等同于 val image = message[Image]
try {
image.downloadTo(newTestTempFile(suffix = ".png").also { reply("Temp file: ${it.absolutePath}") })
reply(image.id.value + " downloaded")
} catch (e: Exception) {
e.printStackTrace()
reply(e.message ?: e::class.java.simpleName)
}
if (this is FriendMessage || (this is GroupMessage && this.permission == MemberPermission.ADMINISTRATOR)) withContext(IO) {
val image: Image by message
// 等同于 val image = message[Image]
try {
image.downloadTo(newTestTempFile(suffix = ".png").also { reply("Temp file: ${it.absolutePath}") })
reply(image.id.value + " downloaded")
} catch (e: Exception) {
e.printStackTrace()
reply(e.message ?: e::class.java.simpleName)
}
}
}
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