mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
Merge branch 'master' of https://github.com/Mrs4s/MiraiGo
This commit is contained in:
commit
013c937ad7
@ -151,7 +151,8 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
|
|||||||
"ProfileService.Pb.ReqSystemMsgNew.Friend": decodeSystemMsgFriendPacket,
|
"ProfileService.Pb.ReqSystemMsgNew.Friend": decodeSystemMsgFriendPacket,
|
||||||
"MultiMsg.ApplyUp": decodeMultiApplyUpResponse,
|
"MultiMsg.ApplyUp": decodeMultiApplyUpResponse,
|
||||||
"MultiMsg.ApplyDown": decodeMultiApplyDownResponse,
|
"MultiMsg.ApplyDown": decodeMultiApplyDownResponse,
|
||||||
"OidbSvc.0x6d6_2": decodeOIDB6d6Response,
|
"OidbSvc.0x6d6_2": decodeOIDB6d62Response,
|
||||||
|
"OidbSvc.0x6d6_3": decodeOIDB6d63Response,
|
||||||
"OidbSvc.0x6d8_1": decodeOIDB6d81Response,
|
"OidbSvc.0x6d8_1": decodeOIDB6d81Response,
|
||||||
"OidbSvc.0x88d_0": decodeGroupInfoResponse,
|
"OidbSvc.0x88d_0": decodeGroupInfoResponse,
|
||||||
"OidbSvc.0xe07_0": decodeImageOcrResponse,
|
"OidbSvc.0xe07_0": decodeImageOcrResponse,
|
||||||
@ -641,17 +642,19 @@ func (c *QQClient) uploadPrivateImage(target int64, img []byte, count int) (*mes
|
|||||||
count++
|
count++
|
||||||
h := md5.Sum(img)
|
h := md5.Sum(img)
|
||||||
e, err := c.QueryFriendImage(target, h[:], int32(len(img)))
|
e, err := c.QueryFriendImage(target, h[:], int32(len(img)))
|
||||||
if err != nil {
|
if err == ErrNotExists {
|
||||||
// use group highway upload and query again for image id.
|
// use group highway upload and query again for image id.
|
||||||
if _, err = c.UploadGroupImage(target, img); err != nil {
|
if _, err = c.UploadGroupImage(target, img); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// safe
|
|
||||||
if count >= 5 {
|
if count >= 5 {
|
||||||
return nil, errors.New("upload failed")
|
return e, nil
|
||||||
}
|
}
|
||||||
return c.uploadPrivateImage(target, img, count)
|
return c.uploadPrivateImage(target, img, count)
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return e, nil
|
return e, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -698,7 +701,10 @@ func (c *QQClient) QueryFriendImage(target int64, hash []byte, size int32) (*mes
|
|||||||
return nil, errors.New(rsp.Message)
|
return nil, errors.New(rsp.Message)
|
||||||
}
|
}
|
||||||
if !rsp.IsExists {
|
if !rsp.IsExists {
|
||||||
return nil, errors.New("image not exists")
|
return &message.FriendImageElement{
|
||||||
|
ImageId: rsp.ResourceId,
|
||||||
|
Md5: hash,
|
||||||
|
}, ErrNotExists
|
||||||
}
|
}
|
||||||
return &message.FriendImageElement{
|
return &message.FriendImageElement{
|
||||||
ImageId: rsp.ResourceId,
|
ImageId: rsp.ResourceId,
|
||||||
@ -1124,6 +1130,7 @@ func (c *QQClient) doHeartbeat() {
|
|||||||
_ = c.Conn.Close()
|
_ = c.Conn.Close()
|
||||||
}
|
}
|
||||||
time.AfterFunc(30*time.Second, c.doHeartbeat)
|
time.AfterFunc(30*time.Second, c.doHeartbeat)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
c.heartbeatEnabled = false
|
c.heartbeatEnabled = false
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
ErrAlreadyOnline = errors.New("already online")
|
ErrAlreadyOnline = errors.New("already online")
|
||||||
ErrMemberNotFound = errors.New("member not found")
|
ErrMemberNotFound = errors.New("member not found")
|
||||||
|
ErrNotExists = errors.New("not exists")
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -142,6 +142,16 @@ func (fs *GroupFileSystem) GetDownloadUrl(file *GroupFile) string {
|
|||||||
return fs.client.GetGroupFileUrl(file.GroupCode, file.FileId, file.BusId)
|
return fs.client.GetGroupFileUrl(file.GroupCode, file.FileId, file.BusId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteFile 删除群文件,需要管理权限.
|
||||||
|
// 返回错误, 空为删除成功
|
||||||
|
func (fs *GroupFileSystem) DeleteFile(parentFolderId, fileId string, busId int32) string {
|
||||||
|
i, err := fs.client.sendAndWait(fs.client.buildGroupFileDeleteReqPacket(fs.GroupCode, parentFolderId, fileId, busId))
|
||||||
|
if err != nil {
|
||||||
|
return err.Error()
|
||||||
|
}
|
||||||
|
return i.(string)
|
||||||
|
}
|
||||||
|
|
||||||
// OidbSvc.0x6d8_1
|
// OidbSvc.0x6d8_1
|
||||||
func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderId string, startIndex uint32) (uint16, []byte) {
|
func (c *QQClient) buildGroupFileListRequestPacket(groupCode int64, folderId string, startIndex uint32) (uint16, []byte) {
|
||||||
seq := c.nextSeq()
|
seq := c.nextSeq()
|
||||||
@ -229,6 +239,27 @@ func (c *QQClient) buildGroupFileDownloadReqPacket(groupCode int64, fileId strin
|
|||||||
return seq, packet
|
return seq, packet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *QQClient) buildGroupFileDeleteReqPacket(groupCode int64, parentFolderId, fileId string, busId int32) (uint16, []byte) {
|
||||||
|
seq := c.nextSeq()
|
||||||
|
body := &oidb.D6D6ReqBody{DeleteFileReq: &oidb.DeleteFileReqBody{
|
||||||
|
GroupCode: groupCode,
|
||||||
|
AppId: 3,
|
||||||
|
BusId: busId,
|
||||||
|
ParentFolderId: parentFolderId,
|
||||||
|
FileId: fileId,
|
||||||
|
}}
|
||||||
|
b, _ := proto.Marshal(body)
|
||||||
|
req := &oidb.OIDBSSOPkg{
|
||||||
|
Command: 1750,
|
||||||
|
ServiceType: 3,
|
||||||
|
Bodybuffer: b,
|
||||||
|
ClientVersion: "android 8.4.8",
|
||||||
|
}
|
||||||
|
payload, _ := proto.Marshal(req)
|
||||||
|
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x6d6_3", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
|
||||||
|
return seq, packet
|
||||||
|
}
|
||||||
|
|
||||||
func decodeOIDB6d81Response(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
func decodeOIDB6d81Response(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
||||||
pkg := oidb.OIDBSSOPkg{}
|
pkg := oidb.OIDBSSOPkg{}
|
||||||
rsp := oidb.D6D8RspBody{}
|
rsp := oidb.D6D8RspBody{}
|
||||||
@ -242,7 +273,7 @@ func decodeOIDB6d81Response(c *QQClient, _ uint16, payload []byte) (interface{},
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OidbSvc.0x6d6_2
|
// OidbSvc.0x6d6_2
|
||||||
func decodeOIDB6d6Response(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
func decodeOIDB6d62Response(_ *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
||||||
pkg := oidb.OIDBSSOPkg{}
|
pkg := oidb.OIDBSSOPkg{}
|
||||||
rsp := oidb.D6D6RspBody{}
|
rsp := oidb.D6D6RspBody{}
|
||||||
if err := proto.Unmarshal(payload, &pkg); err != nil {
|
if err := proto.Unmarshal(payload, &pkg); err != nil {
|
||||||
@ -251,7 +282,25 @@ func decodeOIDB6d6Response(_ *QQClient, _ uint16, payload []byte) (interface{},
|
|||||||
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
|
if err := proto.Unmarshal(pkg.Bodybuffer, &rsp); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if rsp.DownloadFileRsp.DownloadUrl == nil {
|
||||||
|
return nil, errors.New(rsp.DownloadFileRsp.ClientWording)
|
||||||
|
}
|
||||||
ip := rsp.DownloadFileRsp.DownloadIp
|
ip := rsp.DownloadFileRsp.DownloadIp
|
||||||
url := hex.EncodeToString(rsp.DownloadFileRsp.DownloadUrl)
|
url := hex.EncodeToString(rsp.DownloadFileRsp.DownloadUrl)
|
||||||
return fmt.Sprintf("http://%s/ftn_handler/%s/", ip, url), nil
|
return fmt.Sprintf("http://%s/ftn_handler/%s/", ip, url), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func decodeOIDB6d63Response(_ *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.DeleteFileRsp == nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
return rsp.DeleteFileRsp.ClientWording, nil
|
||||||
|
}
|
||||||
|
@ -366,16 +366,16 @@ func ParseMessageElems(elems []*msg.Elem) []IMessageElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if elem.LightApp != nil && len(elem.LightApp.Data) > 1 {
|
if elem.LightApp != nil && len(elem.LightApp.Data) > 1 {
|
||||||
var content string
|
var content []byte
|
||||||
if elem.LightApp.Data[0] == 0 {
|
if elem.LightApp.Data[0] == 0 {
|
||||||
content = string(elem.LightApp.Data[1:])
|
content = elem.LightApp.Data[1:]
|
||||||
}
|
}
|
||||||
if elem.LightApp.Data[0] == 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
|
// TODO: 解析具体的APP
|
||||||
return append(res, &LightAppElement{Content: content})
|
return append(res, &LightAppElement{Content: string(content)})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if elem.VideoFile != nil {
|
if elem.VideoFile != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user