Skip to content

Commit

Permalink
fix: 视频缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Nov 15, 2024
1 parent 0edb2a7 commit f1950e2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion coolq/cqcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,12 +1018,15 @@ func (bot *CQBot) readImageCache(b []byte, sourceType message.SourceType) (messa

func (bot *CQBot) readVideoCache(b []byte) message.IMessageElement {
r := binary.NewReader(b)
return &message.ShortVideoElement{ // todo 检查缓存是否有效
isGroup := r.ReadU8() == '1'
video := &message.ShortVideoElement{ // todo 检查缓存是否有效
Md5: r.ReadBytes(16),
Sha1: r.ReadBytes(20),
Name: r.ReadStringWithLength("u32", true),
UUID: r.ReadStringWithLength("u32", true),
}
video.URL, _ = bot.Client.GetVideoURL(isGroup, video.UUID)
return video
}

//// makeShowPic 一种xml 方式发送的群消息图片
Expand Down
5 changes: 3 additions & 2 deletions coolq/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,9 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement, source message.Source)
}
case *message.ShortVideoElement:
data := binary.NewWriterF(func(w *binary.Builder) {
_, _ = w.Write(i.Md5)
_, _ = w.Write(i.Sha1)
w.WriteBool(source.SourceType == message.SourceGroup)
w.WriteBytes(i.Md5)
w.WriteBytes(i.Sha1)
w.WritePacketString(i.Name, "u32", true)
w.WritePacketString(i.UUID, "u32", true)
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/FloatTech/sqlite v1.6.3
github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114084508-83b888a2dadc
github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114153145-593cc9695c20
github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/FloatTech/sqlite v1.6.3 h1:MQkqBNlkPuCoKQQgoNLuTL/2Ci3tBTFAnVYBdD0Wy4
github.com/FloatTech/sqlite v1.6.3/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY=
github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1 h1:g4pTnDJUW4VbJ9NvoRfUvdjDrHz/6QhfN/LoIIpICbo=
github.com/FloatTech/ttl v0.0.0-20230307105452-d6f7b2b647d1/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114084508-83b888a2dadc h1:9Sox4G0cjmFvB4wqEel5+gb1iycYmgrf0u8hURsbDDI=
github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114084508-83b888a2dadc/go.mod h1:m7ydyvA8DKOg5c6iTFDfNtfIK9uhqXVJKRXl4mlGkTA=
github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114153145-593cc9695c20 h1:3vE7lW4qieoxzyIM0FZG100uZDt3GAFdsfYFR9lsb2g=
github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114153145-593cc9695c20/go.mod h1:m7ydyvA8DKOg5c6iTFDfNtfIK9uhqXVJKRXl4mlGkTA=
github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a h1:aU1703IHxupjzipvhu16qYKLMR03e+8WuNR+JMsKfGU=
github.com/Microsoft/go-winio v0.6.2-0.20230724192519-b29bbd58a65a/go.mod h1:OZqLNXdYJHmx7aqq/T6wAdFEdoGm5nmIfC4kU7M8P8o=
github.com/RomiChan/protobuf v0.1.1-0.20230204044148-2ed269a2e54d h1:/Xuj3fIiMY2ls1TwvPKmaqQrtJsPY+c9s+0lOScVHd8=
Expand Down

0 comments on commit f1950e2

Please sign in to comment.