Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

Adds complete WeChat Official Account adapter following the new OneBots architecture pattern.

Implementation

Core Bot Client (src/adapters/wechat-mp/bot.ts)

  • Access token management with auto-refresh (2hr expiry - 200s buffer)
  • Signature verification (SHA1 hash of token + timestamp + nonce)
  • XML message parsing/building via xml2js
  • Customer service API: text, image, voice, video messages
  • User info, follower list, media upload

Adapter (src/adapters/wechat-mp/index.ts)

  • Implements all required Adapter base methods
  • Webhook endpoints:
    • GET /{platform}/{account_id}/webhook - WeChat server verification
    • POST /{platform}/{account_id}/webhook - Message receiving with XML parsing
  • Converts WeChat messages to CommonEvent format
  • Proper log4js integration (no console.*)

Utilities (src/adapters/wechat-mp/utils.ts)

  • Message segment conversion helpers
  • Error formatting

Configuration

wechat-mp.my_account:
  onebot.v11:
    use_http: true
    use_ws: true
  
  appId: 'wx...'
  appSecret: '...'
  token: '...'
  encodingAESKey: ''  # optional
  encrypt: false

Dependencies

  • axios - WeChat API calls
  • xml2js - XML message parsing/building

Limitations

  • Private messages only (WeChat MP has no group/channel concept)
  • Methods for groups/channels throw appropriate errors
  • Message deletion not supported (WeChat MP API limitation)
Original prompt

现在的适配器、协议、app他们的类型声明都ok了,现在,完整实现一个微信公众号的适配器


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: lc-cn <31359947+lc-cn@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 22, 2025

Deploying onebots with  Cloudflare Pages  Cloudflare Pages

Latest commit: afd5b84
Status: ✅  Deploy successful!
Preview URL: https://c4fa985a.onebots.pages.dev
Branch Preview URL: https://copilot-implement-wechat-pub.onebots.pages.dev

View logs

Copilot AI and others added 3 commits November 22, 2025 10:11
Co-authored-by: lc-cn <31359947+lc-cn@users.noreply.github.com>
Co-authored-by: lc-cn <31359947+lc-cn@users.noreply.github.com>
Co-authored-by: lc-cn <31359947+lc-cn@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement WeChat public account adapter Implement WeChat Official Account (微信公众号) adapter Nov 22, 2025
Copilot finished work on behalf of lc-cn November 22, 2025 10:19
Copilot AI requested a review from lc-cn November 22, 2025 10:19
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