1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-06 20:13:50 +08:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
wdvxdr 2020-11-10 12:41:08 +08:00
commit 4659d44a64
15 changed files with 2466 additions and 191 deletions

View File

@ -73,6 +73,29 @@ type (
SetMute byte `jceId:"36"`
}
SvcRespRegister struct {
Uin int64 `jceId:"0"`
Bid int64 `jceId:"1"`
ReplyCode byte `jceId:"2"`
Result string `jceId:"3"`
ServerTime int64 `jceId:"4"`
LogQQ byte `jceId:"5"`
NeedKik byte `jceId:"6"`
UpdateFlag byte `jceId:"7"`
Timestamp int64 `jceId:"8"`
CrashFlag byte `jceId:"9"`
ClientIp string `jceId:"10"`
ClientPort int32 `jceId:"11"`
HelloInterval int32 `jceId:"12"`
LargeSeq int32 `jceId:"13"`
LargeSeqUpdate byte `jceId:"14"`
D769RspBody []byte `jceId:"15"`
Status int32 `jceId:"16"`
ExtOnlineStatus int64 `jceId:"17"`
ClientBatteryGetInterval int64 `jceId:"18"`
ClientAutoStatusInterval int64 `jceId:"19"`
}
PushMessageInfo struct {
FromUin int64 `jceId:"0"`
MsgTime int64 `jceId:"1"`
@ -362,6 +385,14 @@ type (
ReqNearbyGodInfo byte `jceId:"20"`
ReqExtendCard byte `jceId:"22"`
}
SummaryCardReqSearch struct {
IJceStruct
Keyword string `jceId:"0"`
CountryCode string `jceId:"1"`
Version int32 `jceId:"2"`
ReqServices [][]byte `jceId:"3"` // busi
}
)
func (pkt *RequestPacket) ToBytes() []byte {
@ -421,6 +452,27 @@ func (pkt *SvcReqRegister) ToBytes() []byte {
return w.Bytes()
}
func (pkt *SvcRespRegister) ReadFrom(r *JceReader) {
pkt.Uin = r.ReadInt64(0)
pkt.Bid = r.ReadInt64(1)
pkt.ReplyCode = r.ReadByte(2)
pkt.Result = r.ReadString(3)
pkt.ServerTime = r.ReadInt64(4)
pkt.LogQQ = r.ReadByte(5)
pkt.NeedKik = r.ReadByte(6)
pkt.UpdateFlag = r.ReadByte(7)
pkt.Timestamp = r.ReadInt64(8)
pkt.CrashFlag = r.ReadByte(9)
pkt.ClientIp = r.ReadString(10)
pkt.ClientPort = r.ReadInt32(11)
pkt.HelloInterval = r.ReadInt32(12)
pkt.LargeSeq = r.ReadInt32(13)
pkt.LargeSeqUpdate = r.ReadByte(14)
pkt.D769RspBody = r.ReadAny(15).([]byte)
pkt.Status = r.ReadInt32(16)
pkt.ExtOnlineStatus = r.ReadInt64(17)
}
func (pkt *FriendListRequest) ToBytes() []byte {
w := NewJceWriter()
w.WriteJceStructRaw(pkt)
@ -433,6 +485,12 @@ func (pkt *SummaryCardReq) ToBytes() []byte {
return w.Bytes()
}
func (pkt *SummaryCardReqSearch) ToBytes() []byte {
w := NewJceWriter()
w.WriteJceStructRaw(pkt)
return w.Bytes()
}
func (pkt *FriendInfo) ReadFrom(r *JceReader) {
pkt.FriendUin = r.ReadInt64(0)
pkt.GroupId = r.ReadByte(1)

View File

@ -112,6 +112,23 @@ func (w *JceWriter) WriteInt64Slice(l []int64, tag int) {
}
}
func (w *JceWriter) WriteSlice(i interface{}, tag int) {
va := reflect.ValueOf(i)
if va.Kind() != reflect.Slice {
return
}
w.writeHead(9, tag)
if va.Len() == 0 {
w.WriteInt32(0, 0)
return
}
w.WriteInt32(int32(va.Len()), 0)
for i := 0; i < va.Len(); i++ {
v := va.Index(i)
w.WriteObject(v.Interface(), 0)
}
}
func (w *JceWriter) WriteJceStructSlice(l []IJceStruct, tag int) {
w.writeHead(9, tag)
if len(l) == 0 {
@ -149,6 +166,10 @@ func (w *JceWriter) WriteObject(i interface{}, tag int) {
w.WriteMap(i, tag)
return
}
if t.Kind() == reflect.Slice {
w.WriteSlice(i, tag)
return
}
switch o := i.(type) {
case byte:
w.WriteByte(o, tag)
@ -166,14 +187,8 @@ func (w *JceWriter) WriteObject(i interface{}, tag int) {
w.WriteFloat64(o, tag)
case string:
w.WriteString(o, tag)
case []byte:
w.WriteBytes(o, tag)
case []int64:
w.WriteInt64Slice(o, tag)
case IJceStruct:
w.WriteJceStruct(o, tag)
case []IJceStruct:
w.WriteJceStructSlice(o, tag)
}
}

View File

@ -244,7 +244,7 @@ func (c *QQClient) buildClientRegisterPacket() (uint16, []byte) {
ChannelNo: "",
CPID: 0,
VendorName: "MIUI",
VendorOSName: "ONEPLUS A5000_23_17",
VendorOSName: string(SystemDeviceInfo.Product),
B769: []byte{0x0A, 0x04, 0x08, 0x2E, 0x10, 0x00, 0x0A, 0x05, 0x08, 0x9B, 0x02, 0x10, 0x00},
SetMute: 0,
}
@ -1041,54 +1041,6 @@ func (c *QQClient) buildGroupAdminSetPacket(groupCode, member int64, flag bool)
return seq, packet
}
// OidbSvc.0x88d_0
func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.D88DReqBody{
AppId: proto.Uint32(c.version.AppId),
ReqGroupInfo: []*oidb.ReqGroupInfo{
{
GroupCode: proto.Uint64(uint64(groupCode)),
Stgroupinfo: &oidb.D88DGroupInfo{
GroupOwner: proto.Uint64(0),
GroupUin: proto.Uint64(0),
GroupCreateTime: proto.Uint32(0),
GroupFlag: proto.Uint32(0),
GroupMemberMaxNum: proto.Uint32(0),
GroupMemberNum: proto.Uint32(0),
GroupOption: proto.Uint32(0),
GroupLevel: proto.Uint32(0),
GroupFace: proto.Uint32(0),
GroupName: EmptyBytes,
GroupMemo: EmptyBytes,
GroupFingerMemo: EmptyBytes,
GroupLastMsgTime: proto.Uint32(0),
GroupQuestion: EmptyBytes,
GroupAnswer: EmptyBytes,
GroupGrade: proto.Uint32(0),
ActiveMemberNum: proto.Uint32(0),
HeadPortraitSeq: proto.Uint32(0),
MsgHeadPortrait: &oidb.D88DGroupHeadPortrait{},
StGroupExInfo: &oidb.D88DGroupExInfoOnly{},
GroupSecLevel: proto.Uint32(0),
CmduinPrivilege: proto.Uint32(0),
NoFingerOpenFlag: proto.Uint32(0),
NoCodeFingerOpenFlag: proto.Uint32(0),
},
},
},
PcClientVersion: proto.Uint32(0),
}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 2189,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x88d_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// ProfileService.GroupMngReq
func (c *QQClient) buildQuitGroupPacket(groupCode int64) (uint16, []byte) {
seq := c.nextSeq()
@ -1113,28 +1065,6 @@ func (c *QQClient) buildQuitGroupPacket(groupCode int64) (uint16, []byte) {
return seq, packet
}
// OidbSvc.0x6d6_2
func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId string, busId int32) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.D6D6ReqBody{
DownloadFileReq: &oidb.DownloadFileReqBody{
GroupCode: groupCode,
AppId: 3,
BusId: busId,
FileId: fileId,
},
}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 1750,
ServiceType: 2,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_2", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// OidbSvc.0xe07_0
func (c *QQClient) buildImageOcrRequestPacket(url, md5 string, size, weight, height int32) (uint16, []byte) {
seq := c.nextSeq()

View File

@ -152,11 +152,13 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
"MultiMsg.ApplyUp": decodeMultiApplyUpResponse,
"MultiMsg.ApplyDown": decodeMultiApplyDownResponse,
"OidbSvc.0x6d6_2": decodeOIDB6d6Response,
"OidbSvc.0x6d8_1": decodeOIDB6d81Response,
"OidbSvc.0x88d_0": decodeGroupInfoResponse,
"OidbSvc.0xe07_0": decodeImageOcrResponse,
"OidbSvc.0xd79": decodeWordSegmentation,
"OidbSvc.0x990": decodeTranslateResponse,
"SummaryCard.ReqSummaryCard": decodeSummaryCardResponse,
"SummaryCard.ReqSearch": decodeGroupSearchResponse,
"PttCenterSvr.ShortVideoDownReq": decodePttShortVideoDownResponse,
"LightAppSvc.mini_app_info.GetAppInfoById": decodeAppInfoResponse,
"OfflineFilleHandleSvr.pb_ftn_CMD_REQ_APPLY_DOWNLOAD-1200": decodeOfflineFileDownloadResponse,
@ -208,6 +210,7 @@ func (c *QQClient) Login() (*LoginResponse, error) {
seq, packet := c.buildLoginPacket()
rsp, err := c.sendAndWait(seq, packet)
if err != nil {
c.Disconnect()
return nil, err
}
l := rsp.(LoginResponse)
@ -245,7 +248,7 @@ func (c *QQClient) SubmitSMS(code string) (*LoginResponse, error) {
func (c *QQClient) init() {
c.Online = true
c.registerClient()
_ = c.registerClient()
c.groupSysMsgCache, _ = c.GetGroupSystemMessages()
if !c.heartbeatEnabled {
c.startHeartbeat()
@ -370,24 +373,6 @@ func (c *QQClient) GetShortVideoUrl(uuid, md5 []byte) string {
return i.(string)
}
func (c *QQClient) GetGroupFileUrl(groupCode int64, fileId string, busId int32) string {
i, err := c.sendAndWait(c.buildGroupFileDownloadReqPacket(groupCode, fileId, busId))
if err != nil {
return ""
}
url := i.(string)
url += "?fname=" + hex.EncodeToString([]byte(fileId))
return url
}
func (c *QQClient) GetGroupInfo(groupCode int64) (*GroupInfo, error) {
i, err := c.sendAndWait(c.buildGroupInfoRequestPacket(groupCode))
if err != nil {
return nil, err
}
return i.(*GroupInfo), nil
}
func (c *QQClient) SendGroupMessage(groupCode int64, m *message.SendingMessage, f ...bool) *message.GroupMessage {
useFram := false
if len(f) > 0 {
@ -964,9 +949,9 @@ func (c *QQClient) SendGroupGift(groupCode, uin uint64, gift message.GroupGift)
_ = c.send(packet)
}
func (c *QQClient) registerClient() {
_, packet := c.buildClientRegisterPacket()
_ = c.send(packet)
func (c *QQClient) registerClient() error {
_, err := c.sendAndWait(c.buildClientRegisterPacket())
return err
}
func (c *QQClient) nextSeq() uint16 {
@ -1049,7 +1034,12 @@ func (c *QQClient) netLoop() {
break
}
reader = binary.NewNetworkReader(c.Conn)
c.registerClient()
if c.registerClient() != nil {
c.Disconnect()
c.lastLostMsg = "register client failed."
c.Error("reconnect failed: register client failed.")
break
}
}
if l <= 0 {
retry++
@ -1063,8 +1053,11 @@ func (c *QQClient) netLoop() {
pkt, err := packets.ParseIncomingPacket(data, c.sigInfo.d2Key)
if err != nil {
c.Error("parse incoming packet error: %v", err)
if err == packets.ErrSessionExpired {
break
}
errCount++
if errCount > 5 {
if errCount > 2 {
break
}
//log.Println("parse incoming packet error: " + err.Error())

View File

@ -1,7 +1,6 @@
package client
import (
"encoding/hex"
"errors"
"fmt"
"github.com/Mrs4s/MiraiGo/client/pb/notify"
@ -171,6 +170,11 @@ func decodeClientRegisterResponse(_ *QQClient, _ uint16, payload []byte) (interf
request.ReadFrom(jce.NewJceReader(payload))
data := &jce.RequestDataVersion2{}
data.ReadFrom(jce.NewJceReader(request.SBuffer))
svcRsp := &jce.SvcRespRegister{}
svcRsp.ReadFrom(jce.NewJceReader(data.Map["SvcRespRegister"]["QQService.SvcRespRegister"][1:]))
if svcRsp.Result != "" || svcRsp.Status != 11 {
return nil, errors.New("reg failed")
}
return nil, nil
}
@ -518,33 +522,6 @@ func decodeGroupListResponse(c *QQClient, _ uint16, payload []byte) (interface{}
return l, nil
}
// OidbSvc.0x88d_0
func decodeGroupInfoResponse(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
pkg := oidb.OIDBSSOPkg{}
rsp := oidb.D88DRspBody{}
if err := proto.Unmarshal(payload, &pkg); err != nil {
return nil, err
}
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
return nil, err
}
if len(rsp.RspGroupInfo) == 0 {
return nil, errors.New(string(rsp.StrErrorInfo))
}
info := rsp.RspGroupInfo[0]
return &GroupInfo{
Uin: int64(*info.GroupInfo.GroupUin),
Code: int64(*info.GroupCode),
Name: string(info.GroupInfo.GroupName),
Memo: string(info.GroupInfo.GroupMemo),
OwnerUin: int64(*info.GroupInfo.GroupOwner),
MemberCount: uint16(*info.GroupInfo.GroupMemberNum),
MaxMemberCount: uint16(*info.GroupInfo.GroupMemberMaxNum),
Members: []*GroupMemberInfo{},
client: c,
}, nil
}
// friendlist.GetTroopMemberListReq
func decodeGroupMemberListResponse(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
request := &jce.RequestPacket{}
@ -992,21 +969,6 @@ func decodeWordSegmentation(_ *QQClient, _ uint16, payload []byte) (interface{},
return nil, errors.New("no word receive")
}
// OidbSvc.0x6d6_2
func decodeOIDB6d6Response(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
pkg := oidb.OIDBSSOPkg{}
rsp := oidb.D6D6RspBody{}
if err := proto.Unmarshal(payload, &pkg); err != nil {
return nil, err
}
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
return nil, err
}
ip := rsp.DownloadFileRsp.DownloadIp
url := hex.EncodeToString(rsp.DownloadFileRsp.DownloadUrl)
return fmt.Sprintf("http://%s/ftn_handler/%s/", ip, url), nil
}
// OidbSvc.0xe07_0
func decodeImageOcrResponse(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
pkg := oidb.OIDBSSOPkg{}

260
client/group_file.go Normal file
View File

@ -0,0 +1,260 @@
package client
import (
"encoding/hex"
"errors"
"fmt"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/protocol/packets"
"github.com/golang/protobuf/proto"
)
type (
GroupFileSystem struct {
FileCount uint32 `json:"file_count"`
LimitCount uint32 `json:"limit_count"`
UsedSpace uint64 `json:"used_space"`
TotalSpace uint64 `json:"total_space"`
GroupCode int64 `json:"group_id"`
client *QQClient
}
GroupFile struct {
GroupCode int64 `json:"group_id"`
FileId string `json:"file_id"`
FileName string `json:"file_name"`
BusId int32 `json:"busid"`
FileSize int64 `json:"file_size"`
UploadTime int64 `json:"upload_time"`
DeadTime int64 `json:"dead_time"`
ModifyTime int64 `json:"modify_time"`
DownloadTimes int64 `json:"download_times"`
Uploader int64 `json:"uploader"`
UploaderName string `json:"uploader_name"`
}
GroupFolder struct {
GroupCode int64 `json:"group_id"`
FolderId string `json:"folder_id"`
FolderName string `json:"folder_name"`
CreateTime int64 `json:"create_time"`
Creator int64 `json:"creator"`
CreatorName string `json:"creator_name"`
TotalFileCount uint32 `json:"total_file_count"`
}
)
func (c *QQClient) GetGroupFileSystem(groupCode int64) (fs *GroupFileSystem, err error) {
defer func() {
if pan := recover(); pan != nil {
c.Error("get group fs error: %v", pan)
err = errors.New("fs error")
}
}()
g := c.FindGroup(groupCode)
if g == nil {
return nil, errors.New("group not found")
}
rsp, e := c.sendAndWait(c.buildGroupFileCountRequestPacket(groupCode))
if e != nil {
return nil, e
}
fs = &GroupFileSystem{
FileCount: rsp.(*oidb.D6D8RspBody).FileCountRsp.GetAllFileCount(),
LimitCount: rsp.(*oidb.D6D8RspBody).FileCountRsp.GetLimitCount(),
GroupCode: groupCode,
client: c,
}
rsp, err = c.sendAndWait(c.buildGroupFileSpaceRequestPacket(groupCode))
if err != nil {
return nil, err
}
fs.TotalSpace = rsp.(*oidb.D6D8RspBody).GroupSpaceRsp.GetTotalSpace()
fs.UsedSpace = rsp.(*oidb.D6D8RspBody).GroupSpaceRsp.GetUsedSpace()
return fs, nil
}
func (c *QQClient) GetGroupFileUrl(groupCode int64, fileId string, busId int32) string {
i, err := c.sendAndWait(c.buildGroupFileDownloadReqPacket(groupCode, fileId, busId))
if err != nil {
return ""
}
url := i.(string)
url += "?fname=" + hex.EncodeToString([]byte(fileId))
return url
}
func (fs *GroupFileSystem) Root() ([]*GroupFile, []*GroupFolder, error) {
return fs.GetFilesByFolder("/")
}
func (fs *GroupFileSystem) GetFilesByFolder(folderId string) ([]*GroupFile, []*GroupFolder, error) {
var startIndex uint32 = 0
var files []*GroupFile
var folders []*GroupFolder
for {
i, err := fs.client.sendAndWait(fs.client.buildGroupFileListRequestPacket(fs.GroupCode, folderId, startIndex))
if err != nil {
return nil, nil, err
}
rsp := i.(*oidb.D6D8RspBody)
if rsp.FileListInfoRsp == nil {
break
}
for _, item := range rsp.FileListInfoRsp.ItemList {
if item.FileInfo != nil {
files = append(files, &GroupFile{
GroupCode: fs.GroupCode,
FileId: item.FileInfo.GetFileId(),
FileName: item.FileInfo.GetFileName(),
BusId: int32(item.FileInfo.GetBusId()),
FileSize: int64(item.FileInfo.GetFileSize()),
UploadTime: int64(item.FileInfo.GetUploadTime()),
DeadTime: int64(item.FileInfo.GetDeadTime()),
ModifyTime: int64(item.FileInfo.GetModifyTime()),
DownloadTimes: int64(item.FileInfo.GetDownloadTimes()),
Uploader: int64(item.FileInfo.GetUploaderUin()),
UploaderName: item.FileInfo.GetUploaderName(),
})
}
if item.FolderInfo != nil {
folders = append(folders, &GroupFolder{
GroupCode: fs.GroupCode,
FolderId: item.FolderInfo.GetFolderId(),
FolderName: item.FolderInfo.GetFolderName(),
CreateTime: int64(item.FolderInfo.GetCreateTime()),
Creator: int64(item.FolderInfo.GetCreateUin()),
CreatorName: item.FolderInfo.GetCreatorName(),
TotalFileCount: item.FolderInfo.GetTotalFileCount(),
})
}
}
if rsp.FileListInfoRsp.GetIsEnd() {
break
}
startIndex = rsp.FileListInfoRsp.GetNextIndex()
}
return files, folders, nil
}
func (fs *GroupFileSystem) GetDownloadUrl(file *GroupFile) string {
return fs.client.GetGroupFileUrl(file.GroupCode, file.FileId, file.BusId)
}
// OidbSvc.0x6d8_1
func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderId string, startIndex uint32) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.D6D8ReqBody{FileListInfoReq: &oidb.GetFileListReqBody{
GroupCode: proto.Uint64(uint64(groupCode)),
AppId: proto.Uint32(3),
FolderId: &folderId,
FileCount: proto.Uint32(20),
AllFileCount: proto.Uint32(0),
ReqFrom: proto.Uint32(3),
SortBy: proto.Uint32(1),
FilterCode: proto.Uint32(0),
Uin: proto.Uint64(0),
StartIndex: &startIndex,
Context: EmptyBytes,
}}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 1752,
ServiceType: 1,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d8_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
func (c *QQClient) buildGroupFileCountRequestPacket(groupCode int64) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.D6D8ReqBody{GroupFileCountReq: &oidb.GetFileCountReqBody{
GroupCode: proto.Uint64(uint64(groupCode)),
AppId: proto.Uint32(3),
BusId: proto.Uint32(0),
}}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 1752,
ServiceType: 2,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d8_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
func (c *QQClient) buildGroupFileSpaceRequestPacket(groupCode int64) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.D6D8ReqBody{GroupSpaceReq: &oidb.GetSpaceReqBody{
GroupCode: proto.Uint64(uint64(groupCode)),
AppId: proto.Uint32(3),
}}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 1752,
ServiceType: 3,
Bodybuffer: b,
ClientVersion: "android 8.4.8",
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d8_1", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// OidbSvc.0x6d6_2
func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId string, busId int32) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.D6D6ReqBody{
DownloadFileReq: &oidb.DownloadFileReqBody{
GroupCode: groupCode,
AppId: 3,
BusId: busId,
FileId: fileId,
},
}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 1750,
ServiceType: 2,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_2", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
func decodeOIDB6d81Response(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
pkg := oidb.OIDBSSOPkg{}
rsp := oidb.D6D8RspBody{}
if err := proto.Unmarshal(payload, &pkg); err != nil {
return nil, err
}
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
return nil, err
}
return &rsp, nil
}
// OidbSvc.0x6d6_2
func decodeOIDB6d6Response(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
pkg := oidb.OIDBSSOPkg{}
rsp := oidb.D6D6RspBody{}
if err := proto.Unmarshal(payload, &pkg); err != nil {
return nil, err
}
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
return nil, err
}
if rsp.DownloadFileRsp.DownloadUrl == nil {
return nil, errors.New(rsp.DownloadFileRsp.ClientWording)
}
ip := rsp.DownloadFileRsp.DownloadIp
url := hex.EncodeToString(rsp.DownloadFileRsp.DownloadUrl)
return fmt.Sprintf("http://%s/ftn_handler/%s/", ip, url), nil
}

146
client/group_info.go Normal file
View File

@ -0,0 +1,146 @@
package client
import (
"errors"
"github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/binary/jce"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/protocol/packets"
"google.golang.org/protobuf/proto"
)
func (c *QQClient) GetGroupInfo(groupCode int64) (*GroupInfo, error) {
i, err := c.sendAndWait(c.buildGroupInfoRequestPacket(groupCode))
if err != nil {
return nil, err
}
return i.(*GroupInfo), nil
}
// OidbSvc.0x88d_0
func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.D88DReqBody{
AppId: proto.Uint32(c.version.AppId),
ReqGroupInfo: []*oidb.ReqGroupInfo{
{
GroupCode: proto.Uint64(uint64(groupCode)),
Stgroupinfo: &oidb.D88DGroupInfo{
GroupOwner: proto.Uint64(0),
GroupUin: proto.Uint64(0),
GroupCreateTime: proto.Uint32(0),
GroupFlag: proto.Uint32(0),
GroupMemberMaxNum: proto.Uint32(0),
GroupMemberNum: proto.Uint32(0),
GroupOption: proto.Uint32(0),
GroupLevel: proto.Uint32(0),
GroupFace: proto.Uint32(0),
GroupName: EmptyBytes,
GroupMemo: EmptyBytes,
GroupFingerMemo: EmptyBytes,
GroupLastMsgTime: proto.Uint32(0),
GroupQuestion: EmptyBytes,
GroupAnswer: EmptyBytes,
GroupGrade: proto.Uint32(0),
ActiveMemberNum: proto.Uint32(0),
HeadPortraitSeq: proto.Uint32(0),
MsgHeadPortrait: &oidb.D88DGroupHeadPortrait{},
StGroupExInfo: &oidb.D88DGroupExInfoOnly{},
GroupSecLevel: proto.Uint32(0),
CmduinPrivilege: proto.Uint32(0),
NoFingerOpenFlag: proto.Uint32(0),
NoCodeFingerOpenFlag: proto.Uint32(0),
},
},
},
PcClientVersion: proto.Uint32(0),
}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 2189,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x88d_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// SummaryCard.ReqSearch
func (c *QQClient) buildGroupSearchPacket(keyword string) (uint16, []byte) {
seq := c.nextSeq()
req := &jce.SummaryCardReqSearch{
Keyword: keyword,
CountryCode: "+86",
Version: 3,
ReqServices: [][]byte{},
}
head := jce.NewJceWriter()
head.WriteInt32(2, 0)
buf := &jce.RequestDataVersion3{Map: map[string][]byte{
"ReqHead": packRequestDataV3(head.Bytes()),
"ReqSearch": packRequestDataV3(req.ToBytes()),
}}
pkt := &jce.RequestPacket{
IVersion: 3,
SServantName: "SummaryCardServantObj",
SFuncName: "ReqSearch",
SBuffer: buf.ToBytes(),
Context: make(map[string]string),
Status: make(map[string]string),
}
packet := packets.BuildUniPacket(c.Uin, seq, "SummaryCard.ReqSearch", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
return seq, packet
}
// SummaryCard.ReqSearch
func decodeGroupSearchResponse(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
request := &jce.RequestPacket{}
request.ReadFrom(jce.NewJceReader(payload))
data := &jce.RequestDataVersion2{}
data.ReadFrom(jce.NewJceReader(request.SBuffer))
if len(data.Map["RespHead"]["SummaryCard.RespHead"]) > 20 {
return nil, errors.New("not found")
}
rsp := data.Map["RespSearch"]["SummaryCard.RespSearch"][1:]
r := jce.NewJceReader(rsp)
rspService := r.ReadAny(2).([]interface{})[0].([]byte)
sr := binary.NewReader(rspService)
sr.ReadByte()
ld1 := sr.ReadInt32()
ld2 := sr.ReadInt32()
if ld1 > 0 && ld2+9 < int32(len(rspService)) {
sr.ReadBytes(int(ld1)) // busi comm
//searchPb := sr.ReadBytes(int(ld2)) //TODO: search pb decode
}
return nil, nil
}
// OidbSvc.0x88d_0
func decodeGroupInfoResponse(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
pkg := oidb.OIDBSSOPkg{}
rsp := oidb.D88DRspBody{}
if err := proto.Unmarshal(payload, &pkg); err != nil {
return nil, err
}
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
return nil, err
}
if len(rsp.RspGroupInfo) == 0 {
return nil, errors.New(string(rsp.StrErrorInfo))
}
info := rsp.RspGroupInfo[0]
if info.GroupInfo == nil {
return nil, errors.New("group info not found")
}
return &GroupInfo{
Uin: int64(*info.GroupInfo.GroupUin),
Code: int64(*info.GroupCode),
Name: string(info.GroupInfo.GroupName),
Memo: string(info.GroupInfo.GroupMemo),
OwnerUin: int64(*info.GroupInfo.GroupOwner),
MemberCount: uint16(*info.GroupInfo.GroupMemberNum),
MaxMemberCount: uint16(*info.GroupInfo.GroupMemberMaxNum),
Members: []*GroupMemberInfo{},
client: c,
}, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,137 @@
syntax = "proto2";
option go_package = ".;oidb";
message D6D8ReqBody {
optional GetFileInfoReqBody fileInfoReq = 1;
optional GetFileListReqBody fileListInfoReq = 2;
optional GetFileCountReqBody groupFileCountReq = 3;
optional GetSpaceReqBody groupSpaceReq = 4;
}
message D6D8RspBody {
optional GetFileInfoRspBody fileInfoRsp = 1;
optional GetFileListRspBody fileListInfoRsp = 2;
optional GetFileCountRspBody fileCountRsp = 3;
optional GetSpaceRspBody groupSpaceRsp = 4;
}
message GetFileInfoReqBody {
optional uint64 groupCode = 1;
optional uint32 appId = 2;
optional uint32 busId = 3;
optional string fileId = 4;
optional uint32 fieldFlag = 5;
}
message GetFileInfoRspBody {
optional int32 retCode = 1;
optional string retMsg = 2;
optional string clientWording = 3;
optional GroupFileInfo fileInfo = 4;
}
message GetFileListRspBody {
optional int32 retCode = 1;
optional string retMsg = 2;
optional string clientWording = 3;
optional bool isEnd = 4;
message Item {
optional uint32 type = 1;
optional GroupFolderInfo folderInfo = 2;
optional GroupFileInfo fileInfo = 3;
}
repeated Item itemList = 5;
optional FileTimeStamp maxTimestamp = 6;
optional uint32 allFileCount = 7;
optional uint32 filterCode = 8;
optional bool safeCheckFlag = 11;
optional uint32 safeCheckRes = 12;
optional uint32 nextIndex = 13;
optional bytes context = 14;
optional uint32 role = 15;
optional uint32 openFlag = 16;
}
message GroupFileInfo {/* renamed from FileInfo */
optional string fileId = 1;
optional string fileName = 2;
optional uint64 fileSize = 3;
optional uint32 busId = 4;
optional uint64 uploadedSize = 5;
optional uint32 uploadTime = 6;
optional uint32 deadTime = 7;
optional uint32 modifyTime = 8;
optional uint32 downloadTimes = 9;
optional bytes sha = 10;
optional bytes sha3 = 11;
optional bytes md5 = 12;
optional string localPath = 13;
optional string uploaderName = 14;
optional uint64 uploaderUin = 15;
optional string parentFolderId = 16;
}
message GroupFolderInfo {/* renamed from FolderInfo */
optional string folderId = 1;
optional string parentFolderId = 2;
optional string folderName = 3;
optional uint32 createTime = 4;
optional uint32 modifyTime = 5;
optional uint64 createUin = 6;
optional string creatorName = 7;
optional uint32 totalFileCount = 8;
}
message GetFileListReqBody {
optional uint64 groupCode = 1;
optional uint32 appId = 2;
optional string folderId = 3;
optional FileTimeStamp startTimestamp = 4;
optional uint32 fileCount = 5;
optional FileTimeStamp maxTimestamp = 6;
optional uint32 allFileCount = 7;
optional uint32 reqFrom = 8;
optional uint32 sortBy = 9;
optional uint32 filterCode = 10;
optional uint64 uin = 11;
optional uint32 fieldFlag = 12;
optional uint32 startIndex = 13;
optional bytes context = 14;
optional uint32 clientVersion = 15;
}
message GetFileCountReqBody {
optional uint64 groupCode = 1;
optional uint32 appId = 2;
optional uint32 busId = 3;
}
message GetSpaceReqBody {
optional uint64 groupCode = 1;
optional uint32 appId = 2;
}
message GetFileCountRspBody {
optional int32 retCode = 1;
optional string retMsg = 2;
optional string clientWording = 3;
optional uint32 allFileCount = 4;
optional bool fileTooMany = 5;
optional uint32 limitCount = 6;
optional bool isFull = 7;
}
message GetSpaceRspBody {
optional int32 retCode = 1;
optional string retMsg = 2;
optional string clientWording = 3;
optional uint64 totalSpace = 4;
optional uint64 usedSpace = 5;
}
message FileTimeStamp {
optional uint32 uploadTime = 1;
optional string fileId = 2;
}

View File

@ -2,7 +2,7 @@
// versions:
// protoc-gen-go v1.25.0
// protoc v3.11.4
// source: oidb0xd79.proto
// source: oidb0xD79.proto
package oidb
@ -42,7 +42,7 @@ type D79ReqBody struct {
func (x *D79ReqBody) Reset() {
*x = D79ReqBody{}
if protoimpl.UnsafeEnabled {
mi := &file_oidb0xd79_proto_msgTypes[0]
mi := &file_oidb0xD79_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -55,7 +55,7 @@ func (x *D79ReqBody) String() string {
func (*D79ReqBody) ProtoMessage() {}
func (x *D79ReqBody) ProtoReflect() protoreflect.Message {
mi := &file_oidb0xd79_proto_msgTypes[0]
mi := &file_oidb0xD79_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -68,7 +68,7 @@ func (x *D79ReqBody) ProtoReflect() protoreflect.Message {
// Deprecated: Use D79ReqBody.ProtoReflect.Descriptor instead.
func (*D79ReqBody) Descriptor() ([]byte, []int) {
return file_oidb0xd79_proto_rawDescGZIP(), []int{0}
return file_oidb0xD79_proto_rawDescGZIP(), []int{0}
}
func (x *D79ReqBody) GetSeq() uint64 {
@ -135,7 +135,7 @@ type D79RspBody struct {
func (x *D79RspBody) Reset() {
*x = D79RspBody{}
if protoimpl.UnsafeEnabled {
mi := &file_oidb0xd79_proto_msgTypes[1]
mi := &file_oidb0xD79_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -148,7 +148,7 @@ func (x *D79RspBody) String() string {
func (*D79RspBody) ProtoMessage() {}
func (x *D79RspBody) ProtoReflect() protoreflect.Message {
mi := &file_oidb0xd79_proto_msgTypes[1]
mi := &file_oidb0xD79_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -161,7 +161,7 @@ func (x *D79RspBody) ProtoReflect() protoreflect.Message {
// Deprecated: Use D79RspBody.ProtoReflect.Descriptor instead.
func (*D79RspBody) Descriptor() ([]byte, []int) {
return file_oidb0xd79_proto_rawDescGZIP(), []int{1}
return file_oidb0xD79_proto_rawDescGZIP(), []int{1}
}
func (x *D79RspBody) GetRet() uint32 {
@ -210,7 +210,7 @@ type D79Content struct {
func (x *D79Content) Reset() {
*x = D79Content{}
if protoimpl.UnsafeEnabled {
mi := &file_oidb0xd79_proto_msgTypes[2]
mi := &file_oidb0xD79_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -223,7 +223,7 @@ func (x *D79Content) String() string {
func (*D79Content) ProtoMessage() {}
func (x *D79Content) ProtoReflect() protoreflect.Message {
mi := &file_oidb0xd79_proto_msgTypes[2]
mi := &file_oidb0xD79_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -236,7 +236,7 @@ func (x *D79Content) ProtoReflect() protoreflect.Message {
// Deprecated: Use D79Content.ProtoReflect.Descriptor instead.
func (*D79Content) Descriptor() ([]byte, []int) {
return file_oidb0xd79_proto_rawDescGZIP(), []int{2}
return file_oidb0xD79_proto_rawDescGZIP(), []int{2}
}
func (x *D79Content) GetSliceContent() [][]byte {
@ -246,10 +246,10 @@ func (x *D79Content) GetSliceContent() [][]byte {
return nil
}
var File_oidb0xd79_proto protoreflect.FileDescriptor
var File_oidb0xD79_proto protoreflect.FileDescriptor
var file_oidb0xd79_proto_rawDesc = []byte{
0x0a, 0x0f, 0x6f, 0x69, 0x64, 0x62, 0x30, 0x78, 0x64, 0x37, 0x39, 0x2e, 0x70, 0x72, 0x6f, 0x74,
var file_oidb0xD79_proto_rawDesc = []byte{
0x0a, 0x0f, 0x6f, 0x69, 0x64, 0x62, 0x30, 0x78, 0x44, 0x37, 0x39, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0xbb, 0x01, 0x0a, 0x0a, 0x44, 0x37, 0x39, 0x52, 0x65, 0x71, 0x42, 0x6f, 0x64, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x73,
0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52,
@ -279,24 +279,24 @@ var file_oidb0xd79_proto_rawDesc = []byte{
}
var (
file_oidb0xd79_proto_rawDescOnce sync.Once
file_oidb0xd79_proto_rawDescData = file_oidb0xd79_proto_rawDesc
file_oidb0xD79_proto_rawDescOnce sync.Once
file_oidb0xD79_proto_rawDescData = file_oidb0xD79_proto_rawDesc
)
func file_oidb0xd79_proto_rawDescGZIP() []byte {
file_oidb0xd79_proto_rawDescOnce.Do(func() {
file_oidb0xd79_proto_rawDescData = protoimpl.X.CompressGZIP(file_oidb0xd79_proto_rawDescData)
func file_oidb0xD79_proto_rawDescGZIP() []byte {
file_oidb0xD79_proto_rawDescOnce.Do(func() {
file_oidb0xD79_proto_rawDescData = protoimpl.X.CompressGZIP(file_oidb0xD79_proto_rawDescData)
})
return file_oidb0xd79_proto_rawDescData
return file_oidb0xD79_proto_rawDescData
}
var file_oidb0xd79_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_oidb0xd79_proto_goTypes = []interface{}{
var file_oidb0xD79_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_oidb0xD79_proto_goTypes = []interface{}{
(*D79ReqBody)(nil), // 0: D79ReqBody
(*D79RspBody)(nil), // 1: D79RspBody
(*D79Content)(nil), // 2: D79Content
}
var file_oidb0xd79_proto_depIdxs = []int32{
var file_oidb0xD79_proto_depIdxs = []int32{
2, // 0: D79RspBody.content:type_name -> D79Content
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
@ -305,13 +305,13 @@ var file_oidb0xd79_proto_depIdxs = []int32{
0, // [0:1] is the sub-list for field type_name
}
func init() { file_oidb0xd79_proto_init() }
func file_oidb0xd79_proto_init() {
if File_oidb0xd79_proto != nil {
func init() { file_oidb0xD79_proto_init() }
func file_oidb0xD79_proto_init() {
if File_oidb0xD79_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_oidb0xd79_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_oidb0xD79_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*D79ReqBody); i {
case 0:
return &v.state
@ -323,7 +323,7 @@ func file_oidb0xd79_proto_init() {
return nil
}
}
file_oidb0xd79_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_oidb0xD79_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*D79RspBody); i {
case 0:
return &v.state
@ -335,7 +335,7 @@ func file_oidb0xd79_proto_init() {
return nil
}
}
file_oidb0xd79_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_oidb0xD79_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*D79Content); i {
case 0:
return &v.state
@ -352,18 +352,18 @@ func file_oidb0xd79_proto_init() {
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_oidb0xd79_proto_rawDesc,
RawDescriptor: file_oidb0xD79_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_oidb0xd79_proto_goTypes,
DependencyIndexes: file_oidb0xd79_proto_depIdxs,
MessageInfos: file_oidb0xd79_proto_msgTypes,
GoTypes: file_oidb0xD79_proto_goTypes,
DependencyIndexes: file_oidb0xD79_proto_depIdxs,
MessageInfos: file_oidb0xD79_proto_msgTypes,
}.Build()
File_oidb0xd79_proto = out.File
file_oidb0xd79_proto_rawDesc = nil
file_oidb0xd79_proto_goTypes = nil
file_oidb0xd79_proto_depIdxs = nil
File_oidb0xD79_proto = out.File
file_oidb0xD79_proto_rawDesc = nil
file_oidb0xD79_proto_goTypes = nil
file_oidb0xD79_proto_depIdxs = nil
}

View File

@ -16,7 +16,7 @@ type (
RequestId int64 `json:"request_id"`
InvitorUin int64 `json:"invitor_uin"`
InvitorNick string `json:"invitor_nick"`
GroupCode int64 `json:"group_code"`
GroupCode int64 `json:"group_id"`
GroupName string `json:"group_name"`
Checked bool `json:"checked"`
@ -30,7 +30,7 @@ type (
Message string `json:"message"`
RequesterUin int64 `json:"requester_uin"`
RequesterNick string `json:"requester_nick"`
GroupCode int64 `json:"group_code"`
GroupCode int64 `json:"group_id"`
GroupName string `json:"group_name"`
Checked bool `json:"checked"`
@ -125,9 +125,6 @@ func decodeSystemMsgGroupPacket(c *QQClient, _ uint16, payload []byte) (interfac
if err := proto.Unmarshal(payload, &rsp); err != nil {
return nil, err
}
if len(rsp.Groupmsgs) == 0 {
return nil, nil
}
ret := &GroupSystemMessages{}
for _, st := range rsp.Groupmsgs {
if st.Msg == nil {

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/Mrs4s/MiraiGo
go 1.14
require (
github.com/golang/protobuf v1.4.2
github.com/golang/protobuf v1.4.3
github.com/tidwall/gjson v1.6.1
google.golang.org/protobuf v1.25.0
)

2
go.sum
View File

@ -17,6 +17,8 @@ github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=

View File

@ -366,16 +366,16 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
}
}
if elem.LightApp != nil && len(elem.LightApp.Data) > 1 {
var content string
var content []byte
if elem.LightApp.Data[0] == 0 {
content = string(elem.LightApp.Data[1:])
content = elem.LightApp.Data[1:]
}
if elem.LightApp.Data[0] == 1 {
content = string(binary.ZlibUncompress(elem.LightApp.Data[1:]))
content = binary.ZlibUncompress(elem.LightApp.Data[1:])
}
if content != "" {
if len(content) > 0 && len(content) < 1024*1024*1024 { // 解析出错 or 非法内容
// TODO: 解析具体的APP
return append(res, &LightAppElement{Content: content})
return append(res, &LightAppElement{Content: string(content)})
}
}
if elem.VideoFile != nil {

View File

@ -10,6 +10,7 @@ import (
var ErrUnknownFlag = errors.New("unknown flag")
var ErrInvalidPayload = errors.New("invalid payload")
var ErrDecryptFailed = errors.New("decrypt failed")
var ErrSessionExpired = errors.New("session expired")
type ISendingPacket interface {
CommandId() uint16
@ -125,6 +126,9 @@ func parseSsoFrame(payload []byte, flag2 byte) (*IncomingPacket, error) {
seqId := reader.ReadInt32()
retCode := reader.ReadInt32()
if retCode != 0 {
if retCode == -10008 {
return nil, ErrSessionExpired
}
return nil, errors.New("return code unsuccessful: " + strconv.FormatInt(int64(retCode), 10))
}
reader.ReadBytes(int(reader.ReadInt32()) - 4) // extra data