mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
fix #10
This commit is contained in:
parent
e754bd36ed
commit
d5bff2ad8b
20
coolq/bot.go
20
coolq/bot.go
@ -136,16 +136,18 @@ func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32 {
|
|||||||
"message": ToStringMessage(m.Elements, m.GroupCode, true),
|
"message": ToStringMessage(m.Elements, m.GroupCode, true),
|
||||||
}
|
}
|
||||||
id := ToGlobalId(m.GroupCode, m.Id)
|
id := ToGlobalId(m.GroupCode, m.Id)
|
||||||
err := bot.db.Update(func(tx *nutsdb.Tx) error {
|
if bot.db != nil {
|
||||||
buf := new(bytes.Buffer)
|
err := bot.db.Update(func(tx *nutsdb.Tx) error {
|
||||||
if err := gob.NewEncoder(buf).Encode(val); err != nil {
|
buf := new(bytes.Buffer)
|
||||||
return err
|
if err := gob.NewEncoder(buf).Encode(val); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return tx.Put("group-messages", binary.ToBytes(id), binary.GZipCompress(buf.Bytes()), 0)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("记录聊天数据时出现错误: %v", err)
|
||||||
|
return -1
|
||||||
}
|
}
|
||||||
return tx.Put("group-messages", binary.ToBytes(id), binary.GZipCompress(buf.Bytes()), 0)
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("记录聊天数据时出现错误: %v", err)
|
|
||||||
return -1
|
|
||||||
}
|
}
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user