Skip to content

Commit

Permalink
send image
Browse files Browse the repository at this point in the history
  • Loading branch information
lz1998 committed Sep 22, 2020
1 parent 835f644 commit 89eea7b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/kotlin/net/lz1998/mirai/utils/MsgConverter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import net.mamoe.mirai.message.data.*
import net.mamoe.mirai.message.uploadAsImage
import onebot.OnebotBase
import java.io.File
import java.net.URL

val MSG_EMPTY = PlainText("")

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

0 comments on commit 89eea7b

Please sign in to comment.