chore: format code and add qodana
This commit is contained in:
4 files changed
+43
-4
No files matched your search
+31
@@ -0,0 +1,31 @@
|
||||
#-------------------------------------------------------------------------------#
|
||||
# Qodana analysis is configured by qodana.yaml file #
|
||||
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
|
||||
#-------------------------------------------------------------------------------#
|
||||
version: "1.0"
|
||||
|
||||
#Specify inspection profile for code analysis
|
||||
profile:
|
||||
name: qodana.starter
|
||||
|
||||
#Enable inspections
|
||||
#include:
|
||||
# - name: <SomeEnabledInspectionId>
|
||||
|
||||
#Disable inspections
|
||||
#exclude:
|
||||
# - name: <SomeDisabledInspectionId>
|
||||
# paths:
|
||||
# - <path/where/not/run/inspection>
|
||||
|
||||
projectJDK: 17 #(Applied in CI/CD pipeline)
|
||||
|
||||
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
|
||||
#bootstrap: sh ./prepare-qodana.sh
|
||||
|
||||
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
|
||||
#plugins:
|
||||
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
|
||||
|
||||
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
|
||||
linter: jetbrains/qodana-jvm:latest
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user