MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin-Playground / init

Function init

plugin/qqclean/qqclean.go:14–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12)
13
14func init() {
15 engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
16 DisableOnDefault: false,
17 Brief: "qq号清理",
18 Help: "清理群聊@bot (清理bot不是管理员的群)\n(当群聊数小于20时自动同意加群)\n清理好友@bot (清理bot 5级以下的好友)\n(自动同意好友邀请)",
19 })
20 engine.OnFullMatch("清理群聊", zero.SuperUserPermission, zero.OnlyToMe).SetBlock(true).Handle(func(ctx *zero.Ctx) {
21 cleanGroupnameList := make([]string, 0, 64)
22 ctx.GetGroupList().ForEach(func(_, value gjson.Result) bool {
23 if ctx.GetGroupMemberInfo(value.Get("group_id").Int(), ctx.Event.SelfID, true).Get("role").String() == "member" {
24 cleanGroupnameList = append(cleanGroupnameList, value.Get("group_name").String())
25 ctx.SetGroupLeave(value.Get("group_id").Int(), false)
26 }
27 return true
28 })
29 ctx.SendPrivateMessage(ctx.Event.UserID, message.Text("已清理bot群聊: (", strings.Join(cleanGroupnameList, ", "), ")"))
30 })
31 engine.OnFullMatch("清理好友", zero.SuperUserPermission, zero.OnlyToMe).SetBlock(true).Handle(func(ctx *zero.Ctx) {
32 cleanFriendnameList := make([]string, 0, 64)
33 ctx.GetFriendList().ForEach(func(_, value gjson.Result) bool {
34 if ctx.GetStrangerInfo(value.Get("user_id").Int(), true).Get("level").Int() <= 5 {
35 ctx.CallAction("delete_friend", zero.Params{
36 "friend_id": value.Get("user_id").Int(),
37 })
38 cleanFriendnameList = append(cleanFriendnameList, value.Get("nickname").String())
39 }
40 return true
41 })
42 ctx.SendPrivateMessage(ctx.Event.UserID, message.Text("已清理bot好友: (", strings.Join(cleanFriendnameList, ", "), ")"))
43 })
44 // 清理群聊低等级
45 // go func() {
46 // time.Sleep(5 * time.Second)
47 // zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
48 // gid := int64(1048452984)
49 // list := ctx.GetGroupMemberList(gid)
50 // qqInfoURL := "https://api.kit9.cn/api/qq_material/api.php?qq=%v"
51 // fmt.Println(list)
52 // for i, v := range list.Array() {
53 // time.Sleep(100 * time.Millisecond)
54 // uid := v.Get("user_id").Int()
55 // data, err := web.GetData(fmt.Sprintf(qqInfoURL, uid))
56 // if err != nil {
57 // fmt.Println(err)
58 // }
59 // level := gjson.ParseBytes(data).Get("data.level").Int()
60 // if level <= 3 {
61 // ctx.SetGroupKick(gid, uid, false)
62 // }
63 // fmt.Printf("%v. %v, %v\n", i, v.Get("nickname").String(), level)
64 // }
65 // return true
66 // })
67 // }()
68}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected