mirror of
https://github.com/wonli/aqi.git
synced 2025-09-26 20:51:23 +08:00
34 lines
530 B
Go
34 lines
530 B
Go
package sensitive
|
|
|
|
import (
|
|
"strings"
|
|
"sync"
|
|
|
|
"github.com/importcjj/sensitive"
|
|
)
|
|
|
|
var Entity *sensitive.Filter
|
|
var sensitiveOnce sync.Once
|
|
|
|
func Init() {
|
|
sensitiveOnce.Do(func() {
|
|
Entity = sensitive.New()
|
|
dd, err := Words.ReadDir("words")
|
|
if err != nil {
|
|
return
|
|
}
|
|
for _, v := range dd {
|
|
data, err := Words.ReadFile("words/" + v.Name())
|
|
if err != nil {
|
|
continue
|
|
}
|
|
|
|
Entity.AddWord(strings.Split(string(data), "\n")...)
|
|
}
|
|
})
|
|
}
|
|
|
|
func Replace(msg string) string {
|
|
return Entity.Replace(msg, '*')
|
|
}
|