Skip to content

fix: 修复Vercel部署的云函数无法使用获取QQ昵称功能的问题#916

Merged
imaegoo merged 1 commit into
twikoojs:mainfrom
IceTeacher:fix-vercel-getqqnick
May 5, 2026
Merged

fix: 修复Vercel部署的云函数无法使用获取QQ昵称功能的问题#916
imaegoo merged 1 commit into
twikoojs:mainfrom
IceTeacher:fix-vercel-getqqnick

Conversation

@IceTeacher

@IceTeacher IceTeacher commented May 5, 2026

Copy link
Copy Markdown
Contributor

当前的 twikoo-vercel 没有添加用于获取QQ昵称的路由,即使更新到最新版v1.7.7的 Vercel 云函数、配置了 QQ_API_KEY 也无法使用获取QQ昵称功能,提示“请更新 Twikoo 云函数至最新版本”,参考腾讯云函数添加获取QQ昵称的路由后恢复正常

修复前

01

修复后

02

Summary by Sourcery

Bug Fixes:

  • 通过将 GET_QQ_NICK 动作连接到 QQ 昵称获取逻辑,修复并恢复在 Vercel 部署中的 QQ 昵称查询功能。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Restore QQ nickname lookup in Vercel deployments by wiring the GET_QQ_NICK action to the QQ nickname retrieval logic.

@sourcery-ai

sourcery-ai Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor
审阅者指南(在小型 PR 上默认折叠)

审阅者指南

通过将新的 GET_QQ_NICK 动作连接到专用处理程序,并在其中使用 QQ_API_KEY 调用 getQQNick 并返回标准化响应,为 Vercel 无服务器 API 添加缺失的 QQ 昵称获取支持。

通过 Vercel API 执行 GET_QQ_NICK 以获取 QQ 昵称的时序图

sequenceDiagram
  actor User
  participant Frontend
  participant VercelApi as Vercel_api_handler
  participant QQNickHandler as qqNickGet
  participant QQService as getQQNick
  participant QQApi as QQ_nickname_API

  User ->> Frontend: Trigger_get_QQ_nickname
  Frontend ->> VercelApi: POST { action: GET_QQ_NICK, qq }
  VercelApi ->> QQNickHandler: qqNickGet(event)
  QQNickHandler ->> QQService: getQQNick(qq, QQ_API_KEY)
  QQService ->> QQApi: HTTP_request_with_qq_and_key
  QQApi -->> QQService: nickname_response
  QQService -->> QQNickHandler: nick
  QQNickHandler -->> VercelApi: { code: SUCCESS, nick }
  VercelApi -->> Frontend: JSON_response
  Frontend -->> User: Display_nickname_or_error
Loading

Vercel API 处理程序与 QQ 昵称获取函数的类图

classDiagram
  class VercelApiHandler {
    +handleRequest(request, response) Promise
    -config
    -RES_CODE
  }

  class QQNickHandler {
    +qqNickGet(event) Promise
    -validate(event, requiredFields)
  }

  class QQService {
    +getQQNick(qq, qqApiKey) Promise
  }

  class Config {
    +QQ_API_KEY
  }

  VercelApiHandler o-- QQNickHandler : calls_qqNickGet_on_GET_QQ_NICK
  QQNickHandler ..> QQService : calls_getQQNick
  QQNickHandler ..> Config : reads_QQ_API_KEY
  VercelApiHandler ..> Config : uses_config_for_other_actions
Loading

文件级变更

变更 详情 文件
将 QQ 昵称获取功能接入 Vercel 无服务器 API 并实现其处理程序。
  • 在 Vercel API 入口文件中与其他 QQ 工具一起导入 getQQNick。
  • 在主请求分发器中注册新的 GET_QQ_NICK 动作,并调用 qqNickGet 处理程序。
  • 实现 qqNickGet,用于校验输入、使用配置的 QQ_API_KEY 调用 getQQNick,并基于 RES_CODE 返回包含昵称或错误信息的成功/失败响应。
src/server/vercel/api/index.js

提示与命令

与 Sourcery 交互

  • 触发新的审阅: 在 Pull Request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub issue: 通过回复审阅评论,让 Sourcery 从该评论创建一个 issue。你也可以回复审阅评论并添加 @sourcery-ai issue 来从中创建 issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中的任意位置写上 @sourcery-ai,即可随时生成标题。也可以在 Pull Request 上评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文中的任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。也可以在 Pull Request 上评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审阅者指南: 在 Pull Request 上评论 @sourcery-ai guide,可随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 上评论 @sourcery-ai resolve,以解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会非常有用。
  • 忽略所有 Sourcery 审阅: 在 Pull Request 上评论 @sourcery-ai dismiss,以忽略所有现有的 Sourcery 审阅。特别适合想从头开始一次新的审阅时使用——别忘了再评论 @sourcery-ai review 来触发新的审阅!

