Skip to content

Commit

Permalink
client: delete SpecialTitleExpireTime field in GroupMemberInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
wdvxdr1123 committed May 23, 2022
1 parent b28ec81 commit a9a08db
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 50 deletions.
67 changes: 31 additions & 36 deletions client/decoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,16 +538,15 @@ func decodeGroupMemberListResponse(_ *QQClient, _ *network.IncomingPacketInfo, p
l := make([]*GroupMemberInfo, 0, len(members))
for _, m := range members {
l = append(l, &GroupMemberInfo{
Uin: m.MemberUin,
Nickname: m.Nick,
Gender: m.Gender,
CardName: m.Name,
Level: uint16(m.MemberLevel),
JoinTime: m.JoinTime,
LastSpeakTime: m.LastSpeakTime,
SpecialTitle: m.SpecialTitle,
SpecialTitleExpireTime: m.SpecialTitleExpireTime,
ShutUpTimestamp: m.ShutUpTimestap,
Uin: m.MemberUin,
Nickname: m.Nick,
Gender: m.Gender,
CardName: m.Name,
Level: uint16(m.MemberLevel),
JoinTime: m.JoinTime,
LastSpeakTime: m.LastSpeakTime,
SpecialTitle: m.SpecialTitle,
ShutUpTimestamp: m.ShutUpTimestap,
Permission: func() MemberPermission {
if m.Flag == 1 {
return Administrator
Expand All @@ -572,26 +571,24 @@ func decodeGroupMemberInfoResponse(c *QQClient, _ *network.IncomingPacketInfo, p
return nil, errors.WithStack(ErrMemberNotFound)
}
group := c.FindGroup(rsp.GroupCode)
permission := Member
if rsp.MemInfo.Uin == group.OwnerUin {
permission = Owner
}
if rsp.MemInfo.Role == 2 {
permission = Administrator
}
return &GroupMemberInfo{
Group: group,
Uin: rsp.MemInfo.Uin,
Gender: byte(rsp.MemInfo.Sex),
Nickname: string(rsp.MemInfo.Nick),
CardName: string(rsp.MemInfo.Card),
Level: uint16(rsp.MemInfo.Level),
JoinTime: rsp.MemInfo.Join,
LastSpeakTime: rsp.MemInfo.LastSpeak,
SpecialTitle: string(rsp.MemInfo.SpecialTitle),
SpecialTitleExpireTime: int64(rsp.MemInfo.SpecialTitleExpireTime),
Permission: func() MemberPermission {
if rsp.MemInfo.Uin == group.OwnerUin {
return Owner
}
if rsp.MemInfo.Role == 2 {
return Administrator
}
return Member
}(),
Group: group,
Uin: rsp.MemInfo.Uin,
Gender: byte(rsp.MemInfo.Sex),
Nickname: string(rsp.MemInfo.Nick),
CardName: string(rsp.MemInfo.Card),
Level: uint16(rsp.MemInfo.Level),
JoinTime: rsp.MemInfo.Join,
LastSpeakTime: rsp.MemInfo.LastSpeak,
SpecialTitle: string(rsp.MemInfo.SpecialTitle),
Permission: permission,
}, nil
}

Expand Down Expand Up @@ -713,12 +710,10 @@ func decodeOnlinePushTransPacket(c *QQClient, _ *network.IncomingPacketInfo, pay
}
if g := c.FindGroupByUin(info.GetFromUin()); g != nil {
if var5 == 0 && data.Len() == 1 {
newPermission := func() MemberPermission {
if data.ReadByte() == 1 {
return Administrator
}
return Member
}()
newPermission := Member
if data.ReadByte() == 1 {
newPermission = Administrator
}
mem := g.FindMember(target)
if mem.Permission != newPermission {
old := mem.Permission
Expand Down Expand Up @@ -782,7 +777,7 @@ func decodeMSFOfflinePacket(c *QQClient, _ *network.IncomingPacketInfo, _ []byte

// OidbSvc.0xd79
func decodeWordSegmentation(_ *QQClient, _ *network.IncomingPacketInfo, payload []byte) (any, error) {
rsp := &oidb.D79RspBody{}
rsp := oidb.D79RspBody{}
err := unpackOIDBPackage(payload, &rsp)
if err != nil {
return nil, err
Expand Down
17 changes: 15 additions & 2 deletions client/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,20 @@ func (c *QQClient) getWebDeviceInfo() (i string) {
return
}

var oidbSSOPool = sync.Pool{}

func getOidbSSOPackage() *oidb.OIDBSSOPkg {
g := oidbSSOPool.Get()
if g == nil {
return new(oidb.OIDBSSOPkg)
}
return g.(*oidb.OIDBSSOPkg)
}

func (c *QQClient) packOIDBPackage(cmd, serviceType int32, body []byte) []byte {
pkg := &oidb.OIDBSSOPkg{
pkg := getOidbSSOPackage()
defer oidbSSOPool.Put(pkg)
*pkg = oidb.OIDBSSOPkg{
Command: cmd,
ServiceType: serviceType,
Bodybuffer: body,
Expand All @@ -354,7 +366,8 @@ func (c *QQClient) packOIDBPackageProto(cmd, serviceType int32, msg proto.Messag
}

func unpackOIDBPackage(payload []byte, rsp proto.Message) error {
pkg := new(oidb.OIDBSSOPkg)
pkg := getOidbSSOPackage()
defer oidbSSOPool.Put(pkg)
if err := proto.Unmarshal(payload, pkg); err != nil {
return errors.Wrap(err, "failed to unmarshal protobuf message")
}
Expand Down
23 changes: 11 additions & 12 deletions client/group_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@ type (
}

GroupMemberInfo struct {
Group *GroupInfo
Uin int64
Gender byte
Nickname string
CardName string
Level uint16
JoinTime int64
LastSpeakTime int64
SpecialTitle string
SpecialTitleExpireTime int64
ShutUpTimestamp int64
Permission MemberPermission
Group *GroupInfo
Uin int64
Nickname string
CardName string
JoinTime int64
LastSpeakTime int64
SpecialTitle string
ShutUpTimestamp int64
Permission MemberPermission
Level uint16
Gender byte
}

// GroupSearchInfo 通过搜索得到的群信息
Expand Down

0 comments on commit a9a08db

Please sign in to comment.