1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

feature: private recall.

This commit is contained in:
Mrs4s 2020-10-17 16:37:49 +08:00
parent 0922b058ff
commit 517ddcd50b
6 changed files with 166 additions and 36 deletions

View File

@ -888,30 +888,6 @@ func (c *QQClient) buildSystemMsgFriendActionPacket(reqId, requester int64, acce
return seq, packet
}
// PbMessageSvc.PbMsgWithDraw
func (c *QQClient) buildGroupRecallPacket(groupCode int64, msgSeq, msgRan int32) (uint16, []byte) {
seq := c.nextSeq()
req := &msg.MsgWithDrawReq{
GroupWithDraw: []*msg.GroupMsgWithDrawReq{
{
SubCmd: 1,
GroupCode: groupCode,
MsgList: []*msg.GroupMsgInfo{
{
MsgSeq: msgSeq,
MsgRandom: msgRan,
MsgType: 0,
},
},
UserDef: []byte{0x08, 0x00},
},
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgWithDraw", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// friendlist.ModifyGroupCardReq
func (c *QQClient) buildEditGroupTagPacket(groupCode, memberUin int64, newTag string) (uint16, []byte) {
seq := c.nextSeq()

View File

@ -621,11 +621,6 @@ func (c *QQClient) sendGroupPoke(groupCode, target int64) {
_, _ = c.sendAndWait(c.buildGroupPokePacket(groupCode, target))
}
func (c *QQClient) RecallGroupMessage(groupCode int64, msgId, msgInternalId int32) {
_, pkt := c.buildGroupRecallPacket(groupCode, msgId, msgInternalId)
_ = c.send(pkt)
}
func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.GroupImageElement, error) {
h := md5.Sum(img)
seq, pkt := c.buildGroupImageStorePacket(groupCode, h[:], int32(len(img)))

View File

@ -6238,6 +6238,69 @@ func (x *AnimationImageShow) GetAnimationParam() []byte {
return nil
}
type UinTypeUserDef struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FromUinType int32 `protobuf:"varint,1,opt,name=fromUinType,proto3" json:"fromUinType,omitempty"`
FromGroupCode int64 `protobuf:"varint,2,opt,name=fromGroupCode,proto3" json:"fromGroupCode,omitempty"`
FileUuid string `protobuf:"bytes,3,opt,name=fileUuid,proto3" json:"fileUuid,omitempty"`
}
func (x *UinTypeUserDef) Reset() {
*x = UinTypeUserDef{}
if protoimpl.UnsafeEnabled {
mi := &file_msg_proto_msgTypes[60]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UinTypeUserDef) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UinTypeUserDef) ProtoMessage() {}
func (x *UinTypeUserDef) ProtoReflect() protoreflect.Message {
mi := &file_msg_proto_msgTypes[60]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UinTypeUserDef.ProtoReflect.Descriptor instead.
func (*UinTypeUserDef) Descriptor() ([]byte, []int) {
return file_msg_proto_rawDescGZIP(), []int{60}
}
func (x *UinTypeUserDef) GetFromUinType() int32 {
if x != nil {
return x.FromUinType
}
return 0
}
func (x *UinTypeUserDef) GetFromGroupCode() int64 {
if x != nil {
return x.FromGroupCode
}
return 0
}
func (x *UinTypeUserDef) GetFileUuid() string {
if x != nil {
return x.FileUuid
}
return ""
}
var File_msg_proto protoreflect.FileDescriptor
var file_msg_proto_rawDesc = []byte{
@ -7218,11 +7281,18 @@ var file_msg_proto_rawDesc = []byte{
0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x6e, 0x69, 0x6d,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28,
0x0c, 0x52, 0x0e, 0x61, 0x6e, 0x69, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x72, 0x61,
0x6d, 0x2a, 0x2e, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x09, 0x0a,
0x05, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x54,
0x49, 0x4e, 0x55, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x54, 0x4f, 0x50, 0x10,
0x02, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x6d, 0x73, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x6d, 0x22, 0x74, 0x0a, 0x0e, 0x55, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x55, 0x73, 0x65, 0x72,
0x44, 0x65, 0x66, 0x12, 0x20, 0x0a, 0x0b, 0x66, 0x72, 0x6f, 0x6d, 0x55, 0x69, 0x6e, 0x54, 0x79,
0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x66, 0x72, 0x6f, 0x6d, 0x55, 0x69,
0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6d, 0x47, 0x72, 0x6f,
0x75, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x66, 0x72,
0x6f, 0x6d, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66,
0x69, 0x6c, 0x65, 0x55, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66,
0x69, 0x6c, 0x65, 0x55, 0x75, 0x69, 0x64, 0x2a, 0x2e, 0x0a, 0x08, 0x53, 0x79, 0x6e, 0x63, 0x46,
0x6c, 0x61, 0x67, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x54, 0x41, 0x52, 0x54, 0x10, 0x00, 0x12, 0x0d,
0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x54, 0x49, 0x4e, 0x55, 0x4d, 0x45, 0x10, 0x01, 0x12, 0x08, 0x0a,
0x04, 0x53, 0x54, 0x4f, 0x50, 0x10, 0x02, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x6d, 0x73, 0x67,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -7238,7 +7308,7 @@ func file_msg_proto_rawDescGZIP() []byte {
}
var file_msg_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 60)
var file_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 61)
var file_msg_proto_goTypes = []interface{}{
(SyncFlag)(0), // 0: SyncFlag
(*GetMessageRequest)(nil), // 1: GetMessageRequest
@ -7301,6 +7371,7 @@ var file_msg_proto_goTypes = []interface{}{
(*SubMsgType0X4Body)(nil), // 58: SubMsgType0x4Body
(*ResvAttr)(nil), // 59: ResvAttr
(*AnimationImageShow)(nil), // 60: AnimationImageShow
(*UinTypeUserDef)(nil), // 61: UinTypeUserDef
}
var file_msg_proto_depIdxs = []int32{
0, // 0: GetMessageRequest.syncFlag:type_name -> SyncFlag
@ -8099,6 +8170,18 @@ func file_msg_proto_init() {
return nil
}
}
file_msg_proto_msgTypes[60].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UinTypeUserDef); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -8106,7 +8189,7 @@ func file_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_msg_proto_rawDesc,
NumEnums: 1,
NumMessages: 60,
NumMessages: 61,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -723,4 +723,10 @@ message ResvAttr {
message AnimationImageShow {
int32 effect_id = 1;
bytes animation_param = 2;
}
message UinTypeUserDef {
int32 fromUinType = 1;
int64 fromGroupCode = 2;
string fileUuid = 3;
}

View File

@ -14,6 +14,9 @@ import (
"google.golang.org/protobuf/proto"
)
// 语音相关处理逻辑
// UploadGroupPtt 将语音数据使用群语音通道上传到服务器, 返回 message.GroupVoiceElement 可直接发送
func (c *QQClient) UploadGroupPtt(groupCode int64, voice []byte) (*message.GroupVoiceElement, error) {
h := md5.Sum(voice)
seq, pkt := c.buildGroupPttStorePacket(groupCode, h[:], int32(len(voice)), 0, int32(len(voice)))
@ -50,6 +53,7 @@ ok:
}}, nil
}
// UploadPrivatePtt 将语音数据使用好友语音通道上传到服务器, 返回 message.PrivateVoiceElement 可直接发送
func (c *QQClient) UploadPrivatePtt(target int64, voice []byte) (*message.PrivateVoiceElement, error) {
h := md5.Sum(voice)
i, err := c.sendAndWait(c.buildPrivatePttStorePacket(target, h[:], int32(len(voice)), int32(len(voice))))

66
client/recall.go Normal file
View File

@ -0,0 +1,66 @@
package client
import (
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/protocol/packets"
"google.golang.org/protobuf/proto"
)
// 撤回相关处理逻辑
func (c *QQClient) RecallGroupMessage(groupCode int64, msgId, msgInternalId int32) {
_, pkt := c.buildGroupRecallPacket(groupCode, msgId, msgInternalId)
_ = c.send(pkt)
}
func (c *QQClient) RecallPrivateMessage(uin, ts int64, msgId, msgInternalId int32) {
_, pkt := c.buildPrivateRecallPacket(uin, ts, msgId, msgInternalId)
_ = c.send(pkt)
}
// PbMessageSvc.PbMsgWithDraw
func (c *QQClient) buildGroupRecallPacket(groupCode int64, msgSeq, msgRan int32) (uint16, []byte) {
seq := c.nextSeq()
req := &msg.MsgWithDrawReq{
GroupWithDraw: []*msg.GroupMsgWithDrawReq{
{
SubCmd: 1,
GroupCode: groupCode,
MsgList: []*msg.GroupMsgInfo{
{
MsgSeq: msgSeq,
MsgRandom: msgRan,
MsgType: 0,
},
},
UserDef: []byte{0x08, 0x00},
},
},
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgWithDraw", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
func (c *QQClient) buildPrivateRecallPacket(uin, ts int64, msgSeq, random int32) (uint16, []byte) {
seq := c.nextSeq()
req := &msg.MsgWithDrawReq{C2CWithDraw: []*msg.C2CMsgWithDrawReq{
{
MsgInfo: []*msg.C2CMsgInfo{
{
FromUin: c.Uin,
ToUin: uin,
MsgTime: ts,
MsgUid: int64(random),
MsgSeq: msgSeq,
MsgRandom: random,
},
},
Reserved: []byte{0x08, 0x00},
SubCmd: 1,
},
}}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "PbMessageSvc.PbMsgWithDraw", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}