mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
fix: make linter happy
add db into skip-dirs
This commit is contained in:
parent
2927c2214f
commit
d464236573
@ -78,7 +78,9 @@ run:
|
|||||||
# concurrency: 4 # explicitly omit this value to fully utilize available resources.
|
# concurrency: 4 # explicitly omit this value to fully utilize available resources.
|
||||||
deadline: 5m
|
deadline: 5m
|
||||||
issues-exit-code: 1
|
issues-exit-code: 1
|
||||||
tests: false
|
skip-dirs:
|
||||||
|
- db
|
||||||
|
tests: true
|
||||||
|
|
||||||
# output configuration options
|
# output configuration options
|
||||||
output:
|
output:
|
||||||
|
20
coolq/bot.go
20
coolq/bot.go
@ -88,7 +88,7 @@ func NewQQBot(cli *client.QQClient) *CQBot {
|
|||||||
lconf.Database = "gocq-database"
|
lconf.Database = "gocq-database"
|
||||||
}
|
}
|
||||||
if lconf.Enable {
|
if lconf.Enable {
|
||||||
multiDB.UseDB(db.UseMongoDB(lconf.Uri, lconf.Database))
|
multiDB.UseDB(db.UseMongoDB(lconf.URI, lconf.Database))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := multiDB.Open(); err != nil {
|
if err := multiDB.Open(); err != nil {
|
||||||
@ -317,7 +317,8 @@ func (bot *CQBot) SendPrivateMessage(target int64, groupID int64, m *message.Sen
|
|||||||
default:
|
default:
|
||||||
if session == nil && groupID != 0 {
|
if session == nil && groupID != 0 {
|
||||||
msg := bot.Client.SendGroupTempMessage(groupID, target, m)
|
msg := bot.Client.SendGroupTempMessage(groupID, target, m)
|
||||||
if msg != nil {
|
if msg != nil { // nolint
|
||||||
|
// todo(Mrs4s)
|
||||||
// id = bot.InsertTempMessage(target, msg)
|
// id = bot.InsertTempMessage(target, msg)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -327,7 +328,8 @@ func (bot *CQBot) SendPrivateMessage(target int64, groupID int64, m *message.Sen
|
|||||||
log.Errorf("发送临时会话消息失败: %v", err)
|
log.Errorf("发送临时会话消息失败: %v", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if msg != nil {
|
if msg != nil { // nolint
|
||||||
|
// todo(Mrs4s)
|
||||||
// id = bot.InsertTempMessage(target, msg)
|
// id = bot.InsertTempMessage(target, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -354,7 +356,7 @@ func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32 {
|
|||||||
return ok
|
return ok
|
||||||
})
|
})
|
||||||
msg := &db.StoredGroupMessage{
|
msg := &db.StoredGroupMessage{
|
||||||
ID: encodeMessageId(m.GroupCode, m.Id),
|
ID: encodeMessageID(m.GroupCode, m.Id),
|
||||||
GlobalID: db.ToGlobalID(m.GroupCode, m.Id),
|
GlobalID: db.ToGlobalID(m.GroupCode, m.Id),
|
||||||
SubType: "normal",
|
SubType: "normal",
|
||||||
Attribute: &db.StoredMessageAttribute{
|
Attribute: &db.StoredMessageAttribute{
|
||||||
@ -377,7 +379,7 @@ func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32 {
|
|||||||
reply := replyElem.(*message.ReplyElement)
|
reply := replyElem.(*message.ReplyElement)
|
||||||
msg.SubType = "quote"
|
msg.SubType = "quote"
|
||||||
msg.QuotedInfo = &db.QuotedInfo{
|
msg.QuotedInfo = &db.QuotedInfo{
|
||||||
PrevID: encodeMessageId(m.GroupCode, reply.ReplySeq),
|
PrevID: encodeMessageID(m.GroupCode, reply.ReplySeq),
|
||||||
PrevGlobalID: db.ToGlobalID(m.GroupCode, reply.ReplySeq),
|
PrevGlobalID: db.ToGlobalID(m.GroupCode, reply.ReplySeq),
|
||||||
QuotedContent: ToMessageContent(reply.Elements),
|
QuotedContent: ToMessageContent(reply.Elements),
|
||||||
}
|
}
|
||||||
@ -397,7 +399,7 @@ func (bot *CQBot) InsertPrivateMessage(m *message.PrivateMessage) int32 {
|
|||||||
return ok
|
return ok
|
||||||
})
|
})
|
||||||
msg := &db.StoredPrivateMessage{
|
msg := &db.StoredPrivateMessage{
|
||||||
ID: encodeMessageId(m.Sender.Uin, m.Id),
|
ID: encodeMessageID(m.Sender.Uin, m.Id),
|
||||||
GlobalID: db.ToGlobalID(m.Sender.Uin, m.Id),
|
GlobalID: db.ToGlobalID(m.Sender.Uin, m.Id),
|
||||||
SubType: "normal",
|
SubType: "normal",
|
||||||
Attribute: &db.StoredMessageAttribute{
|
Attribute: &db.StoredMessageAttribute{
|
||||||
@ -420,7 +422,7 @@ func (bot *CQBot) InsertPrivateMessage(m *message.PrivateMessage) int32 {
|
|||||||
reply := replyElem.(*message.ReplyElement)
|
reply := replyElem.(*message.ReplyElement)
|
||||||
msg.SubType = "quote"
|
msg.SubType = "quote"
|
||||||
msg.QuotedInfo = &db.QuotedInfo{
|
msg.QuotedInfo = &db.QuotedInfo{
|
||||||
PrevID: encodeMessageId(reply.Sender, reply.ReplySeq),
|
PrevID: encodeMessageID(reply.Sender, reply.ReplySeq),
|
||||||
PrevGlobalID: db.ToGlobalID(reply.Sender, reply.ReplySeq),
|
PrevGlobalID: db.ToGlobalID(reply.Sender, reply.ReplySeq),
|
||||||
QuotedContent: ToMessageContent(m.Elements),
|
QuotedContent: ToMessageContent(m.Elements),
|
||||||
}
|
}
|
||||||
@ -594,8 +596,8 @@ func (bot *CQBot) uploadMedia(raw message.IMessageElement, target int64, group b
|
|||||||
return nil, errors.New("unsupported message element type")
|
return nil, errors.New("unsupported message element type")
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeMessageId 临时先这样, 暂时用不上
|
// encodeMessageID 临时先这样, 暂时用不上
|
||||||
func encodeMessageId(target int64, seq int32) string {
|
func encodeMessageID(target int64, seq int32) string {
|
||||||
return hex.EncodeToString(binary.NewWriterF(func(w *binary.Writer) {
|
return hex.EncodeToString(binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt64(uint64(target))
|
w.WriteUInt64(uint64(target))
|
||||||
w.WriteUInt32(uint32(seq))
|
w.WriteUInt32(uint32(seq))
|
||||||
|
@ -41,7 +41,7 @@ const bText = `123456789[]&987654321[]&987654321[]&987654321[]&987654321[]&98765
|
|||||||
func BenchmarkCQCodeEscapeText(b *testing.B) {
|
func BenchmarkCQCodeEscapeText(b *testing.B) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
ret := bText
|
ret := bText
|
||||||
ret = CQCodeEscapeText(ret)
|
CQCodeEscapeText(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ func BenchmarkCQCodeEscapeTextBefore(b *testing.B) {
|
|||||||
ret := bText
|
ret := bText
|
||||||
ret = strings.ReplaceAll(ret, "&", "&")
|
ret = strings.ReplaceAll(ret, "&", "&")
|
||||||
ret = strings.ReplaceAll(ret, "[", "[")
|
ret = strings.ReplaceAll(ret, "[", "[")
|
||||||
ret = strings.ReplaceAll(ret, "]", "]")
|
strings.ReplaceAll(ret, "]", "]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,8 @@ func (bot *CQBot) tempMessageEvent(c *client.QQClient, e *client.TempMessageEven
|
|||||||
cqm := ToStringMessage(m.Elements, 0, true)
|
cqm := ToStringMessage(m.Elements, 0, true)
|
||||||
bot.tempSessionCache.Store(m.Sender.Uin, e.Session)
|
bot.tempSessionCache.Store(m.Sender.Uin, e.Session)
|
||||||
id := m.Id
|
id := m.Id
|
||||||
if bot.db != nil {
|
if bot.db != nil { // nolint
|
||||||
|
// todo(Mrs4s)
|
||||||
// id = bot.InsertTempMessage(m.Sender.Uin, m)
|
// id = bot.InsertTempMessage(m.Sender.Uin, m)
|
||||||
}
|
}
|
||||||
log.Infof("收到来自群 %v(%v) 内 %v(%v) 的临时会话消息: %v", m.GroupName, m.GroupCode, m.Sender.DisplayName(), m.Sender.Uin, cqm)
|
log.Infof("收到来自群 %v(%v) 内 %v(%v) 的临时会话消息: %v", m.GroupName, m.GroupCode, m.Sender.DisplayName(), m.Sender.Uin, cqm)
|
||||||
|
@ -137,9 +137,10 @@ type LevelDBConfig struct {
|
|||||||
Enable bool `yaml:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MongoDBConfig mongodb 相关配置
|
||||||
type MongoDBConfig struct {
|
type MongoDBConfig struct {
|
||||||
Enable bool `yaml:"enable"`
|
Enable bool `yaml:"enable"`
|
||||||
Uri string `yaml:"uri"`
|
URI string `yaml:"uri"`
|
||||||
Database string `yaml:"database"`
|
Database string `yaml:"database"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user