chore: format code and add qodana

This commit is contained in:
2024-09-25 18:18:28 +08:00
parent 4d2be92081
commit 19e980be86
4 files changed
+43 -4

No files matched your search

@@ -11,6 +11,8 @@ import cn.rtast.rob.entity.GroupMessage
import cn.rtast.rob.util.BaseCommand
import cn.rtast.rob.util.ob.MessageChain
import cn.rtast.rob.util.ob.OneBotListener
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.net.InetAddress
class NslookupCommand : BaseCommand() {
@@ -20,7 +22,9 @@ class NslookupCommand : BaseCommand() {
val msg = MessageChain.Builder()
.addReply(message.messageId)
.addText("域名: ${args.first()}解析后的IP地址为: ")
.addText(InetAddress.getByName(args.first()).hostAddress)
.addText(withContext(Dispatchers.IO) {
InetAddress.getByName(args.first())
}.hostAddress)
.build()
listener.sendGroupMessage(message.groupId, msg)
}
@@ -14,6 +14,8 @@ import cn.rtast.rob.enums.ArrayMessageType
import cn.rtast.rob.util.BaseCommand
import cn.rtast.rob.util.ob.MessageChain
import cn.rtast.rob.util.ob.OneBotListener
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.awt.Color
import java.awt.Font
import java.awt.image.BufferedImage
@@ -84,7 +86,9 @@ class AsciiArtCommand : BaseCommand() {
if (message.sender.userId in waitingList) {
if (message.message.any { it.type == ArrayMessageType.image }) {
val url = message.message.find { it.type == ArrayMessageType.image }!!.data.file!!
val bufferedImage = ImageIO.read(URI(url).toURL())
val bufferedImage = withContext(Dispatchers.IO) {
ImageIO.read(URI(url).toURL())
}
val imageBase64 =
bufferedImage.convertToAscii().saveAsciiArtToImage(bufferedImage.width, bufferedImage.height)
val msg = MessageChain.Builder().addImage(imageBase64, true).build()
@@ -16,8 +16,8 @@ import okhttp3.RequestBody.Companion.toRequestBody
object Http {
val jsonMediaType = "application/json; charset=utf-8".toMediaType()
val jsonHeader = mapOf(
private val jsonMediaType = "application/json; charset=utf-8".toMediaType()
private val jsonHeader = mapOf(
"Content-Type" to "application/json; charset=utf-8",
"Accept" to "application/json"
)