chore: add catch exception
This commit is contained in:
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 {
|
||||||
val imageByteArray = imageUrl.toURL().readBytes()
|
try {
|
||||||
val imageFileType = imageByteArray.getFileType()
|
val imageByteArray = imageUrl.toURL().readBytes()
|
||||||
val imageBedUrl = ImageBed.upload(imageByteArray, imageFileType)
|
val imageFileType = imageByteArray.getFileType()
|
||||||
message.reply(imageBedUrl)
|
val imageBedUrl = ImageBed.upload(imageByteArray, imageFileType).makeShortLink()
|
||||||
|
message.reply(imageBedUrl)
|
||||||
|
} catch (_: Exception) {
|
||||||
|
message.reply("上传失败~")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user