自定义你的体验

进入你的 仪表盘 以:

  • 启用或禁用审阅功能,例如 Sourcery 生成的 Pull Request 摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、移除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds missing QQ nickname retrieval support to the Vercel serverless API by wiring a new GET_QQ_NICK action to a dedicated handler that calls getQQNick with QQ_API_KEY and returns a standardized response.

Sequence diagram for GET_QQ_NICK QQ nickname retrieval via Vercel API

sequenceDiagram
  actor User
  participant Frontend
  participant VercelApi as Vercel_api_handler
  participant QQNickHandler as qqNickGet
  participant QQService as getQQNick
  participant QQApi as QQ_nickname_API

  User ->> Frontend: Trigger_get_QQ_nickname
  Frontend ->> VercelApi: POST { action: GET_QQ_NICK, qq }
  VercelApi ->> QQNickHandler: qqNickGet(event)
  QQNickHandler ->> QQService: getQQNick(qq, QQ_API_KEY)
  QQService ->> QQApi: HTTP_request_with_qq_and_key
  QQApi -->> QQService: nickname_response
  QQService -->> QQNickHandler: nick
  QQNickHandler -->> VercelApi: { code: SUCCESS, nick }
  VercelApi -->> Frontend: JSON_response
  Frontend -->> User: Display_nickname_or_error
Loading

Class diagram for Vercel API handler and QQ nickname retrieval function

classDiagram
  class VercelApiHandler {
    +handleRequest(request, response) Promise
    -config
    -RES_CODE
  }

  class QQNickHandler {
    +qqNickGet(event) Promise
    -validate(event, requiredFields)
  }

  class QQService {
    +getQQNick(qq, qqApiKey) Promise
  }

  class Config {
    +QQ_API_KEY
  }

  VercelApiHandler o-- QQNickHandler : calls_qqNickGet_on_GET_QQ_NICK
  QQNickHandler ..> QQService : calls_getQQNick
  QQNickHandler ..> Config : reads_QQ_API_KEY
  VercelApiHandler ..> Config : uses_config_for_other_actions
Loading

File-Level Changes

Change Details Files
Wire the QQ nickname retrieval feature into the Vercel serverless API and implement its handler.
  • Import getQQNick into the Vercel API entrypoint alongside other QQ utilities.
  • Register a new GET_QQ_NICK action in the main request dispatcher, invoking a qqNickGet handler.
  • Implement qqNickGet to validate input, call getQQNick with the configured QQ_API_KEY, and return a RES_CODE-based success/fail response with the nickname or error message.
src/server/vercel/api/index.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

Hey - 我发现了 1 个问题

给 AI 智能体的提示
请根据本次代码审查中的评论进行修改:

## 单条评论

### 评论 1
<location path="src/server/vercel/api/index.js" line_range="149-150" />
<code_context>
       case 'UPLOAD_IMAGE': // >= 1.5.0
         res = await uploadImage(event, config)
         break
+      case 'GET_QQ_NICK': // >= 1.7.0
+        res = await qqNickGet(event)
+        break
       case 'COMMENT_EXPORT_FOR_ADMIN': // >= 1.6.13
</code_context>
<issue_to_address>
**issue (bug_risk):**`config` 传入 `qqNickGet`,以避免使用超出作用域的变量。

`qqNickGet` 会引用 `config.QQ_API_KEY`,但在该函数内部 `config` 不在作用域内。为避免运行时错误,请在调用时传入 `config``qqNickGet(event, config)`),并更新函数签名,使其接受 `config` 作为参数。
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得这些审查有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续审查。
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/server/vercel/api/index.js" line_range="149-150" />
<code_context>
       case 'UPLOAD_IMAGE': // >= 1.5.0
         res = await uploadImage(event, config)
         break
+      case 'GET_QQ_NICK': // >= 1.7.0
+        res = await qqNickGet(event)
+        break
       case 'COMMENT_EXPORT_FOR_ADMIN': // >= 1.6.13
</code_context>
<issue_to_address>
**issue (bug_risk):** Pass `config` into `qqNickGet` to avoid using an out-of-scope variable.

`qqNickGet` references `config.QQ_API_KEY`, but `config` isn’t in scope inside that function. To prevent a runtime error, pass `config` into the call (`qqNickGet(event, config)`) and update the function signature to accept `config` as a parameter.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/server/vercel/api/index.js
@imaegoo imaegoo merged commit a66bd77 into twikoojs:main May 5, 2026
2 checks passed
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.

2 participants