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

32 lines
1.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 store
import "io"
type (
Store interface {
// LoadDictPath 从指定的本地路径加载词库文件(可传多个路径)
LoadDictPath(path ...string) error
// LoadDictEmbed (推荐)加载嵌入式词库内容(如 go:embed 提供的字符串)
LoadDictEmbed(contents ...string) error
// LoadDictHttp 从远程 URL 加载词库内容(支持多个 URL
LoadDictHttp(url ...string) error
// LoadDict 从 io.Reader 加载词库内容(按行读取)
LoadDict(reader io.Reader) error
// ReadChan 返回一个通道,逐个输出当前存储中的所有敏感词(可用于异步加载到过滤器)
ReadChan() <-chan string
// ReadString 以字符串数组形式返回当前所有敏感词
ReadString() []string
// GetAddChan 获取新增敏感词的事件通道(用于实时监听词库变更)
GetAddChan() <-chan string
// GetDelChan 获取删除敏感词的事件通道(用于实时监听词库变更)
GetDelChan() <-chan string
// AddWord 添加一个或多个敏感词
AddWord(words ...string) error
// DelWord 删除一个或多个敏感词
DelWord(words ...string) error
}
)
// 接口实现验证
var _ Store = (*MemoryModel)(nil)