chore: remove bad word filter command
This commit is contained in:
3 files changed
+2
-41
No files matched your search
@@ -24,7 +24,6 @@ import cn.rtast.fancybot.commands.parse.BVParseCommand
|
|||||||
import cn.rtast.fancybot.commands.parse.GitHubParseCommand
|
import cn.rtast.fancybot.commands.parse.GitHubParseCommand
|
||||||
import cn.rtast.fancybot.commands.parse.ImageURLCommand
|
import cn.rtast.fancybot.commands.parse.ImageURLCommand
|
||||||
import cn.rtast.fancybot.commands.parse.ReverseGIFCommand
|
import cn.rtast.fancybot.commands.parse.ReverseGIFCommand
|
||||||
import cn.rtast.fancybot.commands.parse.filterBadWord
|
|
||||||
import cn.rtast.fancybot.commands.record.JiJianCommand
|
import cn.rtast.fancybot.commands.record.JiJianCommand
|
||||||
import cn.rtast.fancybot.commands.record.JrrpCommand
|
import cn.rtast.fancybot.commands.record.JrrpCommand
|
||||||
import cn.rtast.fancybot.commands.record.MyNiuziCommand
|
import cn.rtast.fancybot.commands.record.MyNiuziCommand
|
||||||
@@ -37,7 +36,6 @@ import cn.rtast.fancybot.entity.enums.WSType
|
|||||||
import cn.rtast.fancybot.items.BaisiItem
|
import cn.rtast.fancybot.items.BaisiItem
|
||||||
import cn.rtast.fancybot.items.HeisiItem
|
import cn.rtast.fancybot.items.HeisiItem
|
||||||
import cn.rtast.fancybot.items.SetuItem
|
import cn.rtast.fancybot.items.SetuItem
|
||||||
import cn.rtast.fancybot.util.file.BadWordManager
|
|
||||||
import cn.rtast.fancybot.util.file.ConfigManager
|
import cn.rtast.fancybot.util.file.ConfigManager
|
||||||
import cn.rtast.fancybot.util.file.NiuziManager
|
import cn.rtast.fancybot.util.file.NiuziManager
|
||||||
import cn.rtast.fancybot.util.file.SignManager
|
import cn.rtast.fancybot.util.file.SignManager
|
||||||
@@ -62,9 +60,8 @@ class FancyBot : OneBotListener {
|
|||||||
val senderId = message.sender.userId
|
val senderId = message.sender.userId
|
||||||
val msg = message.rawMessage
|
val msg = message.rawMessage
|
||||||
val groupId = message.groupId
|
val groupId = message.groupId
|
||||||
println("$sender($senderId: $groupId): $msg")
|
val messageId = message.messageId
|
||||||
|
println("$sender($senderId: $groupId >>> $messageId): $msg")
|
||||||
filterBadWord(message)
|
|
||||||
|
|
||||||
if (message.rawMessage.startsWith("https://github.com/") || message.rawMessage.startsWith("git@github.com:")) {
|
if (message.rawMessage.startsWith("https://github.com/") || message.rawMessage.startsWith("git@github.com:")) {
|
||||||
GitHubParseCommand.parse(this, message)
|
GitHubParseCommand.parse(this, message)
|
||||||
@@ -147,7 +144,6 @@ val configManager = ConfigManager()
|
|||||||
val itemManager = ItemManager()
|
val itemManager = ItemManager()
|
||||||
val signManager = SignManager()
|
val signManager = SignManager()
|
||||||
val niuziManager = NiuziManager()
|
val niuziManager = NiuziManager()
|
||||||
val badWordManager = BadWordManager()
|
|
||||||
|
|
||||||
val items = listOf(
|
val items = listOf(
|
||||||
HeisiItem(),
|
HeisiItem(),
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2024 RTAkland
|
|
||||||
* Author: RTAkland
|
|
||||||
* Date: 2024/9/18
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package cn.rtast.fancybot.commands.parse
|
|
||||||
|
|
||||||
import cn.rtast.fancybot.badWordManager
|
|
||||||
import cn.rtast.rob.entity.GroupMessage
|
|
||||||
|
|
||||||
suspend fun filterBadWord(message: GroupMessage) {
|
|
||||||
if (badWordManager.contain(message.rawMessage)) {
|
|
||||||
message.reply("你不许说脏话")
|
|
||||||
message.revoke()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright © 2024 RTAkland
|
|
||||||
* Author: RTAkland
|
|
||||||
* Date: 2024/9/18
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package cn.rtast.fancybot.util.file
|
|
||||||
|
|
||||||
import cn.rtast.fancybot.util.JsonFileHandler
|
|
||||||
|
|
||||||
class BadWordManager : JsonFileHandler<List<String>>("bd.json", listOf<String>()) {
|
|
||||||
|
|
||||||
fun contain(word: String): Boolean {
|
|
||||||
return this.read<List<String>>().any { word.contains(it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user