chore: format code and add qodana
This commit is contained in:
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()
|
||||
|
||||
Reference in New Issue
Block a user