MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / audit

Method audit

plugin/baiduaudit/model.go:27–76  ·  view source on GitHub ↗

禁言检测

(ctx *zero.Ctx, configpath string)

Source from the content-addressed store, hash-verified

25
26// 禁言检测
27func (bdres *baiduRes) audit(ctx *zero.Ctx, configpath string) {
28 bdres.mu.Lock()
29 defer bdres.mu.Unlock()
30 // 如果返回类型为2(不合规), 0为合规, 3为疑似
31 if bdres.ConclusionType != 2 {
32 return
33 }
34 // 获取群配置
35 group := config.groupof(ctx.Event.GroupID)
36 // 检测群配置里的不检测类型白名单, 忽略掉不检测的违规类型
37 for i, b := range group.copyWhiteListType() {
38 if i == bdres.Data[0].SubType && b {
39 return
40 }
41 }
42 // 生成回复文本
43 res := group.reply(bdres)
44 // 撤回消息
45 ctx.DeleteMessage(ctx.Event.MessageID)
46 // 查看是否启用撤回后禁言
47 if group.DMBAN {
48 // 从历史违规记录中获取指定用户
49 user := group.historyof(ctx.Event.UserID)
50 // 用户违规次数自增
51 atomic.AddInt64(&user.Count, 1)
52 user.mu.Lock()
53 // 用户违规原因记录
54 user.ResList = append(user.ResList, bdres)
55 user.mu.Unlock()
56 // 保存到json
57 err := config.saveto(configpath)
58 if err != nil {
59 ctx.SendChain(message.Text("ERROR: ", err))
60 }
61 var bantime int64
62 // 查看是否开启禁言累加功能, 并计算禁言时间
63 if group.BANTimeAddEnable {
64 bantime = atomic.LoadInt64(&user.Count) * group.BANTimeAddTime * 60
65 } else {
66 bantime = group.BANTime * 60
67 }
68 // 执行禁言
69 ctx.SetThisGroupBan(ctx.Event.UserID, bantime)
70 }
71 // 查看是否开启撤回提示
72 if group.DMRemind {
73 res = append(res, message.At(ctx.Event.Sender.ID))
74 ctx.Send(res)
75 }
76}
77
78type auditData struct {
79 // Type int `json:"type"` // 审核主类型, 11:百度官方违禁词库、12:文本反作弊、13:自定义文本黑名单、14:自定义文本白名单

Callers 1

initFunction · 0.95

Calls 5

groupofMethod · 0.80
copyWhiteListTypeMethod · 0.80
replyMethod · 0.80
historyofMethod · 0.80
savetoMethod · 0.80

Tested by

no test coverage detected