mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 14:30:10 +08:00
✨ 增加入群验证
This commit is contained in:
parent
f0fd1eaf22
commit
60c29b2d12
10
README.md
10
README.md
@ -45,12 +45,14 @@
|
|||||||
- [x] 退出群聊[群号]
|
- [x] 退出群聊[群号]
|
||||||
- [x] *入群欢迎
|
- [x] *入群欢迎
|
||||||
- [x] *退群通知
|
- [x] *退群通知
|
||||||
- [x] 在[月份]月[日期]日的[小时]点[分钟]分时(用[url])提醒大家[消息]
|
- [x] 设置欢迎语[欢迎~]
|
||||||
- [x] 在[月份]月[每周or周几]的[小时]点[分钟]分时(用[url])提醒大家[消息]
|
- [x] 在MM月dd日的hh点mm分时(用http://url)提醒大家xxx
|
||||||
- [x] 取消在[月份]月[日期]日的[小时]点[分钟]分的提醒
|
- [x] 在MM月[每周|周几]的hh点mm分时(用http://url)提醒大家xxx
|
||||||
- [x] 取消在[月份]月[每周or周几]的[小时]点[分钟]分的提醒
|
- [x] 取消在MM月dd日的hh点mm分的提醒
|
||||||
|
- [x] 取消在MM月[每周|周几]的hh点mm分的提醒
|
||||||
- [x] 列出所有提醒
|
- [x] 列出所有提醒
|
||||||
- [x] 翻牌
|
- [x] 翻牌
|
||||||
|
- [x] [开启|关闭]入群验证
|
||||||
- [ ] 同意入群请求
|
- [ ] 同意入群请求
|
||||||
- [ ] 同意好友请求
|
- [ ] 同意好友请求
|
||||||
- [ ] 撤回[@xxx] [xxx]
|
- [ ] 撤回[@xxx] [xxx]
|
||||||
|
|||||||
2
main.go
2
main.go
@ -60,7 +60,7 @@ func init() {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Print(
|
fmt.Print(
|
||||||
"======================[ZeroBot-Plugin]======================",
|
"\n======================[ZeroBot-Plugin]======================",
|
||||||
"\n", banner, "\n",
|
"\n", banner, "\n",
|
||||||
"============================================================\n",
|
"============================================================\n",
|
||||||
) // 启动打印
|
) // 启动打印
|
||||||
|
|||||||
@ -3,7 +3,9 @@ package manager
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -14,27 +16,44 @@ import (
|
|||||||
timer "github.com/FloatTech/ZeroBot-Plugin-Timer"
|
timer "github.com/FloatTech/ZeroBot-Plugin-Timer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
datapath = "data/manager/"
|
||||||
|
confile = datapath + "config.pb"
|
||||||
|
hint = "====群管====\n" +
|
||||||
|
"- 禁言@QQ 1分钟\n" +
|
||||||
|
"- 解除禁言 @QQ\n" +
|
||||||
|
"- 我要自闭 1分钟\n" +
|
||||||
|
"- 开启全员禁言\n" +
|
||||||
|
"- 解除全员禁言\n" +
|
||||||
|
"- 升为管理@QQ\n" +
|
||||||
|
"- 取消管理@QQ\n" +
|
||||||
|
"- 修改名片@QQ XXX\n" +
|
||||||
|
"- 修改头衔@QQ XXX\n" +
|
||||||
|
"- 申请头衔 XXX\n" +
|
||||||
|
"- 踢出群聊@QQ\n" +
|
||||||
|
"- 退出群聊 1234\n" +
|
||||||
|
"- 群聊转发 1234 XXX\n" +
|
||||||
|
"- 私聊转发 0000 XXX\n" +
|
||||||
|
"- 在MM月dd日的hh点mm分时(用http://url)提醒大家XXX\n" +
|
||||||
|
"- 在MM月[每周|周几]的hh点mm分时(用http://url)提醒大家XXX\n" +
|
||||||
|
"- 取消在MM月dd日的hh点mm分的提醒\n" +
|
||||||
|
"- 取消在MM月[每周|周几]的hh点mm分的提醒\n" +
|
||||||
|
"- 列出所有提醒\n" +
|
||||||
|
"- 翻牌\n" +
|
||||||
|
"- 设置欢迎语XXX\n" +
|
||||||
|
"- [开启|关闭]入群验证"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
config Config
|
||||||
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
|
loadConfig()
|
||||||
// 菜单
|
// 菜单
|
||||||
zero.OnFullMatch("群管系统", zero.AdminPermission).SetBlock(true).FirstPriority().
|
zero.OnFullMatch("群管系统", zero.AdminPermission).SetBlock(true).FirstPriority().
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.SendChain(message.Text(
|
ctx.Send(hint)
|
||||||
"====群管====", "\n",
|
|
||||||
"- 禁言@QQ 1分钟", "\n",
|
|
||||||
"- 解除禁言 @QQ", "\n",
|
|
||||||
"- 我要自闭 1分钟", "\n",
|
|
||||||
"- 开启全员禁言", "\n",
|
|
||||||
"- 解除全员禁言", "\n",
|
|
||||||
"- 升为管理@QQ", "\n",
|
|
||||||
"- 取消管理@QQ", "\n",
|
|
||||||
"- 修改名片@QQ XXX", "\n",
|
|
||||||
"- 修改头衔@QQ XXX", "\n",
|
|
||||||
"- 申请头衔 XXX", "\n",
|
|
||||||
"- 踢出群聊@QQ", "\n",
|
|
||||||
"- 退出群聊 1234", "\n",
|
|
||||||
"- 群聊转发 1234 XXX", "\n",
|
|
||||||
"- 私聊转发 0000 XXX",
|
|
||||||
))
|
|
||||||
})
|
})
|
||||||
// 升为管理
|
// 升为管理
|
||||||
zero.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
zero.OnRegex(`^升为管理.*?(\d+)`, zero.OnlyGroup, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
||||||
@ -222,7 +241,7 @@ func init() { // 插件主体
|
|||||||
ctx.SendChain(message.Text("📧 --> " + ctx.State["regex_matched"].([]string)[1]))
|
ctx.SendChain(message.Text("📧 --> " + ctx.State["regex_matched"].([]string)[1]))
|
||||||
})
|
})
|
||||||
// 定时提醒
|
// 定时提醒
|
||||||
zero.OnRegex(`^在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分时(用.+)?提醒大家(.*)`, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
zero.OnRegex(`^在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分时(用.+)?提醒大家(.*)`, zero.AdminPermission).SetBlock(true).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if ctx.Event.GroupID > 0 {
|
||||||
dateStrs := ctx.State["regex_matched"].([]string)
|
dateStrs := ctx.State["regex_matched"].([]string)
|
||||||
@ -237,7 +256,7 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 取消定时
|
// 取消定时
|
||||||
zero.OnRegex(`^取消在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分的提醒`, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
zero.OnRegex(`^取消在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分的提醒`, zero.AdminPermission).SetBlock(true).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if ctx.Event.GroupID > 0 {
|
||||||
dateStrs := ctx.State["regex_matched"].([]string)
|
dateStrs := ctx.State["regex_matched"].([]string)
|
||||||
@ -256,7 +275,7 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 列出本群所有定时
|
// 列出本群所有定时
|
||||||
zero.OnFullMatch("列出所有提醒", zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
zero.OnFullMatch("列出所有提醒", zero.AdminPermission).SetBlock(true).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if ctx.Event.GroupID > 0 {
|
||||||
ctx.Send(fmt.Sprint(timer.ListTimers(uint64(ctx.Event.GroupID))))
|
ctx.Send(fmt.Sprint(timer.ListTimers(uint64(ctx.Event.GroupID))))
|
||||||
@ -277,10 +296,52 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 入群欢迎
|
// 入群欢迎
|
||||||
zero.OnNotice().SetBlock(false).SetPriority(40).
|
zero.OnNotice().SetBlock(false).FirstPriority().
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.NoticeType == "group_increase" {
|
if ctx.Event.NoticeType == "group_increase" {
|
||||||
ctx.SendChain(message.Text("欢迎~"))
|
word, ok := config.Welcome[uint64(ctx.Event.GroupID)]
|
||||||
|
if ok {
|
||||||
|
ctx.Send(word)
|
||||||
|
} else {
|
||||||
|
ctx.Send("欢迎~")
|
||||||
|
}
|
||||||
|
enable, ok1 := config.Checkin[uint64(ctx.Event.GroupID)]
|
||||||
|
if ok1 && enable {
|
||||||
|
uid := ctx.Event.UserID
|
||||||
|
a := rand.Intn(100)
|
||||||
|
b := rand.Intn(100)
|
||||||
|
r := a + b
|
||||||
|
ctx.SendChain(message.At(uid), message.Text(fmt.Sprintf("考你一道题:%d+%d=?\n如果60秒之内答不上来,%s就要把你踢出去了哦~", a, b, zero.BotConfig.NickName[0])))
|
||||||
|
// 匹配发送者进行验证
|
||||||
|
rule := func(ctx *zero.Ctx) bool {
|
||||||
|
for _, elem := range ctx.Event.Message {
|
||||||
|
if elem.Type == "text" {
|
||||||
|
text := strings.ReplaceAll(elem.Data["text"], " ", "")
|
||||||
|
ans, err := strconv.Atoi(text)
|
||||||
|
if err == nil {
|
||||||
|
if ans != r {
|
||||||
|
ctx.Send("答案不对哦,再想想吧~")
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
next := zero.NewFutureEvent("message", 999, false, zero.CheckUser(ctx.Event.UserID), rule)
|
||||||
|
recv, cancel := next.Repeat()
|
||||||
|
select {
|
||||||
|
case <-time.After(time.Minute):
|
||||||
|
ctx.Send("拜拜啦~")
|
||||||
|
ctx.SetGroupKick(ctx.Event.GroupID, uid, false)
|
||||||
|
cancel()
|
||||||
|
case <-recv:
|
||||||
|
cancel()
|
||||||
|
ctx.Send("答对啦~")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 退群提醒
|
// 退群提醒
|
||||||
@ -290,6 +351,34 @@ func init() { // 插件主体
|
|||||||
ctx.SendChain(message.Text("有人跑路了~"))
|
ctx.SendChain(message.Text("有人跑路了~"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 设置欢迎语
|
||||||
|
zero.OnRegex(`^设置欢迎语(.*)$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
config.Welcome[uint64(ctx.Event.GroupID)] = ctx.State["regex_matched"].([]string)[1]
|
||||||
|
if saveConfig() == nil {
|
||||||
|
ctx.Send("记住啦!")
|
||||||
|
} else {
|
||||||
|
ctx.Send("出错啦!")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 入群验证开关
|
||||||
|
zero.OnRegex(`^(.*)入群验证$`, zero.OnlyGroup, zero.AdminPermission).SetBlock(true).SetPriority(40).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
option := ctx.State["regex_matched"].([]string)[1]
|
||||||
|
switch option {
|
||||||
|
case "开启":
|
||||||
|
config.Checkin[uint64(ctx.Event.GroupID)] = true
|
||||||
|
case "关闭":
|
||||||
|
config.Checkin[uint64(ctx.Event.GroupID)] = false
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if saveConfig() == nil {
|
||||||
|
ctx.Send("已" + option)
|
||||||
|
} else {
|
||||||
|
ctx.Send("出错啦!")
|
||||||
|
}
|
||||||
|
})
|
||||||
// 运行 CQ 码
|
// 运行 CQ 码
|
||||||
zero.OnRegex(`^run(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(0).
|
zero.OnRegex(`^run(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(0).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
@ -304,3 +393,43 @@ func strToInt(str string) int64 {
|
|||||||
val, _ := strconv.ParseInt(str, 10, 64)
|
val, _ := strconv.ParseInt(str, 10, 64)
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadConfig() {
|
||||||
|
mkdirerr := os.MkdirAll(datapath, 0755)
|
||||||
|
if mkdirerr == nil {
|
||||||
|
if _, err := os.Stat(confile); err == nil || os.IsExist(err) {
|
||||||
|
f, err := os.Open(confile)
|
||||||
|
if err == nil {
|
||||||
|
data, err1 := io.ReadAll(f)
|
||||||
|
if err1 == nil {
|
||||||
|
if len(data) > 0 {
|
||||||
|
config.Unmarshal(data)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
config.Checkin = make(map[uint64]bool)
|
||||||
|
config.Welcome = make(map[uint64]string)
|
||||||
|
} else {
|
||||||
|
panic(mkdirerr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func saveConfig() error {
|
||||||
|
data, err := config.Marshal()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if _, err := os.Stat(datapath); err == nil || os.IsExist(err) {
|
||||||
|
f, err1 := os.OpenFile(confile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
||||||
|
if err1 != nil {
|
||||||
|
return err1
|
||||||
|
} else {
|
||||||
|
defer f.Close()
|
||||||
|
_, err2 := f.Write(data)
|
||||||
|
return err2
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
561
plugin_manager/manager.pb.go
Normal file
561
plugin_manager/manager.pb.go
Normal file
@ -0,0 +1,561 @@
|
|||||||
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
|
// source: manager.proto
|
||||||
|
|
||||||
|
package manager
|
||||||
|
|
||||||
|
import (
|
||||||
|
fmt "fmt"
|
||||||
|
proto "github.com/golang/protobuf/proto"
|
||||||
|
io "io"
|
||||||
|
math "math"
|
||||||
|
math_bits "math/bits"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Checkin map[uint64]bool `protobuf:"bytes,1,rep,name=checkin,proto3" json:"checkin,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||||
|
Welcome map[uint64]string `protobuf:"bytes,2,rep,name=welcome,proto3" json:"welcome,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Config) Reset() { *m = Config{} }
|
||||||
|
func (m *Config) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Config) ProtoMessage() {}
|
||||||
|
func (*Config) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_cde9ec64f0d2c859, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Config) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_Config.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (m *Config) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Config.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *Config) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *Config) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Config.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Config proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *Config) GetCheckin() map[uint64]bool {
|
||||||
|
if m != nil {
|
||||||
|
return m.Checkin
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Config) GetWelcome() map[uint64]string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Welcome
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*Config)(nil), "manager.config")
|
||||||
|
proto.RegisterMapType((map[uint64]bool)(nil), "manager.config.CheckinEntry")
|
||||||
|
proto.RegisterMapType((map[uint64]string)(nil), "manager.config.WelcomeEntry")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("manager.proto", fileDescriptor_cde9ec64f0d2c859) }
|
||||||
|
|
||||||
|
var fileDescriptor_cde9ec64f0d2c859 = []byte{
|
||||||
|
// 186 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcd, 0x4d, 0xcc, 0x4b,
|
||||||
|
0x4c, 0x4f, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x87, 0x72, 0x95, 0x3e, 0x30,
|
||||||
|
0x72, 0xb1, 0x25, 0xe7, 0xe7, 0xa5, 0x65, 0xa6, 0x0b, 0x99, 0x71, 0xb1, 0x27, 0x67, 0xa4, 0x26,
|
||||||
|
0x67, 0x67, 0xe6, 0x49, 0x30, 0x2a, 0x30, 0x6b, 0x70, 0x1b, 0xc9, 0xe8, 0xc1, 0x34, 0x41, 0x54,
|
||||||
|
0xe8, 0x39, 0x43, 0xa4, 0x5d, 0xf3, 0x4a, 0x8a, 0x2a, 0x83, 0x60, 0x8a, 0x41, 0xfa, 0xca, 0x53,
|
||||||
|
0x73, 0x92, 0xf3, 0x73, 0x53, 0x25, 0x98, 0xb0, 0xeb, 0x0b, 0x87, 0x48, 0x43, 0xf5, 0x41, 0x15,
|
||||||
|
0x4b, 0x59, 0x71, 0xf1, 0x20, 0x1b, 0x28, 0x24, 0xc0, 0xc5, 0x9c, 0x9d, 0x5a, 0x29, 0xc1, 0xa8,
|
||||||
|
0xc0, 0xa8, 0xc1, 0x12, 0x04, 0x62, 0x0a, 0x89, 0x70, 0xb1, 0x96, 0x25, 0xe6, 0x94, 0x82, 0xcc,
|
||||||
|
0x65, 0xd4, 0xe0, 0x08, 0x82, 0x70, 0xac, 0x98, 0x2c, 0x18, 0x41, 0x7a, 0x91, 0x0d, 0x25, 0xa4,
|
||||||
|
0x97, 0x13, 0x49, 0xaf, 0x93, 0xc0, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78,
|
||||||
|
0x24, 0xc7, 0x38, 0xe3, 0xb1, 0x1c, 0x43, 0x12, 0x1b, 0x38, 0x50, 0x8c, 0x01, 0x01, 0x00, 0x00,
|
||||||
|
0xff, 0xff, 0x2a, 0xe6, 0x90, 0x6e, 0x25, 0x01, 0x00, 0x00,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Config) Marshal() (dAtA []byte, err error) {
|
||||||
|
size := m.Size()
|
||||||
|
dAtA = make([]byte, size)
|
||||||
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dAtA[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Config) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Config) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if m.XXX_unrecognized != nil {
|
||||||
|
i -= len(m.XXX_unrecognized)
|
||||||
|
copy(dAtA[i:], m.XXX_unrecognized)
|
||||||
|
}
|
||||||
|
if len(m.Welcome) > 0 {
|
||||||
|
for k := range m.Welcome {
|
||||||
|
v := m.Welcome[k]
|
||||||
|
baseI := i
|
||||||
|
i -= len(v)
|
||||||
|
copy(dAtA[i:], v)
|
||||||
|
i = encodeVarintManager(dAtA, i, uint64(len(v)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
|
i = encodeVarintManager(dAtA, i, uint64(k))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x8
|
||||||
|
i = encodeVarintManager(dAtA, i, uint64(baseI-i))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(m.Checkin) > 0 {
|
||||||
|
for k := range m.Checkin {
|
||||||
|
v := m.Checkin[k]
|
||||||
|
baseI := i
|
||||||
|
i--
|
||||||
|
if v {
|
||||||
|
dAtA[i] = 1
|
||||||
|
} else {
|
||||||
|
dAtA[i] = 0
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x10
|
||||||
|
i = encodeVarintManager(dAtA, i, uint64(k))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x8
|
||||||
|
i = encodeVarintManager(dAtA, i, uint64(baseI-i))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func encodeVarintManager(dAtA []byte, offset int, v uint64) int {
|
||||||
|
offset -= sovManager(v)
|
||||||
|
base := offset
|
||||||
|
for v >= 1<<7 {
|
||||||
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
|
v >>= 7
|
||||||
|
offset++
|
||||||
|
}
|
||||||
|
dAtA[offset] = uint8(v)
|
||||||
|
return base
|
||||||
|
}
|
||||||
|
func (m *Config) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.Checkin) > 0 {
|
||||||
|
for k, v := range m.Checkin {
|
||||||
|
_ = k
|
||||||
|
_ = v
|
||||||
|
mapEntrySize := 1 + sovManager(uint64(k)) + 1 + 1
|
||||||
|
n += mapEntrySize + 1 + sovManager(uint64(mapEntrySize))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(m.Welcome) > 0 {
|
||||||
|
for k, v := range m.Welcome {
|
||||||
|
_ = k
|
||||||
|
_ = v
|
||||||
|
mapEntrySize := 1 + sovManager(uint64(k)) + 1 + len(v) + sovManager(uint64(len(v)))
|
||||||
|
n += mapEntrySize + 1 + sovManager(uint64(mapEntrySize))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m.XXX_unrecognized != nil {
|
||||||
|
n += len(m.XXX_unrecognized)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func sovManager(x uint64) (n int) {
|
||||||
|
return (math_bits.Len64(x|1) + 6) / 7
|
||||||
|
}
|
||||||
|
func sozManager(x uint64) (n int) {
|
||||||
|
return sovManager(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||||
|
}
|
||||||
|
func (m *Config) Unmarshal(dAtA []byte) error {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
preIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
if wireType == 4 {
|
||||||
|
return fmt.Errorf("proto: config: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: config: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Checkin", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if m.Checkin == nil {
|
||||||
|
m.Checkin = make(map[uint64]bool)
|
||||||
|
}
|
||||||
|
var mapkey uint64
|
||||||
|
var mapvalue bool
|
||||||
|
for iNdEx < postIndex {
|
||||||
|
entryPreIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
if fieldNum == 1 {
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
mapkey |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if fieldNum == 2 {
|
||||||
|
var mapvaluetemp int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
mapvaluetemp |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapvalue = bool(mapvaluetemp != 0)
|
||||||
|
} else {
|
||||||
|
iNdEx = entryPreIndex
|
||||||
|
skippy, err := skipManager(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > postIndex {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Checkin[mapkey] = mapvalue
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 2:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Welcome", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if m.Welcome == nil {
|
||||||
|
m.Welcome = make(map[uint64]string)
|
||||||
|
}
|
||||||
|
var mapkey uint64
|
||||||
|
var mapvalue string
|
||||||
|
for iNdEx < postIndex {
|
||||||
|
entryPreIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
if fieldNum == 1 {
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
mapkey |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if fieldNum == 2 {
|
||||||
|
var stringLenmapvalue uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLenmapvalue |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLenmapvalue := int(stringLenmapvalue)
|
||||||
|
if intStringLenmapvalue < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
postStringIndexmapvalue := iNdEx + intStringLenmapvalue
|
||||||
|
if postStringIndexmapvalue < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
if postStringIndexmapvalue > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue])
|
||||||
|
iNdEx = postStringIndexmapvalue
|
||||||
|
} else {
|
||||||
|
iNdEx = entryPreIndex
|
||||||
|
skippy, err := skipManager(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > postIndex {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Welcome[mapkey] = mapvalue
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipManager(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func skipManager(dAtA []byte) (n int, err error) {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
depth := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= (uint64(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
switch wireType {
|
||||||
|
case 0:
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx++
|
||||||
|
if dAtA[iNdEx-1] < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
iNdEx += 8
|
||||||
|
case 2:
|
||||||
|
var length int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowManager
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
length |= (int(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if length < 0 {
|
||||||
|
return 0, ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
iNdEx += length
|
||||||
|
case 3:
|
||||||
|
depth++
|
||||||
|
case 4:
|
||||||
|
if depth == 0 {
|
||||||
|
return 0, ErrUnexpectedEndOfGroupManager
|
||||||
|
}
|
||||||
|
depth--
|
||||||
|
case 5:
|
||||||
|
iNdEx += 4
|
||||||
|
default:
|
||||||
|
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||||
|
}
|
||||||
|
if iNdEx < 0 {
|
||||||
|
return 0, ErrInvalidLengthManager
|
||||||
|
}
|
||||||
|
if depth == 0 {
|
||||||
|
return iNdEx, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrInvalidLengthManager = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||||
|
ErrIntOverflowManager = fmt.Errorf("proto: integer overflow")
|
||||||
|
ErrUnexpectedEndOfGroupManager = fmt.Errorf("proto: unexpected end of group")
|
||||||
|
)
|
||||||
7
plugin_manager/manager.proto
Normal file
7
plugin_manager/manager.proto
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package manager;
|
||||||
|
|
||||||
|
message config {
|
||||||
|
map<uint64, bool> checkin = 1;
|
||||||
|
map<uint64, string> welcome = 2;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user