Skip to content

Commit

Permalink
add create role packet
Browse files Browse the repository at this point in the history
  • Loading branch information
Kengxxiao committed Nov 16, 2021
1 parent 96489d0 commit 5ba0039
Show file tree
Hide file tree
Showing 3 changed files with 357 additions and 164 deletions.
51 changes: 45 additions & 6 deletions client/guild.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ type (

// GuildRole 频道身份组信息
GuildRole struct {
RoleId uint64
RoleName string
ArgbColor uint32
RoleId uint64
RoleName string
ArgbColor uint32
Indepedent bool
Num int32
Owned bool
Disabled bool
MaxNum int32
}

// ChannelInfo 子频道信息
Expand Down Expand Up @@ -300,14 +305,48 @@ func (s *GuildService) GetGuildRoles(guildId uint64) ([]*GuildRole, error) {
roles := make([]*GuildRole, 0)
for _, role := range body.Roles {
roles = append(roles, &GuildRole{
RoleId: *role.RoleId,
RoleName: *role.Name,
ArgbColor: *role.ArgbColor,
RoleId: role.GetRoleId(),
RoleName: role.GetName(),
ArgbColor: role.GetArgbColor(),
Indepedent: role.GetIndependent() == 1,
Num: role.GetNum(),
Owned: role.GetOwned() == 1,
Disabled: role.GetDisabled() == 1,
MaxNum: role.GetMaxNum(),
})
}
return roles, nil
}

func (s *GuildService) CreateGuildRole(guildId uint64, name string, color uint32, independent bool, initialUsers []uint64) (uint64, error) {
seq := s.c.nextSeq()
u1 := uint32(1)
packet := packets.BuildUniPacket(s.c.Uin, seq, "OidbSvcTrpcTcp.0x1016_1", 1, s.c.OutGoingPacketSessionId, []byte{}, s.c.sigInfo.d2Key,
s.c.packOIDBPackageDynamically(4118, 1, binary.DynamicProtoMessage{
1: guildId,
2: binary.DynamicProtoMessage{ // todo: 未知参数
1: u1,
2: u1,
3: u1,
},
3: binary.DynamicProtoMessage{
1: name,
2: color,
3: independent,
},
4: initialUsers,
}))
rsp, err := s.c.sendAndWaitDynamic(seq, packet)
if err != nil {
return 0, errors.Wrap(err, "send packet error")
}
body := new(channel.ChannelOidb0X1016Rsp)
if err = s.c.unpackOIDBPackage(rsp, body); err != nil {
return 0, errors.Wrap(err, "decode packet error")
}
return body.GetRoleId(), nil
}

func (s *GuildService) FetchGuestGuild(guildId uint64) (*GuildMeta, error) {
seq := s.c.nextSeq()
u1 := uint32(1)
Expand Down
Loading

0 comments on commit 5ba0039

Please sign in to comment.