Skip to content

Commit 89eea7b

Browse files
committed
send image
1 parent 835f644 commit 89eea7b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/kotlin/net/lz1998/mirai/utils/MsgConverter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import net.mamoe.mirai.message.data.*
99
import net.mamoe.mirai.message.uploadAsImage
1010
import onebot.OnebotBase
1111
import java.io.File
12+
import java.net.URL
1213

1314
val MSG_EMPTY = PlainText("")
1415

@@ -19,7 +20,7 @@ suspend fun OnebotBase.Message.toMiraiMessage(bot: Bot, contact: Contact): Messa
1920
"image" -> {
2021
return try {
2122
withContext(Dispatchers.IO) {
22-
File(dataMap["file"] ?: "").uploadAsImage(contact)
23+
URL(dataMap["file"]?:"").openConnection().getInputStream().uploadAsImage(contact)
2324
}
2425
} catch (e: Exception) {
2526
MSG_EMPTY

0 commit comments

Comments
 (0)