You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
762 B
Go
41 lines
762 B
Go
/**
|
|
* @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})
|
|
}
|