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

Function init

plugin/baiduaudit/audit.go:36–278  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34)
35
36func init() {
37 engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
38 DisableOnDefault: false,
39 Brief: "百度内容审核",
40 Help: "##该功能来自百度内容审核, 需购买相关服务, 并创建app##\n" +
41 "- 获取BDAKey\n" +
42 "- 配置BDAKey [API key] [Secret Key]\n" +
43 "- 开启/关闭内容审核\n" +
44 "- 开启/关闭撤回提示\n" +
45 "- 开启/关闭详细提示\n" +
46 "- 开启/关闭撤回禁言\n" +
47 "##禁言时间设置## 禁言时间计算方式为:禁言次数*每次禁言累加时间,当达到最大禁言时间时, 再次触发按最大禁言时间计算\n" +
48 "- 开启/关闭禁言累加\n" +
49 "- 设置撤回禁言时间[分钟, 默认:1]\n" +
50 "- 设置最大禁言时间[分钟, 默认:60,最大43200]\n" +
51 "- 设置每次累加时间[分钟, 默认:1]\n" +
52 "##检测类型设置## 类型编号列表:[1:违禁违规、2:文本色情、3:敏感信息、4:恶意推广、5:低俗辱骂 6:恶意推广-联系方式、7:恶意推广-软文推广]\n" +
53 "- 查看检测类型\n" +
54 "- 查看检测配置\n" +
55 "- 设置检测类型[类型编号]\n" +
56 "- 设置不检测类型[类型编号]\n" +
57 "- 开启/关闭文本检测\n" +
58 "- 开启/关闭图像检测\n" +
59 "##测试功能##\n" +
60 "- ^文本检测[文本内容]\n" +
61 "- ^图像检测[图片]\n",
62 PrivateDataFolder: "baiduaudit",
63 })
64
65 configpath := engine.DataFolder() + "config.json"
66 err := config.load(configpath)
67 if err != nil {
68 logrus.Warnln("[baiduaudit] 加载配置错误:", err)
69 } else if config.Key1 != "" && config.Key2 != "" {
70 bdcli = censor.NewClient(config.Key1, config.Key2)
71 }
72
73 engine.OnFullMatch("获取BDAKey", zero.SuperUserPermission).SetBlock(true).
74 Handle(func(ctx *zero.Ctx) {
75 ctx.SendChain(message.Text("接口key创建网址:\n" +
76 "https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/index\n" +
77 "免费8w次数领取地址:\n" +
78 "https://console.bce.baidu.com/ai/?_=1665977657185#/ai/antiporn/overview/resource/getFree"))
79 })
80
81 engine.OnRegex("^查看检测(类型|配置)$", zero.AdminPermission, hasinit).SetBlock(true).
82 Handle(func(ctx *zero.Ctx) {
83 // 获取群配置
84 group := config.groupof(ctx.Event.GroupID)
85 msg := ""
86 k1 := ctx.State["regex_matched"].([]string)[1]
87 if k1 == "类型" {
88 sb := strings.Builder{}
89 sb.WriteString("本群检测类型:")
90 found := false
91 // 遍历群检测类型名单
92 for i, v := range group.copyWhiteListType() {
93 if !v {

Callers

nothing calls this directly

Calls 12

auditMethod · 0.95
markTypeAlias · 0.85
parse2BaiduResFunction · 0.85
loadMethod · 0.80
groupofMethod · 0.80
copyWhiteListTypeMethod · 0.80
setWhiteListTypeMethod · 0.80
savetoMethod · 0.80
setMethod · 0.80
setkeyMethod · 0.80
replyMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected