1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

clear code.

This commit is contained in:
Mrs4s 2020-10-22 13:13:46 +08:00
parent e24921467c
commit b9170d8163
3 changed files with 87 additions and 78 deletions

View File

@ -7,7 +7,6 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb/notify"
"github.com/Mrs4s/MiraiGo/client/pb/pttcenter"
"github.com/Mrs4s/MiraiGo/client/pb/qweb"
"log"
"net"
"strconv"
"strings"
@ -934,57 +933,6 @@ func decodeOnlinePushTransPacket(c *QQClient, _ uint16, payload []byte) (interfa
return nil, nil
}
// ProfileService.Pb.ReqSystemMsgNew.Group
func decodeSystemMsgGroupPacket(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
rsp := structmsg.RspSystemMsgNew{}
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 {
if st.Msg.SubType == 1 {
// 处理被邀请入群 或 处理成员入群申请
switch st.Msg.GroupMsgType {
case 1: // 成员申请
ret.JoinRequests = append(ret.JoinRequests, &UserJoinGroupRequest{
RequestId: st.MsgSeq,
Message: st.Msg.MsgAdditional,
RequesterUin: st.ReqUin,
RequesterNick: st.Msg.ReqUinNick,
GroupCode: st.Msg.GroupCode,
GroupName: st.Msg.GroupName,
client: c,
})
case 2: // 被邀请
ret.InvitedRequests = append(ret.InvitedRequests, &GroupInvitedRequest{
RequestId: st.MsgSeq,
InvitorUin: st.Msg.ActionUin,
InvitorNick: st.Msg.ActionUinNick,
GroupCode: st.Msg.GroupCode,
GroupName: st.Msg.GroupName,
client: c,
})
default:
log.Println("unknown group msg:", st)
}
} else if st.Msg.SubType == 2 {
// 被邀请入群, 自动同意, 不需处理
} else if st.Msg.SubType == 3 {
// 已被其他管理员处理
} else if st.Msg.SubType == 5 {
// 成员退群消息
} else {
log.Println("unknown group msg:", st)
}
}
}
return ret, nil
}
// ProfileService.Pb.ReqSystemMsgNew.Friend
func decodeSystemMsgFriendPacket(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
rsp := structmsg.RspSystemMsgNew{}

View File

@ -151,32 +151,6 @@ type (
Message string
}
GroupSystemMessages struct {
InvitedRequests []*GroupInvitedRequest
JoinRequests []*UserJoinGroupRequest
}
GroupInvitedRequest struct {
RequestId int64
InvitorUin int64
InvitorNick string
GroupCode int64
GroupName string
client *QQClient
}
UserJoinGroupRequest struct {
RequestId int64
Message string
RequesterUin int64
RequesterNick string
GroupCode int64
GroupName string
client *QQClient
}
NewFriendRequest struct {
RequestId int64
Message string

87
client/system_msg.go Normal file
View File

@ -0,0 +1,87 @@
package client
import (
"github.com/Mrs4s/MiraiGo/client/pb/structmsg"
"google.golang.org/protobuf/proto"
"log"
)
type (
GroupSystemMessages struct {
InvitedRequests []*GroupInvitedRequest
JoinRequests []*UserJoinGroupRequest
}
GroupInvitedRequest struct {
RequestId int64
InvitorUin int64
InvitorNick string
GroupCode int64
GroupName string
client *QQClient
}
UserJoinGroupRequest struct {
RequestId int64
Message string
RequesterUin int64
RequesterNick string
GroupCode int64
GroupName string
client *QQClient
}
)
// ProfileService.Pb.ReqSystemMsgNew.Group
func decodeSystemMsgGroupPacket(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
rsp := structmsg.RspSystemMsgNew{}
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 {
continue
}
if st.Msg.SubType == 1 {
// 处理被邀请入群 或 处理成员入群申请
switch st.Msg.GroupMsgType {
case 1: // 成员申请
ret.JoinRequests = append(ret.JoinRequests, &UserJoinGroupRequest{
RequestId: st.MsgSeq,
Message: st.Msg.MsgAdditional,
RequesterUin: st.ReqUin,
RequesterNick: st.Msg.ReqUinNick,
GroupCode: st.Msg.GroupCode,
GroupName: st.Msg.GroupName,
client: c,
})
case 2: // 被邀请
ret.InvitedRequests = append(ret.InvitedRequests, &GroupInvitedRequest{
RequestId: st.MsgSeq,
InvitorUin: st.Msg.ActionUin,
InvitorNick: st.Msg.ActionUinNick,
GroupCode: st.Msg.GroupCode,
GroupName: st.Msg.GroupName,
client: c,
})
default:
log.Println("unknown group msg:", st)
}
} else if st.Msg.SubType == 2 {
// 被邀请入群, 自动同意, 不需处理
} else if st.Msg.SubType == 3 {
// 已被其他管理员处理
} else if st.Msg.SubType == 5 {
// 成员退群消息
} else {
log.Println("unknown group msg:", st)
}
}
return ret, nil
}