diff --git a/.gitignore b/.gitignore index 9e66494..4066bc3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ internal/btree/*.db # binary builds go-cqhttp + +# macos +.DS_Store diff --git a/coolq/cqcode.go b/coolq/cqcode.go index c241e34..e93e50c 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -11,6 +11,7 @@ import ( "net/url" "os" "path" + "reflect" "runtime" "strconv" "strings" @@ -725,7 +726,17 @@ func (bot *CQBot) ConvertContentMessage(content []global.MSG, sourceType message flash = true } if t.(string) == "show" { - id = data["id"].(int32) + id := 0 + switch idn := data["id"].(type) { + case int32: + id = int(idn) + case int: + id = idn + case int64: + id = int(idn) + default: + id = int(reflect.ValueOf(data["id"]).Convert(reflect.TypeOf(0)).Int()) + } if id < 40000 || id >= 40006 { id = 40000 } @@ -753,7 +764,7 @@ func (bot *CQBot) ConvertContentMessage(content []global.MSG, sourceType message case "all": r = append(r, message.NewAt(0)) case "user": - r = append(r, message.NewAt(data["target"].(int64), data["display"].(string))) + r = append(r, message.NewAt(reflect.ValueOf(data["target"]).Int(), data["display"].(string))) default: continue } @@ -767,7 +778,18 @@ func (bot *CQBot) ConvertContentMessage(content []global.MSG, sourceType message ResId: data["id"].(string), }) case "face": - r = append(r, message.NewFace(data["id"].(int32))) + id := int32(0) + switch idn := data["id"].(type) { + case int32: + id = idn + case int: + id = int32(idn) + case int64: + id = int32(idn) + default: + id = int32(reflect.ValueOf(data["id"]).Convert(reflect.TypeOf(0)).Int()) + } + r = append(r, message.NewFace(id)) case "video": e, err := bot.makeImageOrVideoElem(map[string]string{"file": data["file"].(string)}, true, sourceType) if err != nil { diff --git a/db/database.go b/db/database.go index c19da97..c904822 100644 --- a/db/database.go +++ b/db/database.go @@ -40,61 +40,61 @@ type ( // StoredGroupMessage 持久化群消息 StoredGroupMessage struct { - ID string `bson:"_id"` - GlobalID int32 `bson:"globalId"` - Attribute *StoredMessageAttribute `bson:"attribute"` - SubType string `bson:"subType"` - QuotedInfo *QuotedInfo `bson:"quotedInfo"` - GroupCode int64 `bson:"groupCode"` - AnonymousID string `bson:"anonymousId"` - Content []global.MSG `bson:"content"` + ID string `bson:"_id" yaml:"-"` + GlobalID int32 `bson:"globalId" yaml:"-"` + Attribute *StoredMessageAttribute `bson:"attribute" yaml:"-"` + SubType string `bson:"subType" yaml:"-"` + QuotedInfo *QuotedInfo `bson:"quotedInfo" yaml:"-"` + GroupCode int64 `bson:"groupCode" yaml:"-"` + AnonymousID string `bson:"anonymousId" yaml:"-"` + Content []global.MSG `bson:"content" yaml:"content"` } // StoredPrivateMessage 持久化私聊消息 StoredPrivateMessage struct { - ID string `bson:"_id"` - GlobalID int32 `bson:"globalId"` - Attribute *StoredMessageAttribute `bson:"attribute"` - SubType string `bson:"subType"` - QuotedInfo *QuotedInfo `bson:"quotedInfo"` - SessionUin int64 `bson:"sessionUin"` - TargetUin int64 `bson:"targetUin"` - Content []global.MSG `bson:"content"` + ID string `bson:"_id" yaml:"-"` + GlobalID int32 `bson:"globalId" yaml:"-"` + Attribute *StoredMessageAttribute `bson:"attribute" yaml:"-"` + SubType string `bson:"subType" yaml:"-"` + QuotedInfo *QuotedInfo `bson:"quotedInfo" yaml:"-"` + SessionUin int64 `bson:"sessionUin" yaml:"-"` + TargetUin int64 `bson:"targetUin" yaml:"-"` + Content []global.MSG `bson:"content" yaml:"content"` } // StoredGuildChannelMessage 持久化频道消息 StoredGuildChannelMessage struct { - ID string `bson:"_id"` - Attribute *StoredGuildMessageAttribute `bson:"attribute"` - GuildID uint64 `bson:"guildId"` - ChannelID uint64 `bson:"channelId"` - QuotedInfo *QuotedInfo `bson:"quotedInfo"` - Content []global.MSG `bson:"content"` + ID string `bson:"_id" yaml:"-"` + Attribute *StoredGuildMessageAttribute `bson:"attribute" yaml:"-"` + GuildID uint64 `bson:"guildId" yaml:"-"` + ChannelID uint64 `bson:"channelId" yaml:"-"` + QuotedInfo *QuotedInfo `bson:"quotedInfo" yaml:"-"` + Content []global.MSG `bson:"content" yaml:"content"` } // StoredMessageAttribute 持久化消息属性 StoredMessageAttribute struct { - MessageSeq int32 `bson:"messageSeq"` - InternalID int32 `bson:"internalId"` - SenderUin int64 `bson:"senderUin"` - SenderName string `bson:"senderName"` - Timestamp int64 `bson:"timestamp"` + MessageSeq int32 `bson:"messageSeq" yaml:"-"` + InternalID int32 `bson:"internalId" yaml:"-"` + SenderUin int64 `bson:"senderUin" yaml:"-"` + SenderName string `bson:"senderName" yaml:"-"` + Timestamp int64 `bson:"timestamp" yaml:"-"` } // StoredGuildMessageAttribute 持久化频道消息属性 StoredGuildMessageAttribute struct { - MessageSeq uint64 `bson:"messageSeq"` - InternalID uint64 `bson:"internalId"` - SenderTinyID uint64 `bson:"senderTinyId"` - SenderName string `bson:"senderName"` - Timestamp int64 `bson:"timestamp"` + MessageSeq uint64 `bson:"messageSeq" yaml:"-"` + InternalID uint64 `bson:"internalId" yaml:"-"` + SenderTinyID uint64 `bson:"senderTinyId" yaml:"-"` + SenderName string `bson:"senderName" yaml:"-"` + Timestamp int64 `bson:"timestamp" yaml:"-"` } // QuotedInfo 引用回复 QuotedInfo struct { - PrevID string `bson:"prevId"` - PrevGlobalID int32 `bson:"prevGlobalId"` - QuotedContent []global.MSG `bson:"quotedContent"` + PrevID string `bson:"prevId" yaml:"-"` + PrevGlobalID int32 `bson:"prevGlobalId" yaml:"-"` + QuotedContent []global.MSG `bson:"quotedContent" yaml:"quoted_content"` } ) diff --git a/db/sqlite3/model.go b/db/sqlite3/model.go new file mode 100644 index 0000000..2869865 --- /dev/null +++ b/db/sqlite3/model.go @@ -0,0 +1,84 @@ +package sqlite3 + +const ( + Sqlite3GroupMessageTableName = "grpmsg" + Sqlite3MessageAttributeTableName = "msgattr" + Sqlite3GuildMessageAttributeTableName = "gmsgattr" + Sqlite3QuotedInfoTableName = "quoinf" + Sqlite3PrivateMessageTableName = "privmsg" + Sqlite3GuildChannelMessageTableName = "guildmsg" + Sqlite3UinInfoTableName = "uininf" + Sqlite3TinyInfoTableName = "tinyinf" +) + +// StoredMessageAttribute 持久化消息属性 +type StoredMessageAttribute struct { + ID int64 // ID is the crc64 of 字段s below + MessageSeq int32 + InternalID int32 + SenderUin int64 // SenderUin is fk to UinInfo + Timestamp int64 +} + +// StoredGuildMessageAttribute 持久化频道消息属性 +type StoredGuildMessageAttribute struct { + ID int64 // ID is the crc64 of 字段s below + MessageSeq int64 + InternalID int64 + SenderTinyID int64 // SenderTinyID is fk to TinyInfo + Timestamp int64 +} + +// QuotedInfo 引用回复 +type QuotedInfo struct { + ID int64 // ID is the crc64 of 字段s below + PrevID string + PrevGlobalID int32 + QuotedContent string // QuotedContent is json of original content +} + +// UinInfo QQ 与 昵称 +type UinInfo struct { + Uin int64 + Name string +} + +// TinyInfo Tiny 与 昵称 +type TinyInfo struct { + ID int64 + Name string +} + +// StoredGroupMessage 持久化群消息 +type StoredGroupMessage struct { + GlobalID int32 + ID string + AttributeID int64 + SubType string + QuotedInfoID int64 + GroupCode int64 + AnonymousID string + Content string // Content is json of original content +} + +// StoredPrivateMessage 持久化私聊消息 +type StoredPrivateMessage struct { + GlobalID int32 + ID string + AttributeID int64 + SubType string + QuotedInfoID int64 + SessionUin int64 + TargetUin int64 + Content string // Content is json of original content +} + +// StoredGuildChannelMessage 持久化频道消息 +type StoredGuildChannelMessage struct { + ID string + AttributeID int64 + GuildID int64 + ChannelID int64 + QuotedInfoID int64 + Content string // Content is json of original content +} diff --git a/db/sqlite3/sqlite3.go b/db/sqlite3/sqlite3.go new file mode 100644 index 0000000..5097057 --- /dev/null +++ b/db/sqlite3/sqlite3.go @@ -0,0 +1,532 @@ +package sqlite3 + +import ( + "encoding/base64" + "hash/crc64" + "os" + "path" + "strconv" + "sync" + "time" + + sql "github.com/FloatTech/sqlite" + "github.com/pkg/errors" + "gopkg.in/yaml.v3" + + "github.com/Mrs4s/MiraiGo/binary" + "github.com/Mrs4s/MiraiGo/utils" + "github.com/Mrs4s/go-cqhttp/db" +) + +type database struct { + sync.RWMutex + db *sql.Sqlite + ttl time.Duration +} + +// config mongodb 相关配置 +type config struct { + Enable bool `yaml:"enable"` + CacheTTL time.Duration `yaml:"cachettl"` +} + +func init() { + sql.DriverName = "sqlite" + db.Register("sqlite3", func(node yaml.Node) db.Database { + conf := new(config) + _ = node.Decode(conf) + if !conf.Enable { + return nil + } + return &database{db: new(sql.Sqlite), ttl: conf.CacheTTL} + }) +} + +func (s *database) Open() error { + s.db.DBPath = path.Join("data", "sqlite3") + _ = os.MkdirAll(s.db.DBPath, 0755) + s.db.DBPath += "/msg.db" + err := s.db.Open(s.ttl) + if err != nil { + return errors.Wrap(err, "open sqlite3 error") + } + _, err = s.db.DB.Exec("PRAGMA foreign_keys = ON;") + if err != nil { + return errors.Wrap(err, "enable foreign_keys error") + } + err = s.db.Create(Sqlite3UinInfoTableName, &UinInfo{}) + if err != nil { + return errors.Wrap(err, "create sqlite3 table error") + } + err = s.db.Insert(Sqlite3UinInfoTableName, &UinInfo{Name: "null"}) + if err != nil { + return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3UinInfoTableName+" error") + } + err = s.db.Create(Sqlite3TinyInfoTableName, &TinyInfo{}) + if err != nil { + return errors.Wrap(err, "create sqlite3 table error") + } + err = s.db.Insert(Sqlite3TinyInfoTableName, &TinyInfo{Name: "null"}) + if err != nil { + return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3TinyInfoTableName+" error") + } + err = s.db.Create(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{}, + "FOREIGN KEY(SenderUin) REFERENCES "+Sqlite3UinInfoTableName+"(Uin)", + ) + if err != nil { + return errors.Wrap(err, "create sqlite3 table error") + } + err = s.db.Insert(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{}) + if err != nil { + return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3MessageAttributeTableName+" error") + } + err = s.db.Create(Sqlite3GuildMessageAttributeTableName, &StoredGuildMessageAttribute{}, + "FOREIGN KEY(SenderTinyID) REFERENCES "+Sqlite3TinyInfoTableName+"(ID)", + ) + if err != nil { + return errors.Wrap(err, "create sqlite3 table error") + } + err = s.db.Insert(Sqlite3GuildMessageAttributeTableName, &StoredGuildMessageAttribute{}) + if err != nil { + return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3GuildMessageAttributeTableName+" error") + } + err = s.db.Create(Sqlite3QuotedInfoTableName, &QuotedInfo{}) + if err != nil { + return errors.Wrap(err, "create sqlite3 table error") + } + err = s.db.Insert(Sqlite3QuotedInfoTableName, &QuotedInfo{QuotedContent: "null"}) + if err != nil { + return errors.Wrap(err, "insert into sqlite3 table "+Sqlite3QuotedInfoTableName+" error") + } + err = s.db.Create(Sqlite3GroupMessageTableName, &StoredGroupMessage{}, + "FOREIGN KEY(AttributeID) REFERENCES "+Sqlite3MessageAttributeTableName+"(ID)", + "FOREIGN KEY(QuotedInfoID) REFERENCES "+Sqlite3QuotedInfoTableName+"(ID)", + ) + if err != nil { + return errors.Wrap(err, "create sqlite3 table error") + } + err = s.db.Create(Sqlite3PrivateMessageTableName, &StoredPrivateMessage{}, + "FOREIGN KEY(AttributeID) REFERENCES "+Sqlite3MessageAttributeTableName+"(ID)", + "FOREIGN KEY(QuotedInfoID) REFERENCES "+Sqlite3QuotedInfoTableName+"(ID)", + ) + if err != nil { + return errors.Wrap(err, "create sqlite3 table error") + } + err = s.db.Create(Sqlite3GuildChannelMessageTableName, &StoredGuildChannelMessage{}, + "FOREIGN KEY(AttributeID) REFERENCES "+Sqlite3MessageAttributeTableName+"(ID)", + "FOREIGN KEY(QuotedInfoID) REFERENCES "+Sqlite3QuotedInfoTableName+"(ID)", + ) + if err != nil { + return errors.Wrap(err, "create sqlite3 table error") + } + return nil +} + +func (s *database) GetMessageByGlobalID(id int32) (db.StoredMessage, error) { + if r, err := s.GetGroupMessageByGlobalID(id); err == nil { + return r, nil + } + return s.GetPrivateMessageByGlobalID(id) +} + +func (s *database) GetGroupMessageByGlobalID(id int32) (*db.StoredGroupMessage, error) { + var ret db.StoredGroupMessage + var grpmsg StoredGroupMessage + s.RLock() + err := s.db.Find(Sqlite3GroupMessageTableName, &grpmsg, "WHERE GlobalID="+strconv.Itoa(int(id))) + s.RUnlock() + if err != nil { + return nil, errors.Wrap(err, "query error") + } + ret.ID = grpmsg.ID + ret.GlobalID = grpmsg.GlobalID + ret.SubType = grpmsg.SubType + ret.GroupCode = grpmsg.GroupCode + ret.AnonymousID = grpmsg.AnonymousID + _ = yaml.Unmarshal(utils.S2B(grpmsg.Content), &ret) + if grpmsg.AttributeID != 0 { + var attr StoredMessageAttribute + s.RLock() + err = s.db.Find(Sqlite3MessageAttributeTableName, &attr, "WHERE ID="+strconv.FormatInt(grpmsg.AttributeID, 10)) + s.RUnlock() + if err == nil { + var uin UinInfo + s.RLock() + err = s.db.Find(Sqlite3UinInfoTableName, &uin, "WHERE Uin="+strconv.FormatInt(attr.SenderUin, 10)) + s.RUnlock() + if err == nil { + ret.Attribute = &db.StoredMessageAttribute{ + MessageSeq: attr.MessageSeq, + InternalID: attr.InternalID, + SenderUin: attr.SenderUin, + SenderName: uin.Name, + Timestamp: attr.Timestamp, + } + } + } + } + if grpmsg.QuotedInfoID != 0 { + var quoinf QuotedInfo + s.RLock() + err = s.db.Find(Sqlite3QuotedInfoTableName, &quoinf, "WHERE ID="+strconv.FormatInt(grpmsg.QuotedInfoID, 10)) + s.RUnlock() + if err == nil { + ret.QuotedInfo = &db.QuotedInfo{ + PrevID: quoinf.PrevID, + PrevGlobalID: quoinf.PrevGlobalID, + } + _ = yaml.Unmarshal(utils.S2B(quoinf.QuotedContent), &ret.QuotedInfo) + } + } + return &ret, nil +} + +func (s *database) GetPrivateMessageByGlobalID(id int32) (*db.StoredPrivateMessage, error) { + var ret db.StoredPrivateMessage + var privmsg StoredPrivateMessage + s.RLock() + err := s.db.Find(Sqlite3PrivateMessageTableName, &privmsg, "WHERE GlobalID="+strconv.Itoa(int(id))) + s.RUnlock() + if err != nil { + return nil, errors.Wrap(err, "query error") + } + ret.ID = privmsg.ID + ret.GlobalID = privmsg.GlobalID + ret.SubType = privmsg.SubType + ret.SessionUin = privmsg.SessionUin + ret.TargetUin = privmsg.TargetUin + _ = yaml.Unmarshal(utils.S2B(privmsg.Content), &ret) + if privmsg.AttributeID != 0 { + var attr StoredMessageAttribute + s.RLock() + err = s.db.Find(Sqlite3MessageAttributeTableName, &attr, "WHERE ID="+strconv.FormatInt(privmsg.AttributeID, 10)) + s.RUnlock() + if err == nil { + var uin UinInfo + s.RLock() + err = s.db.Find(Sqlite3UinInfoTableName, &uin, "WHERE Uin="+strconv.FormatInt(attr.SenderUin, 10)) + s.RUnlock() + if err == nil { + ret.Attribute = &db.StoredMessageAttribute{ + MessageSeq: attr.MessageSeq, + InternalID: attr.InternalID, + SenderUin: attr.SenderUin, + SenderName: uin.Name, + Timestamp: attr.Timestamp, + } + } + } + } + if privmsg.QuotedInfoID != 0 { + var quoinf QuotedInfo + s.RLock() + err = s.db.Find(Sqlite3QuotedInfoTableName, &quoinf, "WHERE ID="+strconv.FormatInt(privmsg.QuotedInfoID, 10)) + s.RUnlock() + if err == nil { + ret.QuotedInfo = &db.QuotedInfo{ + PrevID: quoinf.PrevID, + PrevGlobalID: quoinf.PrevGlobalID, + } + _ = yaml.Unmarshal(utils.S2B(quoinf.QuotedContent), &ret.QuotedInfo) + } + } + return &ret, nil +} + +func (s *database) GetGuildChannelMessageByID(id string) (*db.StoredGuildChannelMessage, error) { + b, err := base64.StdEncoding.DecodeString(id) + if err != nil { + return nil, errors.Wrap(err, "query invalid id error") + } + if len(b) < 25 { + return nil, errors.New("query invalid id error: content too short") + } + var ret db.StoredGuildChannelMessage + var guildmsg StoredGuildChannelMessage + s.RLock() + err = s.db.Find(Sqlite3GuildChannelMessageTableName, &guildmsg, "WHERE ID='"+id+"'") + s.RUnlock() + if err != nil { + return nil, errors.Wrap(err, "query error") + } + ret.ID = guildmsg.ID + ret.GuildID = uint64(guildmsg.GuildID) + ret.ChannelID = uint64(guildmsg.ChannelID) + _ = yaml.Unmarshal(utils.S2B(guildmsg.Content), &ret) + if guildmsg.AttributeID != 0 { + var attr StoredGuildMessageAttribute + s.RLock() + err = s.db.Find(Sqlite3GuildMessageAttributeTableName, &attr, "WHERE ID="+strconv.FormatInt(guildmsg.AttributeID, 10)) + s.RUnlock() + if err == nil { + var tiny TinyInfo + s.RLock() + err = s.db.Find(Sqlite3TinyInfoTableName, &tiny, "WHERE ID="+strconv.FormatInt(attr.SenderTinyID, 10)) + s.RUnlock() + if err == nil { + ret.Attribute = &db.StoredGuildMessageAttribute{ + MessageSeq: uint64(attr.MessageSeq), + InternalID: uint64(attr.InternalID), + SenderTinyID: uint64(attr.SenderTinyID), + SenderName: tiny.Name, + Timestamp: attr.Timestamp, + } + } + } + } + if guildmsg.QuotedInfoID != 0 { + var quoinf QuotedInfo + s.RLock() + err = s.db.Find(Sqlite3QuotedInfoTableName, &quoinf, "WHERE ID="+strconv.FormatInt(guildmsg.QuotedInfoID, 10)) + s.RUnlock() + if err == nil { + ret.QuotedInfo = &db.QuotedInfo{ + PrevID: quoinf.PrevID, + PrevGlobalID: quoinf.PrevGlobalID, + } + _ = yaml.Unmarshal(utils.S2B(quoinf.QuotedContent), &ret.QuotedInfo) + } + } + return &ret, nil +} + +func (s *database) InsertGroupMessage(msg *db.StoredGroupMessage) error { + grpmsg := &StoredGroupMessage{ + GlobalID: msg.GlobalID, + ID: msg.ID, + SubType: msg.SubType, + GroupCode: msg.GroupCode, + AnonymousID: msg.AnonymousID, + } + h := crc64.New(crc64.MakeTable(crc64.ISO)) + if msg.Attribute != nil { + h.Write(binary.NewWriterF(func(w *binary.Writer) { + w.WriteUInt32(uint32(msg.Attribute.MessageSeq)) + w.WriteUInt32(uint32(msg.Attribute.InternalID)) + w.WriteUInt64(uint64(msg.Attribute.SenderUin)) + w.WriteUInt64(uint64(msg.Attribute.Timestamp)) + })) + h.Write(utils.S2B(msg.Attribute.SenderName)) + id := int64(h.Sum64()) + if id == 0 { + id++ + } + s.Lock() + err := s.db.Insert(Sqlite3UinInfoTableName, &UinInfo{ + Uin: msg.Attribute.SenderUin, + Name: msg.Attribute.SenderName, + }) + if err == nil { + err = s.db.Insert(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{ + ID: id, + MessageSeq: msg.Attribute.MessageSeq, + InternalID: msg.Attribute.InternalID, + SenderUin: msg.Attribute.SenderUin, + Timestamp: msg.Attribute.Timestamp, + }) + } + s.Unlock() + if err == nil { + grpmsg.AttributeID = id + } + h.Reset() + } + if msg.QuotedInfo != nil { + h.Write(utils.S2B(msg.QuotedInfo.PrevID)) + h.Write(binary.NewWriterF(func(w *binary.Writer) { + w.WriteUInt32(uint32(msg.QuotedInfo.PrevGlobalID)) + })) + content, err := yaml.Marshal(&msg.QuotedInfo) + if err != nil { + return errors.Wrap(err, "insert marshal QuotedContent error") + } + h.Write(content) + id := int64(h.Sum64()) + if id == 0 { + id++ + } + s.Lock() + err = s.db.Insert(Sqlite3QuotedInfoTableName, &QuotedInfo{ + ID: id, + PrevID: msg.QuotedInfo.PrevID, + PrevGlobalID: msg.QuotedInfo.PrevGlobalID, + QuotedContent: utils.B2S(content), + }) + s.Unlock() + if err == nil { + grpmsg.QuotedInfoID = id + } + } + content, err := yaml.Marshal(&msg) + if err != nil { + return errors.Wrap(err, "insert marshal Content error") + } + grpmsg.Content = utils.B2S(content) + s.Lock() + err = s.db.Insert(Sqlite3GroupMessageTableName, grpmsg) + s.Unlock() + if err != nil { + return errors.Wrap(err, "insert error") + } + return nil +} + +func (s *database) InsertPrivateMessage(msg *db.StoredPrivateMessage) error { + privmsg := &StoredPrivateMessage{ + GlobalID: msg.GlobalID, + ID: msg.ID, + SubType: msg.SubType, + SessionUin: msg.SessionUin, + TargetUin: msg.TargetUin, + } + h := crc64.New(crc64.MakeTable(crc64.ISO)) + if msg.Attribute != nil { + h.Write(binary.NewWriterF(func(w *binary.Writer) { + w.WriteUInt32(uint32(msg.Attribute.MessageSeq)) + w.WriteUInt32(uint32(msg.Attribute.InternalID)) + w.WriteUInt64(uint64(msg.Attribute.SenderUin)) + w.WriteUInt64(uint64(msg.Attribute.Timestamp)) + })) + h.Write(utils.S2B(msg.Attribute.SenderName)) + id := int64(h.Sum64()) + if id == 0 { + id++ + } + s.Lock() + err := s.db.Insert(Sqlite3UinInfoTableName, &UinInfo{ + Uin: msg.Attribute.SenderUin, + Name: msg.Attribute.SenderName, + }) + if err == nil { + err = s.db.Insert(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{ + ID: id, + MessageSeq: msg.Attribute.MessageSeq, + InternalID: msg.Attribute.InternalID, + SenderUin: msg.Attribute.SenderUin, + Timestamp: msg.Attribute.Timestamp, + }) + } + s.Unlock() + if err == nil { + privmsg.AttributeID = id + } + h.Reset() + } + if msg.QuotedInfo != nil { + h.Write(utils.S2B(msg.QuotedInfo.PrevID)) + h.Write(binary.NewWriterF(func(w *binary.Writer) { + w.WriteUInt32(uint32(msg.QuotedInfo.PrevGlobalID)) + })) + content, err := yaml.Marshal(&msg.QuotedInfo) + if err != nil { + return errors.Wrap(err, "insert marshal QuotedContent error") + } + h.Write(content) + id := int64(h.Sum64()) + if id == 0 { + id++ + } + s.Lock() + err = s.db.Insert(Sqlite3QuotedInfoTableName, &QuotedInfo{ + ID: id, + PrevID: msg.QuotedInfo.PrevID, + PrevGlobalID: msg.QuotedInfo.PrevGlobalID, + QuotedContent: utils.B2S(content), + }) + s.Unlock() + if err == nil { + privmsg.QuotedInfoID = id + } + } + content, err := yaml.Marshal(&msg) + if err != nil { + return errors.Wrap(err, "insert marshal Content error") + } + privmsg.Content = utils.B2S(content) + s.Lock() + err = s.db.Insert(Sqlite3PrivateMessageTableName, privmsg) + s.Unlock() + if err != nil { + return errors.Wrap(err, "insert error") + } + return nil +} + +func (s *database) InsertGuildChannelMessage(msg *db.StoredGuildChannelMessage) error { + guildmsg := &StoredGuildChannelMessage{ + ID: msg.ID, + GuildID: int64(msg.GuildID), + ChannelID: int64(msg.ChannelID), + } + h := crc64.New(crc64.MakeTable(crc64.ISO)) + if msg.Attribute != nil { + h.Write(binary.NewWriterF(func(w *binary.Writer) { + w.WriteUInt32(uint32(msg.Attribute.MessageSeq)) + w.WriteUInt32(uint32(msg.Attribute.InternalID)) + w.WriteUInt64(uint64(msg.Attribute.SenderTinyID)) + w.WriteUInt64(uint64(msg.Attribute.Timestamp)) + })) + h.Write(utils.S2B(msg.Attribute.SenderName)) + id := int64(h.Sum64()) + if id == 0 { + id++ + } + s.Lock() + err := s.db.Insert(Sqlite3TinyInfoTableName, &TinyInfo{ + ID: int64(msg.Attribute.SenderTinyID), + Name: msg.Attribute.SenderName, + }) + if err == nil { + err = s.db.Insert(Sqlite3MessageAttributeTableName, &StoredGuildMessageAttribute{ + ID: id, + MessageSeq: int64(msg.Attribute.MessageSeq), + InternalID: int64(msg.Attribute.InternalID), + SenderTinyID: int64(msg.Attribute.SenderTinyID), + Timestamp: msg.Attribute.Timestamp, + }) + } + s.Unlock() + if err == nil { + guildmsg.AttributeID = id + } + h.Reset() + } + if msg.QuotedInfo != nil { + h.Write(utils.S2B(msg.QuotedInfo.PrevID)) + h.Write(binary.NewWriterF(func(w *binary.Writer) { + w.WriteUInt32(uint32(msg.QuotedInfo.PrevGlobalID)) + })) + content, err := yaml.Marshal(&msg.QuotedInfo) + if err != nil { + return errors.Wrap(err, "insert marshal QuotedContent error") + } + h.Write(content) + id := int64(h.Sum64()) + if id == 0 { + id++ + } + s.Lock() + err = s.db.Insert(Sqlite3QuotedInfoTableName, &QuotedInfo{ + ID: id, + PrevID: msg.QuotedInfo.PrevID, + PrevGlobalID: msg.QuotedInfo.PrevGlobalID, + QuotedContent: utils.B2S(content), + }) + s.Unlock() + if err == nil { + guildmsg.QuotedInfoID = id + } + } + content, err := yaml.Marshal(&msg) + if err != nil { + return errors.Wrap(err, "insert marshal Content error") + } + guildmsg.Content = utils.B2S(content) + s.Lock() + err = s.db.Insert(Sqlite3GuildChannelMessageTableName, guildmsg) + s.Unlock() + if err != nil { + return errors.Wrap(err, "insert error") + } + return nil +} diff --git a/global/param.go b/global/param.go index f23879a..44225bd 100644 --- a/global/param.go +++ b/global/param.go @@ -8,7 +8,7 @@ import ( ) // MSG 消息Map -type MSG map[string]interface{} +type MSG = map[string]interface{} // VersionNameCompare 检查版本名是否需要更新, 仅适用于 go-cqhttp 的版本命名规则 // diff --git a/go.mod b/go.mod index 3b6bd5b..4f012a6 100644 --- a/go.mod +++ b/go.mod @@ -3,53 +3,66 @@ module github.com/Mrs4s/go-cqhttp go 1.19 require ( - github.com/Microsoft/go-winio v0.5.1 + github.com/FloatTech/sqlite v1.5.7 + github.com/Microsoft/go-winio v0.6.0 github.com/Mrs4s/MiraiGo v0.0.0-20221201090748-23f637d2954e - github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c + github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc - github.com/fumiama/go-base16384 v1.5.2 + github.com/fumiama/go-base16384 v1.6.1 github.com/fumiama/go-hide-param v0.1.4 github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible - github.com/mattn/go-colorable v0.1.12 + github.com/mattn/go-colorable v0.1.13 github.com/pkg/errors v0.9.1 - github.com/segmentio/asm v1.1.3 - github.com/sirupsen/logrus v1.8.1 - github.com/stretchr/testify v1.8.0 + github.com/segmentio/asm v1.2.0 + github.com/sirupsen/logrus v1.9.0 + github.com/stretchr/testify v1.8.1 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - github.com/tidwall/gjson v1.14.3 - github.com/wdvxdr1123/go-silk v0.0.0-20210316130616-d47b553def60 - go.mongodb.org/mongo-driver v1.8.3 - golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 - golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 + github.com/tidwall/gjson v1.14.4 + github.com/wdvxdr1123/go-silk v0.0.0-20220304095002-f67345df09ea + go.mongodb.org/mongo-driver v1.11.0 + golang.org/x/crypto v0.3.0 + golang.org/x/sys v0.2.0 + golang.org/x/term v0.2.0 + golang.org/x/time v0.2.0 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/RomiChan/protobuf v0.1.1-0.20220624030127-3310cba9dbc0 // indirect + github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b // indirect + github.com/RomiChan/protobuf v0.0.0-20220624030127-3310cba9dbc0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fumiama/imgsz v0.0.2 // indirect - github.com/go-stack/stack v1.8.0 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/go-cmp v0.5.5 // indirect - github.com/jonboulle/clockwork v0.2.2 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/jonboulle/clockwork v0.3.0 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.13.6 // indirect - github.com/lestrrat-go/strftime v1.0.5 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/lestrrat-go/strftime v1.0.6 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect + github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect github.com/pierrec/lz4/v4 v4.1.15 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.0.2 // indirect - github.com/xdg-go/stringprep v1.0.2 // indirect + github.com/xdg-go/scram v1.1.1 // indirect + github.com/xdg-go/stringprep v1.0.3 // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 // indirect + golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect - golang.org/x/sys v0.0.0-20220111092808-5a964db01320 // indirect - golang.org/x/text v0.3.7 // indirect - modernc.org/libc v1.8.1 // indirect - modernc.org/mathutil v1.2.2 // indirect - modernc.org/memory v1.0.4 // indirect + golang.org/x/text v0.4.0 // indirect + golang.org/x/tools v0.1.12 // indirect + lukechampine.com/uint128 v1.2.0 // indirect + modernc.org/cc/v3 v3.40.0 // indirect + modernc.org/ccgo/v3 v3.16.13 // indirect + modernc.org/libc v1.21.5 // indirect + modernc.org/mathutil v1.5.0 // indirect + modernc.org/memory v1.4.0 // indirect + modernc.org/opt v0.1.3 // indirect + modernc.org/sqlite v1.20.0 // indirect + modernc.org/strutil v1.1.3 // indirect + modernc.org/token v1.0.1 // indirect ) + +replace github.com/remyoudompheng/bigfft => github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b diff --git a/go.sum b/go.sum index 9550d9c..564292c 100644 --- a/go.sum +++ b/go.sum @@ -1,27 +1,32 @@ -github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY= -github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= +github.com/FloatTech/sqlite v1.5.7 h1:Bvo4LSojcZ6dVtbHrkqvt6z4v8e+sj0G5PSUIvdawsk= +github.com/FloatTech/sqlite v1.5.7/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY= +github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw= +github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= +github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Mrs4s/MiraiGo v0.0.0-20221201090748-23f637d2954e h1:PvTvu1c9R8XCDGysBYGF+TSO+UfX347NJkNblifC4C8= github.com/Mrs4s/MiraiGo v0.0.0-20221201090748-23f637d2954e/go.mod h1:lecSP26qedhinCceWn1x02dLDxGotH5nTFlpIMilmVM= -github.com/RomiChan/protobuf v0.1.1-0.20220624030127-3310cba9dbc0 h1:+UGPBYVjssFsdahLJIiNPwpmmwgl/OaVdv1oc5NonC0= -github.com/RomiChan/protobuf v0.1.1-0.20220624030127-3310cba9dbc0/go.mod h1:2Ie+hdBFQpQFDHfeklgxoFmQRCE7O+KwFpISeXq7OwA= -github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c h1:cNPOdTNiVwxLpROLjXCgbIPvdkE+BwvxDvgmdYmWx6Q= -github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c/go.mod h1:KqZzu7slNKROh3TSYEH/IUMG6f4M+1qubZ5e52QypsE= +github.com/RomiChan/protobuf v0.0.0-20220624030127-3310cba9dbc0 h1:GEwcB4dL9vc4veW1fLNt0Fby3wspVflAn5v9/HbUwDM= +github.com/RomiChan/protobuf v0.0.0-20220624030127-3310cba9dbc0/go.mod h1:2Ie+hdBFQpQFDHfeklgxoFmQRCE7O+KwFpISeXq7OwA= +github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= +github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0= github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fumiama/go-base16384 v1.5.2 h1:cbxXTcDH92PNgG7bEBwiCEoWb5O+nwZKxKOG94ilFo8= -github.com/fumiama/go-base16384 v1.5.2/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM= +github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b h1:Zt3pFQditAdWTHCOVkiloc9ZauBoWrb37guFV4iIRvE= +github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/fumiama/go-base16384 v1.6.1 h1:4yb4JgmBJDnQtq3XGXXdLrVwEnRpjhMUt4eAcsNeA30= +github.com/fumiama/go-base16384 v1.6.1/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM= github.com/fumiama/go-hide-param v0.1.4 h1:y7TRTzZMdCH9GOXnIzU3B+1BSkcmvejVGmGsz4t0DGU= github.com/fumiama/go-hide-param v0.1.4/go.mod h1:vJkQlJIEI56nIyp7tCQu1/2QOyKtZpudsnJkGk9U1aY= github.com/fumiama/imgsz v0.0.2 h1:fAkC0FnIscdKOXwAxlyw3EUba5NzxZdSxGaq3Uyfxak= github.com/fumiama/imgsz v0.0.2/go.mod h1:dR71mI3I2O5u6+PCpd47M9TZptzP+39tRBcbdIkoqM4= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -36,11 +41,15 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= +github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -52,13 +61,15 @@ github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2t github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is= github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4= github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA= -github.com/lestrrat-go/strftime v1.0.5 h1:A7H3tT8DhTz8u65w+JRpiBxM4dINQhUXAZnhBa2xeOE= -github.com/lestrrat-go/strftime v1.0.5/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205AhTIGQQ= +github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= @@ -71,64 +82,61 @@ github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0= github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc= -github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= +github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= -github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= +github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/wdvxdr1123/go-silk v0.0.0-20210316130616-d47b553def60 h1:lRKf10iIOW0VsH5WDF621ihzR+R2wEBZVtNRHuLLCb4= -github.com/wdvxdr1123/go-silk v0.0.0-20210316130616-d47b553def60/go.mod h1:ecFKZPX81BaB70I6ruUgEwYcDOtuNgJGnjdK+MIl5ko= +github.com/wdvxdr1123/go-silk v0.0.0-20220304095002-f67345df09ea h1:sl1pYm1kHtIndckTY8YDt+QFt77vI0JnKHP0U8rZtKc= +github.com/wdvxdr1123/go-silk v0.0.0-20220304095002-f67345df09ea/go.mod h1:ecFKZPX81BaB70I6ruUgEwYcDOtuNgJGnjdK+MIl5ko= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.0.2 h1:akYIkZ28e6A96dkWNJQu3nmCzH3YfwMPQExUYDaRv7w= -github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= -github.com/xdg-go/stringprep v1.0.2 h1:6iq84/ryjjeRmMJwxutI51F2GIPlP5BfTvXHeYjyhBc= -github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E= +github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= +github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs= +github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -go.mongodb.org/mongo-driver v1.8.3 h1:TDKlTkGDKm9kkJVUOAXDK5/fkqKHJVwYQSpoRfB43R4= -go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= +go.mongodb.org/mongo-driver v1.11.0 h1:FZKhBSTydeuffHj9CBjXlR8vQLee1cQyTWYPA6/tqiE= +go.mongodb.org/mongo-driver v1.11.0/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M= -golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= +golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 h1:0qxwC5n+ttVOINCBeRHO0nq9X7uy8SDsPoi5OaCdIEI= -golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc= golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -136,31 +144,35 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 h1:GZokNIeuVkl3aZHJchRrr13WCsols02MLUcz1U9is6M= -golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/time v0.2.0 h1:52I/1L54xyEQAYdtcSuxtiT84KGYTBGXwayxmIpNJhE= +golang.org/x/time v0.2.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -182,10 +194,31 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -modernc.org/libc v1.8.1 h1:y9oPIhwcaFXxX7kMp6Qb2ZLKzr0mDkikWN3CV5GS63o= +lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= +lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= +modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= +modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0= +modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw= +modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY= +modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk= +modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= modernc.org/libc v1.8.1/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= +modernc.org/libc v1.21.5 h1:xBkU9fnHV+hvZuPSRszN0AXDG4M7nwPLwTWwkYcvLCI= +modernc.org/libc v1.21.5/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM= +modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= +modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc= +modernc.org/memory v1.4.0 h1:crykUfNSnMAXaOJnnxcSzbUGMqkLWjklJKkBK2nwZwk= +modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= +modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= +modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/sqlite v1.20.0 h1:80zmD3BGkm8BZ5fUi/4lwJQHiO3GXgIUvZRXpoIfROY= +modernc.org/sqlite v1.20.0/go.mod h1:EsYz8rfOvLCiYTy5ZFsOYzoCcRMu98YYkwAcCw5YIYw= +modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY= +modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= +modernc.org/tcl v1.15.0 h1:oY+JeD11qVVSgVvodMJsu7Edf8tr5E/7tuhF5cNYz34= +modernc.org/token v1.0.1 h1:A3qvTqOwexpfZZeyI0FeGPDlSWX5pjZu9hF4lU+EKWg= +modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= +modernc.org/z v1.7.0 h1:xkDw/KepgEjeizO2sNco+hqYkU12taxQFqPEmgm1GWE= diff --git a/main.go b/main.go index 1d79704..30838f7 100644 --- a/main.go +++ b/main.go @@ -4,9 +4,10 @@ package main import ( "github.com/Mrs4s/go-cqhttp/cmd/gocq" - _ "github.com/Mrs4s/go-cqhttp/db/leveldb" // leveldb + _ "github.com/Mrs4s/go-cqhttp/db/leveldb" // leveldb 数据库支持 _ "github.com/Mrs4s/go-cqhttp/modules/silk" // silk编码模块 // 其他模块 + // _ "github.com/Mrs4s/go-cqhttp/db/sqlite3" // sqlite3 数据库支持 // _ "github.com/Mrs4s/go-cqhttp/db/mongodb" // mongodb 数据库支持 // _ "github.com/Mrs4s/go-cqhttp/modules/pprof" // pprof 性能分析 ) diff --git a/modules/config/default_config.yml b/modules/config/default_config.yml index 7d2f7e9..60d5db0 100644 --- a/modules/config/default_config.yml +++ b/modules/config/default_config.yml @@ -78,6 +78,12 @@ database: # 数据库相关设置 # 启用将会增加10-20MB的内存占用和一定的磁盘空间 # 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能 enable: true + sqlite3: + # 是否启用内置sqlite3数据库 + # 启用将会增加一定的内存占用和一定的磁盘空间 + # 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能 + enable: false + cachettl: 3600000000000 # 1h # 连接服务列表 servers: