From cf86eab638b23244b7591f3312daebdcb27f4cd4 Mon Sep 17 00:00:00 2001 From: Redmomn <109732988+Redmomn@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:11:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E5=92=8C=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/gocq/main.go | 1 - coolq/cqcode.go | 8 ++------ coolq/event.go | 27 +++++++-------------------- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 12 insertions(+), 30 deletions(-) diff --git a/cmd/gocq/main.go b/cmd/gocq/main.go index 02b55b9cf..38f60b839 100644 --- a/cmd/gocq/main.go +++ b/cmd/gocq/main.go @@ -211,7 +211,6 @@ func LoginInteract() { app := auth.AppList["linux"]["3.2.10-25765"] log.Infof("使用协议: %s %s", app.OS, app.CurrentVersion) cli = newClient(app) - cli.UseVersion(app) cli.UseDevice(device) isQRCodeLogin := (base.Account.Uin == 0 || len(base.Account.Password) == 0) && !base.Account.Encrypt isTokenLogin := false diff --git a/coolq/cqcode.go b/coolq/cqcode.go index b112e2588..c8148bdbf 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -1020,13 +1020,9 @@ func (bot *CQBot) readVideoCache(b []byte) message.IMessageElement { r := binary.NewReader(b) return &message.ShortVideoElement{ // todo 检查缓存是否有效 Md5: r.ReadBytes(16), - Size: r.ReadU32(), - Thumb: &message.VideoThumb{ - Md5: r.ReadBytes(16), - Size: r.ReadU32(), - }, + Sha1: r.ReadBytes(20), Name: r.ReadStringWithLength("u32", true), - UUID: r.ReadBytes(r.Len()), + UUID: r.ReadStringWithLength("u32", true), } } diff --git a/coolq/event.go b/coolq/event.go index d422f088c..d00d47f2c 100644 --- a/coolq/event.go +++ b/coolq/event.go @@ -534,21 +534,16 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement, source message.Source) switch i := elem.(type) { case *message.ImageElement: // 闪照已经4了(私聊还没) - //if i.Flash && sourceID != 0 { - // u, err := bot.Client.GetGroupImageDownloadUrl(i.FileId, sourceID, i.Md5) + //if i.Flash && source.PrimaryID != 0 { + // u, err := bot.Client.GetGroupImageURL(uint32(source.PrimaryID), i.MsgInfo.MsgInfoBody[0].Index) // if err != nil { // log.Warnf("获取闪照地址时出现错误: %v", err) // } else { - // i.Url = u + // i.URL = u // } //} data := binary.NewWriterF(func(w *binary.Builder) { - _, err := w.Write(i.Md5) - if err != nil { - log.Warnf("计算图片md5时出现错误: %v", err) - return - } - + _, _ = w.Write(i.Md5) w.WritePacketString(i.FileUUID, "u32", true) w.WritePacketString(i.ImageID, "u32", true) }) @@ -567,18 +562,10 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement, source message.Source) } case *message.ShortVideoElement: data := binary.NewWriterF(func(w *binary.Builder) { - _, err := w.Write(i.Md5) - if err != nil { - log.Warnf("计算视频md5时出现错误: %v", err) - return - } - _, err = w.Write(i.Sha1) - if err != nil { - log.Warnf("计算视频sha1时出现错误: %v", err) - return - } + _, _ = w.Write(i.Md5) + _, _ = w.Write(i.Sha1) w.WritePacketString(i.Name, "u32", true) - w.WritePacketBytes(i.UUID, "u32", true) + w.WritePacketString(i.UUID, "u32", true) }) filename := hex.EncodeToString(i.Md5) + ".video" cache.Video.Insert(i.Md5, data) diff --git a/go.mod b/go.mod index b2b481430..3df8aecf8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/FloatTech/sqlite v1.6.3 - github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241112102104-63ccad50ea67 + github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114034146-304fa373b532 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 diff --git a/go.sum b/go.sum index ae33fd1d3..7d8c36c6b 100644 --- a/go.sum +++ b/go.sum @@ -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.20241112102104-63ccad50ea67 h1:rbD3p2W6IaQxaZIo1X5fWxeRStHb+VeJBhBITUg2bhE= -github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241112102104-63ccad50ea67/go.mod h1:m7ydyvA8DKOg5c6iTFDfNtfIK9uhqXVJKRXl4mlGkTA= +github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114034146-304fa373b532 h1:fcNkzgqc31OKtBm19XyT6GXKF/OvH9bWvmiUKKENjTM= +github.com/LagrangeDev/LagrangeGo v0.1.2-0.20241114034146-304fa373b532/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=