mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-08 04:55:56 +08:00
clear code.
This commit is contained in:
parent
e24921467c
commit
b9170d8163
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/Mrs4s/MiraiGo/client/pb/notify"
|
"github.com/Mrs4s/MiraiGo/client/pb/notify"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/pttcenter"
|
"github.com/Mrs4s/MiraiGo/client/pb/pttcenter"
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/qweb"
|
"github.com/Mrs4s/MiraiGo/client/pb/qweb"
|
||||||
"log"
|
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -934,57 +933,6 @@ func decodeOnlinePushTransPacket(c *QQClient, _ uint16, payload []byte) (interfa
|
|||||||
return nil, nil
|
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
|
// ProfileService.Pb.ReqSystemMsgNew.Friend
|
||||||
func decodeSystemMsgFriendPacket(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
func decodeSystemMsgFriendPacket(c *QQClient, _ uint16, payload []byte) (interface{}, error) {
|
||||||
rsp := structmsg.RspSystemMsgNew{}
|
rsp := structmsg.RspSystemMsgNew{}
|
||||||
|
@ -151,32 +151,6 @@ type (
|
|||||||
Message string
|
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 {
|
NewFriendRequest struct {
|
||||||
RequestId int64
|
RequestId int64
|
||||||
Message string
|
Message string
|
||||||
|
87
client/system_msg.go
Normal file
87
client/system_msg.go
Normal 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
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user