فهرست منبع

Simplify code

Him188 6 سال پیش
والد
کامیت
f3f8be5fb6
1فایلهای تغییر یافته به همراه11 افزوده شده و 12 حذف شده
  1. 11 12
      mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt

+ 11 - 12
mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt

@@ -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@{