feat: 增加敏感词功能 (#204)

This commit is contained in:
二丫讲梵
2023-04-13 22:03:30 +08:00
committed by GitHub
parent 1b9edc5e63
commit add42dd774
7 changed files with 59 additions and 0 deletions

View File

@@ -146,6 +146,9 @@ func Do(mode string, rmsg *dingbot.ReceiveMsg) error {
logger.Error("往MySQL新增数据失败,错误信息:", err)
}
logger.Info(fmt.Sprintf("🤖 %s得到的答案: %#v", rmsg.SenderNick, reply))
if public.JudgeSensitiveWord(reply) {
reply = public.SolveSensitiveWord(reply)
}
// 回复@我的用户
_, err = rmsg.ReplyToDingtalk(string(dingbot.TEXT), reply)
if err != nil {
@@ -204,6 +207,9 @@ func Do(mode string, rmsg *dingbot.ReceiveMsg) error {
// 将当前回答的ID放入缓存
public.UserService.SetAnswerID(rmsg.SenderNick, rmsg.GetChatTitle(), aid)
logger.Info(fmt.Sprintf("🤖 %s得到的答案: %#v", rmsg.SenderNick, reply))
if public.JudgeSensitiveWord(reply) {
reply = public.SolveSensitiveWord(reply)
}
// 回复@我的用户
_, err = rmsg.ReplyToDingtalk(string(dingbot.TEXT), reply)
if err != nil {