Files
bl/common/utils/go-sensitive-word-1.3.3/options.go
昔念 685069fded feat(cool): 添加敏感词过滤功能
- 引入 go-sensitive-word 敏感词过滤库
- 在全局初始化中加载敏感词库并配置过滤器
- 在创建玩家时应用敏感词过滤,替换不合适的昵称内容
2025-09-09 01:11:10 +08:00

70 lines
2.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package go_sensitive_word
import _ "embed"
// StoreMemory 类型常量定义
// 当前仅支持内存存储StoreMemory后续可扩展为 Redis、文件存储等。
const (
StoreMemory = iota // 内存模式词库(默认)
)
// FilterDfa 类型常量定义
// 当前仅支持 DFA 算法FilterDfa后续可支持 Trie、AC自动机、正则等。
const (
FilterDfa = iota // DFA 敏感词过滤算法(默认)
)
// StoreOption 定义了词库存储的配置选项
// Type 字段用于指定词库的存储实现方式如内存、Redis、文件等。
type StoreOption struct {
Type uint32 // 存储类型标识,例如 StoreMemory
}
// FilterOption 定义了敏感词过滤器的配置选项
// Type 字段用于指定过滤算法的实现方式,如 DFA、Trie、正则等。
type FilterOption struct {
Type uint32 // 过滤器类型标识,例如 FilterDfa
}
// 内置敏感词词库(通过 go:embed 嵌入编译时)
// 这些变量可直接用于调用 LoadDictEmbed 加载内置词库内容,无需读取本地文件。
// 可按需选择加载不同类别的敏感词,例如政治类、暴恐类、色情类、贪腐类等。
//
// 使用示例:
//
// err := manager.LoadDictEmbed(DictCovid19, DictPornography)
var (
//go:embed text/COVID-19词库.txt
DictCovid19 string
//go:embed text/GFW补充词库.txt
DictGFWAdditional string
//go:embed text/其他词库.txt
DictOther string
//go:embed text/反动词库.txt
DictReactionary string
//go:embed text/广告类型.txt
DictAdvertisement string
//go:embed text/政治类型.txt
DictPolitical string
//go:embed text/暴恐词库.txt
DictViolence string
//go:embed text/民生词库.txt
DictPeopleLife string
//go:embed text/涉枪涉爆.txt
DictGunExplosion string
//go:embed text/网易前端过滤敏感词库.txt
DictNeteaseFE string
//go:embed text/色情类型.txt
DictSexual string
//go:embed text/色情词库.txt
DictPornography string
//go:embed text/补充词库.txt
DictAdditional string
//go:embed text/贪腐词库.txt
DictCorruption string
//go:embed text/零时-Tencent.txt
DictTemporaryTencent string
//go:embed text/非法网址.txt
DictIllegalURL string
)