Skip to content

Commit 4d0c204

Browse files
authored
[FIX] 添加JSON序列化反序列化接口,修复若干问题 (#160)
* 这个ParseTempMessage返回的消息不完整导致临时信息接收错误 * 更新了ToReadableStringEle支持所有有的消息类型 * 添加了JSON模块,现在对于消息的序列化和反序列化都能够正常进行了 * 添加了对于私聊消息和临时消息的实现 * Update json.go * Update json.go * 更新协议发现内部未使用函数。暴露接口 * 修复了FetchFriends函数及一些使用这个直接获得自己uin的函数
1 parent eb83ec6 commit 4d0c204

9 files changed

Lines changed: 434 additions & 9 deletions

File tree

client/auth/app.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,27 @@ var AppList = map[string]map[string]*AppInfo{
9797
SubSigmap: 0,
9898
NTLoginType: 1,
9999
},
100+
101+
"3.2.19-39038": {
102+
OS: "Linux",
103+
Kernel: "Linux",
104+
VendorOS: "linux",
105+
106+
CurrentVersion: "3.2.19-39038",
107+
BuildVersion: 39038,
108+
MiscBitmap: 32764,
109+
PTVersion: "2.0.0",
110+
PTOSVersion: 19,
111+
PackageName: "com.tencent.qq",
112+
WTLoginSDK: "nt.wtlogin.0.0.1",
113+
AppID: 1600001615,
114+
SubAppID: 537313942,
115+
AppIDQrcode: 537313942,
116+
AppClientVersion: 39038,
117+
MainSigmap: 169742560,
118+
SubSigmap: 0,
119+
NTLoginType: 1,
120+
},
100121
},
101122

102123
"macos": {

client/base.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ func (c *QQClient) AddSignServer(signServers ...string) {
137137
c.signProvider.AddSignServer(signServers...)
138138
}
139139

140+
// GetSignServer 获得所有签名服务器
141+
func (c *QQClient) GetSignServer() []string {
142+
return c.signProvider.GetSignServer()
143+
}
144+
140145
// AddSignHeader 设置签名服务器签名时的额外http header
141146
func (c *QQClient) AddSignHeader(header map[string]string) {
142147
if c.signProvider == nil {

client/cache.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
package client
22

33
import (
4+
"strconv"
45
"time"
56

67
"github.com/LagrangeDev/LagrangeGo/client/entity"
78
)
89

10+
var selfUin string
11+
912
// GetUID 获取缓存中对应uin的uid
1013
func (c *QQClient) GetUID(uin uint32, groupUin ...uint32) string {
1114
if uin == 0 {
1215
return ""
1316
}
17+
if uin == c.Uin {
18+
if selfUin == "" {
19+
selfUin = strconv.FormatUint(uint64(uin), 10)
20+
}
21+
return selfUin
22+
}
1423
if len(groupUin) == 0 && c.cache.FriendCacheIsEmpty() {
1524
if err := c.RefreshFriendCache(); err != nil {
1625
return ""

client/packets/oidb/fetch_friends.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ func BuildFetchFriendsReq(token uint32) (*Packet, error) {
1111
body := oidb.OidbSvcTrpcTcp0XFD4_1{
1212
Field2: 300,
1313
Field4: 0,
14-
NextUin: &oidb.OidbSvcTrpcTcp0XFD4_1Uin{
15-
Uin: token,
16-
},
1714
Field6: 1,
15+
Field7: 2147483647,
1816
Body: []*oidb.OidbSvcTrpcTcp0XFD4_1Body{{
1917
Type: 1,
2018
Number: &oidb.OidbNumber{Numbers: []uint32{103, 102, 20002, 27394}},
@@ -25,6 +23,11 @@ func BuildFetchFriendsReq(token uint32) (*Packet, error) {
2523
Field10002: []uint32{13578, 13579, 13573, 13572, 13568},
2624
Field10003: 4051,
2725
}
26+
if token != 0 {
27+
body.NextUin = &oidb.OidbSvcTrpcTcp0XFD4_1Uin{
28+
Uin: token,
29+
}
30+
}
2831
/*
2932
* OidbNumber里面的东西代表你想要拿到的Property,这些Property将会在返回的数据里面的Preserve的Field,
3033
* 102:个性签名

client/packets/pb/service/oidb/OidbSvcTrpcTcp0xFD4_1.pb.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/packets/pb/service/oidb/OidbSvcTrpcTcp0xFD4_1.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ message OidbSvcTrpcTcp0xFD4_1 {
1010
uint32 Field4 = 4; // 0
1111
OidbSvcTrpcTcp0xFD4_1Uin NextUin = 5;
1212
uint32 Field6 = 6; // 1
13+
uint32 Field7 = 7; // 2,147,483,647
1314
repeated OidbSvcTrpcTcp0xFD4_1Body Body = 10001;
1415
repeated uint32 Field10002 = 10002; // [13578, 13579, 13573, 13572, 13568]
1516
uint32 Field10003 = 10003;

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
)
2626

2727
func main() {
28-
appInfo := auth.AppList["linux"]["3.2.15-30366"]
28+
appInfo := auth.AppList["linux"]["3.2.19-39038"]
2929
deviceInfo := &auth.DeviceInfo{
3030
GUID: "cfcd208495d565ef66e7dff9f98764da",
3131
DeviceName: "Lagrange-DCFCD07E",
@@ -36,7 +36,7 @@ func main() {
3636
qqclient := client.NewClient(0, "")
3737
qqclient.SetLogger(protocolLogger{})
3838
qqclient.UseVersion(appInfo)
39-
qqclient.AddSignServer("https://sign.lagrangecore.org/api/sign/30366")
39+
qqclient.AddSignServer("https://sign.lagrangecore.org/api/sign/39038")
4040
qqclient.UseDevice(deviceInfo)
4141
data, err := os.ReadFile("sig.bin")
4242
if err != nil {

0 commit comments

Comments
 (0)