Skip to content

Commit

Permalink
feat: 添加群聊/单聊中的用户头像获取
Browse files Browse the repository at this point in the history
  • Loading branch information
WindowsSov8forUs committed Jul 15, 2024
1 parent fce3f7d commit b7320f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion processor/process_c2c_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func (p *Processor) ProcessC2CMessage(payload *dto.WSPayload, data *dto.WSC2CMes

// 构建 user
user := &user.User{
Id: data.Author.UserOpenID,
Id: data.Author.UserOpenID,
Avatar: p.getUserAvatar(data.Author.UserOpenID),
}

// 填充事件数据
Expand Down
3 changes: 2 additions & 1 deletion processor/process_group_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func (p *Processor) ProcessGroupMessage(payload *dto.WSPayload, data *dto.WSGrou

// 构建 user
user := &user.User{
Id: data.Author.MemberOpenID,
Id: data.Author.MemberOpenID,
Avatar: p.getUserAvatar(data.Author.MemberOpenID),
}

// 填充事件数据
Expand Down
8 changes: 7 additions & 1 deletion processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func NewProcessor(conf *config.Config) (*Processor, context.Context, error) {
}

// 获取机器人信息
me, err := getBotMe(api, ctx)
me, err := getBotMe(api, ctx, conf)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -269,3 +269,9 @@ func (p *Processor) BroadcastEvent(event *operation.Event) error {
p.Server.Send(event)
return nil
}

// getUserAvatar 获取用户头像
func (p *Processor) getUserAvatar(userId string) string {
url := fmt.Sprintf("https://q.qlogo.cn/qqapp/%v/%s/3", p.conf.Account.AppID, userId)
return url
}

0 comments on commit b7320f7

Please sign in to comment.