feat: add sensitive word filter
This commit is contained in:
2 files changed
+24
No files matched your search
@@ -75,6 +75,10 @@ class FancyBot : OneBotListener {
|
|||||||
logger.info("$sender($senderId: $groupId >>> $messageId): $msg")
|
logger.info("$sender($senderId: $groupId >>> $messageId): $msg")
|
||||||
logger.trace("$sender($senderId: $groupId >>> $messageId: $json")
|
logger.trace("$sender($senderId: $groupId >>> $messageId: $json")
|
||||||
|
|
||||||
|
if (SensitiveWord.containsSensitiveWords(message.text)) {
|
||||||
|
message.reply("你似乎说了一个不能说的词(?)")
|
||||||
|
}
|
||||||
|
|
||||||
if (message.message.any { it.type == ArrayMessageType.face && it.data.id.toString() == "419" }) {
|
if (message.message.any { it.type == ArrayMessageType.face && it.data.id.toString() == "419" }) {
|
||||||
message.reply("你发牛魔的火车呢, 我直接就是打断")
|
message.reply("你发牛魔的火车呢, 我直接就是打断")
|
||||||
}
|
}
|
||||||
@@ -276,4 +280,5 @@ suspend fun main() {
|
|||||||
initSetuIndex()
|
initSetuIndex()
|
||||||
initItems()
|
initItems()
|
||||||
initBackgroundTasks(instance)
|
initBackgroundTasks(instance)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2024 RTAkland
|
||||||
|
* Author: RTAkland
|
||||||
|
* Date: 2024/11/7
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package cn.rtast.fancybot.util
|
||||||
|
|
||||||
|
import cn.rtast.fancybot.util.str.proxy
|
||||||
|
|
||||||
|
object SensitiveWord {
|
||||||
|
private val SENSITIVE_WORD_URL =
|
||||||
|
"https://raw.githubusercontent.com/cjh0613/tencent-sensitive-words/refs/heads/main/sensitive_words.txt".proxy
|
||||||
|
private const val SEPARATOR = "、"
|
||||||
|
private val sensitiveWords = Http.get(SENSITIVE_WORD_URL).split(SEPARATOR)
|
||||||
|
|
||||||
|
fun containsSensitiveWords(input: String): Boolean = sensitiveWords.contains(input)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user