From 57b9b0d237133a696eaaa550997ab0eab74b6c71 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:57:41 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E7=BE=A4=E6=89=93=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/operation.go | 13 +++++ client/packets/oidb/group_sign.go | 54 +++++++++++++++++++ .../service/oidb/OidbSvcTrpcTcp0xEB7_1.pb.go | 33 ++++++++++++ .../service/oidb/OidbSvcTrpcTcp0xEB7_1.proto | 28 ++++++++++ 4 files changed, 128 insertions(+) create mode 100644 client/packets/oidb/group_sign.go create mode 100644 client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.pb.go create mode 100644 client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto diff --git a/client/operation.go b/client/operation.go index 50ec565..7fcf3eb 100644 --- a/client/operation.go +++ b/client/operation.go @@ -1280,3 +1280,16 @@ func (c *QQClient) ImageOcr(url string) (*oidb2.OcrResponse, error) { } return nil, errors.New("image error") } + +// SendGroupSign 发送群聊打卡消息 +func (c *QQClient) SendGroupSign(target uint32) (*oidb2.BotGroupClockInResult, error) { + pkt, err := oidb2.BuildGroupSignPacket(c.Uin, target, c.version().CurrentVersion) + if err != nil { + return nil, err + } + resp, err := c.sendOidbPacketAndWait(pkt) + if err != nil { + return nil, err + } + return oidb2.ParseGroupSignResp(resp) +} diff --git a/client/packets/oidb/group_sign.go b/client/packets/oidb/group_sign.go new file mode 100644 index 0000000..844aaba --- /dev/null +++ b/client/packets/oidb/group_sign.go @@ -0,0 +1,54 @@ +package oidb + +import ( + "errors" + "strconv" + + "github.com/LagrangeDev/LagrangeGo/client/packets/pb/service/oidb" +) + +// 群打卡 + +type BotGroupClockInResult struct { + Title string // 今日已成功打卡 + KeepDayText string // 已打卡N天 + GroupRankText string // 群内排名第N位 + ClockInUtcTime int64 // 打卡时间 + DetailUrl string // Detail info url https://qun.qq.com/v2/signin/detail?... +} + +func BuildGroupSignPacket(botUin, groupUin uint32, appVersion string) (*Packet, error) { + body := &oidb.OidbSvcTrpcTcp0XEB7_1_ReqBody{ + SignInWriteReq: &oidb.StSignInWriteReq{ + Uin: strconv.Itoa(int(botUin)), + GroupUin: strconv.Itoa(int(groupUin)), + AppVersion: appVersion, + }, + } + return BuildOidbPacket(0xEB7, 1, body, false, false) +} + +func ParseGroupSignResp(data []byte) (*BotGroupClockInResult, error) { + var rsp oidb.OidbSvcTrpcTcp0XEB7_1_RspBody + _, err := ParseOidbPacket(data, &rsp) + if err != nil { + return nil, err + } + + if rsp.SignInWriteRsp == nil || rsp.SignInWriteRsp.DoneInfo == nil { + return nil, errors.New("SignInWriteRsp or SignInWriteRsp.DoneInfo nil") + } + + ret := &BotGroupClockInResult{ + Title: rsp.SignInWriteRsp.DoneInfo.Title, + KeepDayText: rsp.SignInWriteRsp.DoneInfo.KeepDayText, + DetailUrl: rsp.SignInWriteRsp.DoneInfo.DetailUrl, + } + if size := len(rsp.SignInWriteRsp.DoneInfo.ClockInInfo); size > 0 { + ret.GroupRankText = rsp.SignInWriteRsp.DoneInfo.ClockInInfo[0] + if size > 1 { + ret.ClockInUtcTime, _ = strconv.ParseInt(rsp.SignInWriteRsp.DoneInfo.ClockInInfo[1], 10, 64) + } + } + return ret, nil +} diff --git a/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.pb.go b/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.pb.go new file mode 100644 index 0000000..5be0421 --- /dev/null +++ b/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.pb.go @@ -0,0 +1,33 @@ +// Code generated by protoc-gen-golite. DO NOT EDIT. +// source: pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto + +package oidb + +type OidbSvcTrpcTcp0XEB7_1_ReqBody struct { + SignInWriteReq *StSignInWriteReq `protobuf:"bytes,2,opt"` + _ [0]func() +} + +type StSignInWriteReq struct { + Uin string `protobuf:"bytes,1,opt"` + GroupUin string `protobuf:"bytes,2,opt"` + AppVersion string `protobuf:"bytes,3,opt"` // 不确定要不要加,测试过没有这个参数也是可以的 + _ [0]func() +} + +type OidbSvcTrpcTcp0XEB7_1_RspBody struct { + SignInWriteRsp *StSignInWriteRsp `protobuf:"bytes,2,opt"` + _ [0]func() +} + +type StSignInWriteRsp struct { + DoneInfo *SignInStatusDoneInfo `protobuf:"bytes,2,opt"` + _ [0]func() +} + +type SignInStatusDoneInfo struct { + Title string `protobuf:"bytes,1,opt"` // 今日已成功打卡 + KeepDayText string `protobuf:"bytes,2,opt"` // 已打卡N天 + ClockInInfo []string `protobuf:"bytes,3,rep"` // ["群内排名第N位", "[clock in timestamp (second)]"] + DetailUrl string `protobuf:"bytes,4,opt"` // https://qun.qq.com/v2/signin/detail?... +} diff --git a/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto b/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto new file mode 100644 index 0000000..18be0f8 --- /dev/null +++ b/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +option go_package = "github.com/LagrangeDev/LagrangeGo/client/packets/pb/service/oidb"; + +message OidbSvcTrpcTcp0xEB7_1_ReqBody { + optional StSignInWriteReq signInWriteReq = 2; +} + +message StSignInWriteReq { + string Uin = 1; + string GroupUin = 2; + string AppVersion = 3; // 不确定要不要加,测试过没有这个参数也是可以的 +} + +message OidbSvcTrpcTcp0xEB7_1_RspBody { + optional StSignInWriteRsp signInWriteRsp = 2; +} + +message StSignInWriteRsp { + optional SignInStatusDoneInfo doneInfo = 2; +} + +message SignInStatusDoneInfo { + string Title = 1; // 今日已成功打卡 + string KeepDayText = 2; // 已打卡N天 + repeated string ClockInInfo = 3; // ["群内排名第N位", "[clock in timestamp (second)]"] + string DetailUrl = 4; // https://qun.qq.com/v2/signin/detail?... +} From 705a30c4011955eb1eeaaae8b63f774efcf70175 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:06:33 +0800 Subject: [PATCH 2/4] ... --- client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto b/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto index 18be0f8..d12ba5c 100644 --- a/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto +++ b/client/packets/pb/service/oidb/OidbSvcTrpcTcp0xEB7_1.proto @@ -2,6 +2,8 @@ syntax = "proto3"; option go_package = "github.com/LagrangeDev/LagrangeGo/client/packets/pb/service/oidb"; +// see https://github.com/LagrangeDev/Lagrange.Core/blob/47b819d43ad101a1a066a3f8afa094d000fe19f5/Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0xEB7_1.cs + message OidbSvcTrpcTcp0xEB7_1_ReqBody { optional StSignInWriteReq signInWriteReq = 2; } From 8bed17f82d619711b7a6ca55dc78b1404f6c834c Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:16:41 +0800 Subject: [PATCH 3/4] ... --- client/packets/oidb/group_sign.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/packets/oidb/group_sign.go b/client/packets/oidb/group_sign.go index 844aaba..0261ab5 100644 --- a/client/packets/oidb/group_sign.go +++ b/client/packets/oidb/group_sign.go @@ -14,7 +14,7 @@ type BotGroupClockInResult struct { KeepDayText string // 已打卡N天 GroupRankText string // 群内排名第N位 ClockInUtcTime int64 // 打卡时间 - DetailUrl string // Detail info url https://qun.qq.com/v2/signin/detail?... + DetailURL string // Detail info url https://qun.qq.com/v2/signin/detail?... } func BuildGroupSignPacket(botUin, groupUin uint32, appVersion string) (*Packet, error) { @@ -42,7 +42,7 @@ func ParseGroupSignResp(data []byte) (*BotGroupClockInResult, error) { ret := &BotGroupClockInResult{ Title: rsp.SignInWriteRsp.DoneInfo.Title, KeepDayText: rsp.SignInWriteRsp.DoneInfo.KeepDayText, - DetailUrl: rsp.SignInWriteRsp.DoneInfo.DetailUrl, + DetailURL: rsp.SignInWriteRsp.DoneInfo.DetailUrl, } if size := len(rsp.SignInWriteRsp.DoneInfo.ClockInInfo); size > 0 { ret.GroupRankText = rsp.SignInWriteRsp.DoneInfo.ClockInInfo[0] From 6107d0542671fe0c469eec84fbbdfec6abe8dcb5 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:20:47 +0800 Subject: [PATCH 4/4] ... --- client/operation.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/operation.go b/client/operation.go index 7fcf3eb..03d68ed 100644 --- a/client/operation.go +++ b/client/operation.go @@ -1282,8 +1282,8 @@ func (c *QQClient) ImageOcr(url string) (*oidb2.OcrResponse, error) { } // SendGroupSign 发送群聊打卡消息 -func (c *QQClient) SendGroupSign(target uint32) (*oidb2.BotGroupClockInResult, error) { - pkt, err := oidb2.BuildGroupSignPacket(c.Uin, target, c.version().CurrentVersion) +func (c *QQClient) SendGroupSign(groupUin uint32) (*oidb2.BotGroupClockInResult, error) { + pkt, err := oidb2.BuildGroupSignPacket(c.Uin, groupUin, c.version().CurrentVersion) if err != nil { return nil, err }