From c9ba1fa296e9b1d20902991a4be43b6c99f06ab6 Mon Sep 17 00:00:00 2001 From: Fripine Date: Fri, 11 Oct 2024 01:34:05 +0800 Subject: [PATCH] chore --- cmd/gocq/main.go | 33 ++++++++++++++++----------------- coolq/cqcode.go | 8 ++++---- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/cmd/gocq/main.go b/cmd/gocq/main.go index 8212f2a69..297706535 100644 --- a/cmd/gocq/main.go +++ b/cmd/gocq/main.go @@ -235,22 +235,11 @@ func LoginInteract() { } else if len(base.Account.Password) > 0 { base.PasswordHash = md5.Sum([]byte(base.Account.Password)) } - if !base.FastStart { - log.Info("Bot将在5秒后登录并开始信息处理, 按 Ctrl+C 取消.") - time.Sleep(time.Second * 5) - } - log.Info("开始尝试登录并同步消息...") - log.Infof("使用协议: %s", device.Protocol.Version()) + // if !base.FastStart { + // log.Info("Bot将在5秒后登录并开始信息处理, 按 Ctrl+C 取消.") + // time.Sleep(time.Second * 5) + // } cli = newClient() - cli.UseDevice(device) - isQRCodeLogin := (base.Account.Uin == 0 || len(base.Account.Password) == 0) && !base.Account.Encrypt - isTokenLogin := false - - if isQRCodeLogin && cli.Device().Protocol != 2 { - log.Warn("当前协议不支持二维码登录, 请配置账号密码登录.") - os.Exit(0) - } - // 加载本地版本信息, 一般是在上次登录时保存的 versionFile := path.Join(global.VersionsPath, fmt.Sprint(int(cli.Device().Protocol))+".json") if global.PathExists(versionFile) { @@ -266,6 +255,16 @@ func LoginInteract() { } log.Infof("从文件 %s 读取协议版本 %v.", versionFile, cli.Device().Protocol.Version()) } + cli.UseDevice(device) + log.Info("开始尝试登录并同步消息...") + log.Infof("使用协议: %s", device.Protocol.Version()) + isQRCodeLogin := (base.Account.Uin == 0 || len(base.Account.Password) == 0) && !base.Account.Encrypt + isTokenLogin := false + + if isQRCodeLogin && cli.Device().Protocol != 2 { + log.Warn("当前协议不支持二维码登录, 请配置账号密码登录.") + os.Exit(0) + } saveToken := func() { base.AccountToken = cli.GenToken() @@ -482,8 +481,8 @@ func newClient() *client.QQClient { } var remoteVersions = map[int]string{ - 1: "https://raw.githubusercontent.com/RomiChan/protocol-versions/master/android_phone.json", - 6: "https://raw.githubusercontent.com/RomiChan/protocol-versions/master/android_pad.json", + 1: "https://raw.githubusercontent.com/sealdice/protocol-versions/master/android_phone.json", + 6: "https://raw.githubusercontent.com/sealdice/protocol-versions/master/android_pad.json", } func getRemoteLatestProtocolVersion(protocolType int) ([]byte, error) { diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 5839f02ca..aed3c4b5a 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -167,7 +167,7 @@ func toElements(e []message.IMessageElement, source message.Source) (r []msg.Ele } case *message.GroupImageElement: data := pairs{ - {K: "file", V: hex.EncodeToString(o.Md5) + ".image"}, + {K: "file", V: o.ImageId}, {K: "subType", V: strconv.FormatInt(int64(o.ImageBizType), 10)}, {K: "url", V: o.Url}, } @@ -193,7 +193,7 @@ func toElements(e []message.IMessageElement, source message.Source) (r []msg.Ele } case *message.FriendImageElement: data := pairs{ - {K: "file", V: hex.EncodeToString(o.Md5) + ".image"}, + {K: "file", V: o.ImageId}, {K: "url", V: o.Url}, } if o.Flash { @@ -339,7 +339,7 @@ func ToMessageContent(e []message.IMessageElement, source message.Source) (r []g "data": global.MSG{"file": o.Name, "url": o.Url}, } case *message.GroupImageElement: - data := global.MSG{"file": hex.EncodeToString(o.Md5) + ".image", "url": o.Url, "subType": uint32(o.ImageBizType)} + data := global.MSG{"file": o.ImageId, "url": o.Url, "subType": uint32(o.ImageBizType)} switch { case o.Flash: data["type"] = "flash" @@ -357,7 +357,7 @@ func ToMessageContent(e []message.IMessageElement, source message.Source) (r []g "data": global.MSG{"file": hex.EncodeToString(o.Md5) + ".image", "url": o.Url}, } case *message.FriendImageElement: - data := global.MSG{"file": hex.EncodeToString(o.Md5) + ".image", "url": o.Url} + data := global.MSG{"file": o.ImageId, "url": o.Url} if o.Flash { data["type"] = "flash" }