dirty
parent
8c8a544997
commit
dd7e9f5440
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @Author: jager
|
||||
* @Email: lhj168os@gmail.com
|
||||
* @File: dirty
|
||||
* @Date: 2022/1/18 11:07 上午
|
||||
* @package: dirty
|
||||
* @Version: v1.0.0
|
||||
*
|
||||
* @Description:
|
||||
*
|
||||
*/
|
||||
|
||||
package dirty
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jageros/hawox/httpx"
|
||||
"github.com/jageros/hawox/sensitive"
|
||||
"idata/internal/apity"
|
||||
"idata/internal/service/user"
|
||||
)
|
||||
|
||||
var filter *sensitive.Filter
|
||||
|
||||
func InitDirtyWord(path string) error {
|
||||
filter = sensitive.New()
|
||||
return filter.LoadWordDict(path)
|
||||
}
|
||||
|
||||
func IsDirtyWord(ctx *gin.Context) {
|
||||
if !user.Auth(ctx, apity.Dirty) {
|
||||
return
|
||||
}
|
||||
word, ok := httpx.DecodeUrlVal(ctx, "word")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
dirty, w := filter.Validate(word)
|
||||
httpx.PkgMsgWrite(ctx, map[string]interface{}{"dirty": !dirty, "dirty_word": w})
|
||||
}
|
Loading…
Reference in New Issue