Skip to content

feat: add avatar field to GroupInfo interface#535

Merged
sj817 merged 2 commits into
mainfrom
copilot/fix-1358c1ea-5bd6-4fe9-9b26-0014be5beb75
Oct 2, 2025
Merged

feat: add avatar field to GroupInfo interface#535
sj817 merged 2 commits into
mainfrom
copilot/fix-1358c1ea-5bd6-4fe9-9b26-0014be5beb75

Conversation

Copilot AI commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

Problem

Previously, developers needed to make two separate API calls to get both group information and the group avatar URL:

const bot = getBot(group.botId)!
const groupInfo = await bot.getGroupInfo(group.id)        // First call
const groupAvatarUrl = await bot.getGroupAvatarUrl(group.id)  // Second call

This resulted in unnecessary code duplication and extra async operations.

Solution

Added an optional avatar field to the GroupInfo interface that automatically includes the group avatar URL when retrieving group information:

const bot = getBot(group.botId)!
const groupInfo = await bot.getGroupInfo(group.id)
// groupInfo.avatar now contains the avatar URL - no second call needed!

Changes

1. Updated GroupInfo Interface

Added optional avatar?: string field to packages/core/src/types/adapter/apiResponse.ts:

export interface GroupInfo {
  groupId: string
  groupName?: string
  // ... other fields ...
  avatar?: string  // NEW: Group avatar URL
}

2. Updated getGroupInfo Method

Modified packages/core/src/adapter/onebot/core/core.ts to automatically fetch and include the avatar URL:

async getGroupInfo(groupId: string, noCache?: boolean) {
  const info = await this._onebot.getGroupInfo(Number(groupId), noCache)
  const avatar = await this.getGroupAvatarUrl(groupId)  // Fetch avatar URL
  return {
    // ... other fields ...
    avatar,  // Include in response
  }
}

3. Updated getGroupList Method

Also updated getGroupList to include avatar URLs for consistency across the API.

Benefits

  • Reduced API calls: Single call instead of two separate async operations
  • Better DX: More intuitive and convenient API
  • Backward compatible: The field is optional, existing code continues to work
  • Consistent: Both getGroupInfo and getGroupList now include avatar information

Closes #[issue_number]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.npmmirror.com
    • Triggering command: node /home/REDACTED/.npm/_npx/4876f32048baf8ac/node_modules/.bin/prebuild-install -r napi --pkg_version=5.1.7 --pkg_name=sqlite3 (dns block)
    • Triggering command: node /home/REDACTED/.npm/_npx/c65dbefa27d408e0/node_modules/.bin/prebuild-install -r node --pkg_version=0.12.0 --pkg_name=node-pty-prebuilt-multiarch (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Feat: 将群头像放到群信息接口里面</issue_title>
<issue_description>### 描述功能

GroupInfo接口添加avatar字段

动机

Image

需要拿群信息 + 群头像。
本来两行就写完了

实现方法

No response

替代方案

No response

附加信息

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #514

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Feat: 将群头像放到群信息接口里面 feat: add avatar field to GroupInfo interface Oct 2, 2025
Copilot AI requested a review from sj817 October 2, 2025 00:05
@sj817
sj817 marked this pull request as ready for review October 2, 2025 00:15
Copilot AI review requested due to automatic review settings October 2, 2025 00:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an optional avatar field to the GroupInfo interface to include group avatar URLs when retrieving group information, eliminating the need for separate API calls.

  • Added optional avatar?: string field to GroupInfo interface
  • Modified getGroupInfo and getGroupList methods to automatically fetch and include avatar URLs
  • Converted getGroupList to use Promise.all to handle async avatar fetching

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/types/adapter/apiResponse.ts Added optional avatar field to GroupInfo interface
packages/core/src/adapter/onebot/core/core.ts Updated both getGroupInfo and getGroupList methods to fetch and include avatar URLs

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/core/src/adapter/onebot/core/core.ts
@github-actions

github-actions Bot commented Oct 2, 2025

Copy link
Copy Markdown
Contributor

你可以通过以下命令安装该版本:

pnpm add https://pkg.pr.new/node-karin@3293b8c -w

@sj817
sj817 merged commit 7878dcf into main Oct 2, 2025
5 of 6 checks passed
@sj817
sj817 deleted the copilot/fix-1358c1ea-5bd6-4fe9-9b26-0014be5beb75 branch October 2, 2025 00:20
@github-actions github-actions Bot mentioned this pull request Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: 将群头像放到群信息接口里面

3 participants