feat: add nailong detect
This commit is contained in:
7 files changed
+40
-2
No files matched your search
@@ -93,7 +93,8 @@ val DEFAULT_CONFIG = Config(
|
||||
apiSpaceKey = "114514",
|
||||
apiRtastKey = "114514",
|
||||
azureAppClientId = "114514",
|
||||
youtubeDataApiKey = "114514"
|
||||
youtubeDataApiKey = "114514",
|
||||
naiLongApiUrl = "http://127.0.0.1:5000/nailong"
|
||||
)
|
||||
|
||||
val configManager = ConfigManager()
|
||||
|
||||
@@ -13,6 +13,8 @@ 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.reply.ImageBedCommand
|
||||
import cn.rtast.fancybot.entity.nailong.NaiLongDetectPayload
|
||||
import cn.rtast.fancybot.entity.nailong.NaiLongDetectResponse
|
||||
import cn.rtast.fancybot.enums.WSType
|
||||
import cn.rtast.fancybot.util.*
|
||||
import cn.rtast.fancybot.util.misc.convertToDate
|
||||
@@ -21,6 +23,7 @@ import cn.rtast.fancybot.util.misc.initCommand
|
||||
import cn.rtast.fancybot.util.misc.initFilesDir
|
||||
import cn.rtast.fancybot.util.misc.initItems
|
||||
import cn.rtast.fancybot.util.misc.initSetuIndex
|
||||
import cn.rtast.fancybot.util.str.toJson
|
||||
import cn.rtast.rob.ROneBotFactory
|
||||
import cn.rtast.rob.entity.*
|
||||
import cn.rtast.rob.entity.custom.BeKickEvent
|
||||
@@ -58,6 +61,17 @@ class FancyBot : OneBotListener {
|
||||
logger.info("$sender($senderId: $groupId >>> $messageId): $msg")
|
||||
logger.trace("$sender($senderId: $groupId >>> $messageId: $json")
|
||||
|
||||
if (message.images.isNotEmpty()) {
|
||||
message.images.forEach {
|
||||
val payload = NaiLongDetectPayload(it.file).toJson()
|
||||
val result = Http.post<NaiLongDetectResponse>(configManager.naiLongApiUrl, payload)
|
||||
logger.info("奶龙识别结果: ${result.result}")
|
||||
if (result.result) {
|
||||
message.reply("本群禁止发奶龙!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (message.message.any { it.type == ArrayMessageType.face && it.data.id.toString() == "419" }) {
|
||||
message.reply("你发牛魔的火车呢, 我直接就是打断")
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ data class Config(
|
||||
val apiRtastKey: String,
|
||||
val azureAppClientId: String,
|
||||
val youtubeDataApiKey: String,
|
||||
val naiLongApiUrl: String,
|
||||
) {
|
||||
data class Database(
|
||||
val type: DatabaseType,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/10/26
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.entity.nailong
|
||||
|
||||
data class NaiLongDetectPayload(val url: String)
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright © 2024 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 2024/10/26
|
||||
*/
|
||||
|
||||
|
||||
package cn.rtast.fancybot.entity.nailong
|
||||
|
||||
data class NaiLongDetectResponse(val result: Boolean)
|
||||
@@ -50,4 +50,5 @@ class ConfigManager : JsonFileHandler<Config>("config.json") {
|
||||
val azureAppClientId = config.azureAppClientId
|
||||
val youtubeDataApiKey = config.youtubeDataApiKey
|
||||
val dbConfig = config.database
|
||||
val naiLongApiUrl = config.naiLongApiUrl
|
||||
}
|
||||
Reference in New Issue
Block a user