Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Post articles and image-text content to WeChat Official Account via API or Chrome CDP, with markdown-to-WeChat HTML conversion.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/multi-account.md
1# Multi-Account Support23Details for managing multiple WeChat Official Accounts through one EXTEND.md. SKILL.md only covers single-account flow and the selection prompt — read this file when the user has an `accounts:` block, asks to publish to a specific account, or needs per-account credentials.45## Compatibility67| Condition | Mode | Behavior |8|-----------|------|----------|9| No `accounts` block | Single-account | Original behavior, no changes |10| `accounts` with 1 entry | Single-account | Auto-select, no prompt |11| `accounts` with 2+ entries | Multi-account | Prompt to select before publishing |12| `accounts` with `default: true` | Multi-account | Pre-select default; user can switch |1314## EXTEND.md Example1516```md17default_theme: default18default_color: blue1920accounts:21- name: 宝玉的技术分享22alias: baoyu23default: true24default_publish_method: api25default_author: 宝玉26need_open_comment: 127only_fans_can_comment: 028app_id: your_wechat_app_id29app_secret: your_wechat_app_secret30- name: AI工具集31alias: ai-tools32default_publish_method: browser33default_author: AI工具集34need_open_comment: 135only_fans_can_comment: 036```3738## Per-Account vs Global Keys3940**Per-account** (also accepted globally as fallback): `default_publish_method`, `default_author`, `need_open_comment`, `only_fans_can_comment`, `app_id`, `app_secret`, `chrome_profile_path`, `remote_publish_host`, `remote_publish_user`, `remote_publish_port`, `remote_publish_identity_file`, `remote_publish_known_hosts_file`, `remote_publish_strict_host_key_checking`, `remote_publish_connect_timeout`, `remote_publish_proxy_jump`.4142**Global-only** (always shared): `default_theme`, `default_color`.4344## Account Selection (Step 0.5)4546Insert between Step 0 (Load EXTEND.md) and Step 1 (Determine input type):4748```49if no accounts block:50→ single-account mode (original behavior)51elif accounts.length == 1:52→ auto-select the only account53elif --account <alias> CLI arg:54→ select matching account55elif one account has default: true:56→ pre-select, display: "Using account: <name> (--account to switch)"57else:58→ prompt user to choose from the list59```6061## Credential Resolution (API Method)6263For the selected account with alias `{alias}`, try in this order (first hit wins):64651. `app_id` / `app_secret` inline in the EXTEND.md account block662. Env vars `WECHAT_{ALIAS}_APP_ID` / `WECHAT_{ALIAS}_APP_SECRET` (alias uppercased, hyphens → underscores)673. `.baoyu-skills/.env` with the prefixed key `WECHAT_{ALIAS}_APP_ID`684. `~/.baoyu-skills/.env` with the prefixed key695. Fallback to unprefixed `WECHAT_APP_ID` / `WECHAT_APP_SECRET`7071### .env Multi-Account Example7273```bash74# Account: baoyu75WECHAT_BAOYU_APP_ID=your_wechat_app_id76WECHAT_BAOYU_APP_SECRET=your_wechat_app_secret7778# Account: ai-tools79WECHAT_AI_TOOLS_APP_ID=your_ai_tools_wechat_app_id80WECHAT_AI_TOOLS_APP_SECRET=your_ai_tools_wechat_app_secret81```8283## Chrome Profile (Browser Method)8485Each account uses an isolated Chrome profile so logins don't collide.8687| Source | Path |88|--------|------|89| Account `chrome_profile_path` in EXTEND.md | Use as-is |90| Auto-generated from alias | `{shared_profile_parent}/wechat-{alias}/` |91| Single-account fallback | Shared default profile |9293## CLI `--account` Flag9495All publishing scripts accept `--account <alias>`:9697```bash98${BUN_X} {baseDir}/scripts/wechat-api.ts <file> --theme default --account ai-tools99${BUN_X} {baseDir}/scripts/wechat-article.ts --markdown <file> --theme default --account baoyu100${BUN_X} {baseDir}/scripts/wechat-browser.ts --markdown <file> --images ./photos/ --account baoyu101```102103## Remote API Publishing104105`wechat-api.ts` supports a `remote-api` mode that tunnels WeChat API calls through an SSH SOCKS5 dynamic port forward to a server whose IP is on WeChat's allowlist. Markdown rendering, image processing, draft assembly, and HTML rewriting still happen locally; only outbound HTTPS calls to `api.weixin.qq.com` traverse the tunnel. No files are written to the remote host and `AppSecret` never leaves the local process. The remote host needs only `sshd` and outbound network access.106107### Per-Account Configuration108109```md110default_theme: default111default_color: blue112default_publish_method: browser # browser remains the default113114accounts:115- name: 宝玉的技术分享116alias: baoyu117default: true118default_publish_method: api119default_author: 宝玉120app_id: your_wechat_app_id121app_secret: your_wechat_app_secret122- name: AI工具集123alias: ai-tools124default_publish_method: remote-api125default_author: AI工具集126app_id: your_ai_tools_app_id127app_secret: your_ai_tools_app_secret128remote_publish_host: ai-tools-server.example.com129remote_publish_user: deploy130remote_publish_port: 22131remote_publish_identity_file: /home/me/.ssh/id_ed25519132remote_publish_known_hosts_file: /home/me/.ssh/known_hosts133remote_publish_strict_host_key_checking: accept-new134```135136Account-level `remote_publish_*` values override top-level globals. CLI `--remote-*` flags override both.137138### CLI Usage139140```bash141# Use the account's default_publish_method (remote-api here):142${BUN_X} {baseDir}/scripts/wechat-api.ts <file> --theme default --account ai-tools143144# Force remote mode regardless of default_publish_method:145${BUN_X} {baseDir}/scripts/wechat-api.ts <file> --theme default --account baoyu --remote --remote-host other-server.example.com146```147148### Security Notes149150- Authentication is SSH key only. Passwords and `ssh-askpass` are not used.151- Only the typed `remote_publish_*` keys are read; raw `ssh` / `scp` options are intentionally not supported.152- The tunnel forwards raw TCP; TLS verification for `api.weixin.qq.com` is still performed end-to-end by the local process.153