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

style: rename channel to guild

This commit is contained in:
Mrs4s 2021-11-06 16:17:26 +08:00
parent dd7ff422b8
commit 7d6dafc215
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7
2 changed files with 23 additions and 23 deletions

View File

@ -36,15 +36,15 @@ type QQClient struct {
AllowSlider bool AllowSlider bool
// account info // account info
Nickname string Nickname string
Age uint16 Age uint16
Gender uint16 Gender uint16
FriendList []*FriendInfo FriendList []*FriendInfo
GroupList []*GroupInfo GroupList []*GroupInfo
OnlineClients []*OtherClientInfo OnlineClients []*OtherClientInfo
Online bool Online bool
QiDian *QiDianAccountInfo QiDian *QiDianAccountInfo
ChannelService *ChannelService GuildService *GuildService
// protocol public field // protocol public field
SequenceId int32 SequenceId int32
@ -213,7 +213,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
alive: true, alive: true,
ecdh: crypto.NewEcdh(), ecdh: crypto.NewEcdh(),
} }
cli.ChannelService = &ChannelService{c: cli} cli.GuildService = &GuildService{c: cli}
cli.ecdh.FetchPubKey(uin) cli.ecdh.FetchPubKey(uin)
cli.UseDevice(SystemDeviceInfo) cli.UseDevice(SystemDeviceInfo)
sso, err := getSSOAddress() sso, err := getSSOAddress()

View File

@ -11,8 +11,8 @@ import (
) )
type ( type (
// ChannelService 频道模块内自身的信息 // GuildService 频道模块内自身的信息
ChannelService struct { GuildService struct {
TinyId uint64 TinyId uint64
Nickname string Nickname string
AvatarUrl string AvatarUrl string
@ -77,17 +77,17 @@ func (c *QQClient) syncChannelFirstView() {
if err = proto.Unmarshal(rsp, firstViewRsp); err != nil { if err = proto.Unmarshal(rsp, firstViewRsp); err != nil {
return return
} }
c.ChannelService.TinyId = firstViewRsp.GetSelfTinyid() c.GuildService.TinyId = firstViewRsp.GetSelfTinyid()
c.ChannelService.GuildCount = firstViewRsp.GetGuildCount() c.GuildService.GuildCount = firstViewRsp.GetGuildCount()
if self, err := c.ChannelService.GetUserProfile(c.ChannelService.TinyId); err == nil { if self, err := c.GuildService.GetUserProfile(c.GuildService.TinyId); err == nil {
c.ChannelService.Nickname = self.Nickname c.GuildService.Nickname = self.Nickname
c.ChannelService.AvatarUrl = self.AvatarUrl c.GuildService.AvatarUrl = self.AvatarUrl
} else { } else {
c.Error("get self guild profile error: %v", err) c.Error("get self guild profile error: %v", err)
} }
} }
func (s *ChannelService) GetUserProfile(tinyId uint64) (*GuildUserProfile, error) { func (s *GuildService) GetUserProfile(tinyId uint64) (*GuildUserProfile, error) {
seq := s.c.nextSeq() seq := s.c.nextSeq()
flags := binary.DynamicProtoMessage{} flags := binary.DynamicProtoMessage{}
for i := 3; i <= 29; i++ { for i := 3; i <= 29; i++ {
@ -122,7 +122,7 @@ func (s *ChannelService) GetUserProfile(tinyId uint64) (*GuildUserProfile, error
}, nil }, nil
} }
func (s *ChannelService) GetGuildMembers(guildId uint64) (bots []*GuildMemberInfo, members []*GuildMemberInfo, admins []*GuildMemberInfo, err error) { func (s *GuildService) GetGuildMembers(guildId uint64) (bots []*GuildMemberInfo, members []*GuildMemberInfo, admins []*GuildMemberInfo, err error) {
seq := s.c.nextSeq() seq := s.c.nextSeq()
u1 := uint32(1) u1 := uint32(1)
payload := s.c.packOIDBPackageDynamically(3931, 1, binary.DynamicProtoMessage{ // todo: 可能还需要处理翻页的情况? payload := s.c.packOIDBPackageDynamically(3931, 1, binary.DynamicProtoMessage{ // todo: 可能还需要处理翻页的情况?
@ -170,7 +170,7 @@ func (s *ChannelService) GetGuildMembers(guildId uint64) (bots []*GuildMemberInf
return return
} }
func (s *ChannelService) GetGuildMemberProfileInfo(guildId, tinyId uint64) (*GuildUserProfile, error) { func (s *GuildService) GetGuildMemberProfileInfo(guildId, tinyId uint64) (*GuildUserProfile, error) {
seq := s.c.nextSeq() seq := s.c.nextSeq()
flags := binary.DynamicProtoMessage{} flags := binary.DynamicProtoMessage{}
for i := 3; i <= 29; i++ { for i := 3; i <= 29; i++ {
@ -227,7 +227,7 @@ func decodeChannelPushFirstView(c *QQClient, _ *incomingPacketInfo, payload []by
return nil, errors.Wrap(err, "failed to unmarshal protobuf message") return nil, errors.Wrap(err, "failed to unmarshal protobuf message")
} }
if len(firstViewMsg.GuildNodes) > 0 { if len(firstViewMsg.GuildNodes) > 0 {
c.ChannelService.Guilds = []*GuildInfo{} c.GuildService.Guilds = []*GuildInfo{}
for _, guild := range firstViewMsg.GuildNodes { for _, guild := range firstViewMsg.GuildNodes {
info := &GuildInfo{ info := &GuildInfo{
GuildId: guild.GetGuildId(), GuildId: guild.GetGuildId(),
@ -247,8 +247,8 @@ func decodeChannelPushFirstView(c *QQClient, _ *incomingPacketInfo, payload []by
AtAllSeq: meta.GetAtAllSeq(), AtAllSeq: meta.GetAtAllSeq(),
}) })
} }
info.Bots, info.Members, info.Admins, _ = c.ChannelService.GetGuildMembers(info.GuildId) info.Bots, info.Members, info.Admins, _ = c.GuildService.GetGuildMembers(info.GuildId)
c.ChannelService.Guilds = append(c.ChannelService.Guilds, info) c.GuildService.Guilds = append(c.GuildService.Guilds, info)
} }
} }
if len(firstViewMsg.ChannelMsgs) > 0 { // sync msg if len(firstViewMsg.ChannelMsgs) > 0 { // sync msg