chore: add catch exception

This commit is contained in:
2024-10-09 13:17:13 +08:00
parent 06a385db1a
commit f9e6bac23d
1 file changed
+9 -4
@@ -8,6 +8,7 @@
package cn.rtast.fancybot package cn.rtast.fancybot
import cn.rtast.fancybot.commands.misc.ScanQRCodeCommand import cn.rtast.fancybot.commands.misc.ScanQRCodeCommand
import cn.rtast.fancybot.commands.misc.ShortLinkCommand.Companion.makeShortLink
import cn.rtast.fancybot.commands.parse.* import cn.rtast.fancybot.commands.parse.*
import cn.rtast.fancybot.enums.WSType import cn.rtast.fancybot.enums.WSType
import cn.rtast.fancybot.util.* import cn.rtast.fancybot.util.*
@@ -85,10 +86,14 @@ class FancyBot : OneBotListener {
if (imageUrl == null) { if (imageUrl == null) {
message.reply("这个消息里没有图片呢!") message.reply("这个消息里没有图片呢!")
} else { } else {
try {
val imageByteArray = imageUrl.toURL().readBytes() val imageByteArray = imageUrl.toURL().readBytes()
val imageFileType = imageByteArray.getFileType() val imageFileType = imageByteArray.getFileType()
val imageBedUrl = ImageBed.upload(imageByteArray, imageFileType) val imageBedUrl = ImageBed.upload(imageByteArray, imageFileType).makeShortLink()
message.reply(imageBedUrl) message.reply(imageBedUrl)
} catch (_: Exception) {
message.reply("上传失败~")
}
} }
} }
} }