HUB
Sign inSign up

finalpi/wechat2tg

By finalpi

•Updated about 2 hours ago

Telegram收发微信消息

Buildkit cache
Image
3

10K+

finalpi/wechat2tg repository overview

⁠wechat2tg (v6)

中文⁠ | English

Transmit WeChat messages on Telegram, supporting multiple WeChat protocols (iPad, Mac, Car, Windows, Pad)

Current stable release: v6.0.41 — static sticker photos, red-packet amounts on the original button, improved WebUI input and previews, consistent templates, avatar deduplication, and a slimmer image. See the release notes and upgrade guidance⁠.

⁠Telegram Group: @Wx2TgUserGroup⁠

Warning

According to feedback, the Windows protocol has the risk of account suspension, please do not use this protocol

⁠Main Features

  1. Receive messages from WeChat personal chats, group chats, official accounts, and enterprise WeChat
  2. Send messages via Telegram to specific WeChat users, groups, and official accounts
  3. Flexible group message blocking functionality
  4. AI reply suggestions based on the current WeChat chat context
  5. WebUI configuration, message-template previews and model discovery/testing (current React UI is primarily Chinese)
  6. Basic WebUI message viewing, limited operations, categorized contacts and Telegram synchronization tracking; message-type support is incomplete
  7. Eleven MCP tools and WebUI token management; client setup is documented separately

⁠Automatic chat-folder overflow

New groups are organized into WeChat, WeChat 2, WeChat 3, and so on using the logged-in account’s Telegram limits. If no folder slot remains, group creation, binding, and forwarding still succeed; the chat stays available in All Chats. Existing settings and unrelated/shared folders are preserved. See folder allocation and failure behavior (Chinese)⁠.

⁠Official accounts in forum topics

Optionally set OFFICIAL_ACCOUNT_TOPICS_ENABLED=true and restart. The first official-account message automatically provisions one private forum, with a separate topic per account. Future messages use those topics and replies route back to the matching account; General never routes to WeChat. The feature defaults off, retains old groups/bindings, and restores old routing when disabled. See official-account topics (Chinese)⁠.

⁠Inline WeChat custom emoji

WECHAT_CUSTOM_EMOJI_ENABLED=true renders native [微笑] / [Facepalm] tokens inline using WeChatPack⁠, preserving rich text and ordinary Unicode emoji. Sending eligibility includes a Premium bot owner or an eligible Fragment username. Enabled by default in auto mode, with button-icon eligibility checks before delivery and compatible output when eligibility is unknown or unavailable. The WebUI shows detection results and supports rechecking or explicit disable. Unknown tokens remain unchanged. See mapping, coverage and limits (Chinese)⁠. Available starting with v6.0.13-dev.3.

⁠WebUI and message center

The WebUI starts with the application; the current React interface is primarily Chinese. Docker Compose exposes TCP 17863 on all host interfaces by default: open http://<server-address>:17863/. Local development listens on loopback by default: http://127.0.0.1:17863/. WebUI and MCP share the same port; the MCP path is /mcp.

⁠Telegram Mini App and live messages

The same WebUI can open from the owner’s private-chat 控制台 menu. Configure WEBUI_MINI_APP_URL=https://your-domain/ and restart the Bot: the backend verifies Telegram signatures and permits only the existing bot owner, without entering a WebUI token. Ordinary browser login remains available. The message page uses SSE change notifications instead of five-second polling. A reachable HTTPS root URL and an SSE-compatible reverse proxy are required; see setup and security boundaries⁠. Available since v6.0.35; use v6.0.36 or later for the private-chat menu fix.

⁠Configuration console
  • Configure Telegram / WeChat connections, forwarding preferences, message templates, proxies, AI / speech recognition, retries, retention, and logging.
  • Existing-field validation, unsaved-change tracking, conflict detection, responsive layouts and restart feedback are available. Telegram bot language settings do not imply equivalent WebUI language switching.
  • Telegram and WeChat proxies are presented separately. Message templates have live contact, group, and official-account previews, including missing-alias examples. Previews use sample data and never send messages.
  • Sign in with WEBUI_TOKEN (at least 16 characters), or the generated storage/webui-token. Sign-in opens chat by default. Ordinary browsers save the access token locally for refresh/reopen; Mini App sessions remain separate and memory-only. Signing out or a rejected token clears saved credentials.
  • Configuration secret fields remain blank: leave blank to retain the saved value, enter a new value to replace it, or explicitly clear an optional secret. MCP tokens have separate reveal/regeneration controls.
⁠Chat capabilities and current limitations — read first

Important

**WebUI chat is currently intended mainly for viewing simple messages such as text, with limited send, quote, recall and synchronization operations. It does not fully support every WeChat message type and is not a replacement for the WeChat client.** A summary, link or attachment entry does not mean that a message type is fully decoded, interactive or comprehensively verified. Use WeChat for the complete experience.
  • Rendering is partial. Images, audio/video, files, official-account articles and merged histories have some preview/download/decoding paths. Protocol responses, expired media, cache availability and nested formats can still produce summaries, placeholders, missing attachments or failures. Red packets, transfers, mini-programs, Channels content, special cards and real-time voice/video calls are not fully supported Web features.
  • History is not your complete WeChat history. The page reads records this project has saved or synchronized; it does not retrieve all old messages from WeChat. Telegram forwarding support must not be confused with WebUI rendering support.
  • Operations are type-dependent. Text, some attachment sends and eligible quote/recall operations are available; uploads are limited to 50 MiB and captions are sent separately. Quotes cannot include attachments or native mentions; use the member picker for group mentions. Recalls require native receipts and remain subject to WeChat limits. Native interactions on complex cards are not guaranteed.
  • Status is not a read receipt. Submitted means a WeChat-side receipt was returned, not that the recipient received/read the message. Pending Telegram synchronization is not WeChat unread state. Uncertain outcomes are not automatically resent.
  • Contacts are a cached directory. dev.4 adds WeChat-style categories, alphabetical sections, avatars, search and paging. Service accounts require an explicit protocol field; remaining official accounts are not asserted to be confirmed subscription accounts. Counts are neither page lengths nor authoritative real-time WeChat totals. Cached groups are not necessarily saved-to-contacts groups. New-friend management, My Enterprise, and contact add/delete/approval are not implemented in WebUI.
  • Official-account menus are only partially supported. dev.4 displays synchronized menus/submenus and opens ordinary HTTP(S) links in a new window. Event clicks, mini-programs and WeChat authorization/QR actions remain disabled. Button text is never sent as a fake menu click. Missing cached menus do not prove an account has no menu, and links may still require WeChat to complete their workflow.
  • PWA installation is not offline WeChat or background delivery. Trusted HTTPS is required. Only public shell assets are cached, never protected APIs, chat bodies or attachments. Drafts live in the current signed-in window's memory; closing or forcing a reload does not guarantee recovery. There is no offline send replay or reliable closed-window push. Native mobile installation, keyboard and Telegram WebView behavior still need device testing.
  • The UI migration is incomplete. The current React UI is primarily Chinese. Independent UI-language switching, global configuration search and one-click MCP client-configuration export from the old UI are not fully migrated.

Use /chat for chat and /manage for settings. Implemented features retain SSE-driven updates without periodic message/contact polling; desktop focus mode and chat/settings switching preserve in-window chat drafts and reading position. See PWA/chat boundaries⁠, directory/menu capabilities⁠ and WebUI development⁠.

⁠AI and speech

Enter an OpenAI-compatible API URL and key, read the provider's model list, select a model, and test the connection before saving. The current model tools use the saved key; do not assume an unsaved replacement key is being tested. Save and review configuration when changing provider origin. Checks use a generic test prompt, never conversation history. /ai generates contextual reply suggestions; it does not automatically send them.

Configure Tencent Cloud ASR credentials and enable automatic voice transcription through WebUI or /settings.

⁠MCP access and installation

Manage MCP directly in the WebUI MCP access page:

  • Enable or disable MCP immediately; set the client endpoint and local bridge script path. The endpoint is for client configuration, not the server listener.
  • Reveal or regenerate independent read-only and read/send tokens; update connected clients after rotation.
  • Complete one-click client-configuration export is not present in the current React page. Configure Streamable HTTP / stdio manually using the MCP documentation and keep credentials private.
  • The stdio bridge supports local file uploads and downloads; paths in repository examples are placeholders. Keep actual installation paths and credentials in private client configuration outside this repository.
ToolPurpose
wechat_statusWeChat / Telegram connection status
wechat_search_contactsSearch contacts and groups
wechat_get_group_membersSearch group members and obtain IDs for native mentions
wechat_list_conversationsList saved conversations by recent activity
wechat_read_messagesSearch and paginate conversation history
wechat_get_new_messagesRead new incoming messages using a persistent cursor
wechat_send_textSend authorized text with an idempotent request ID
wechat_revoke_messageRecall an eligible own message with explicit confirmation
wechat_send_mediaSend an uploaded attachment, or a local file through the bridge
wechat_download_attachmentDownload ordinary or merged-history attachments
wechat_get_send_statusCheck WeChat submission and Telegram synchronization

MCP uses the existing WeChat login and send queue. Reading messages does not wake an idle AI or enable automatic replies. Cursor-based reception is separate from Telegram unread counters. See MCP setup, parameters, and client examples⁠.

⁠Persistence and configuration precedence
Storage file / directoryPurposeWhen changes apply
storage/webui-config.jsonWebUI environment overridesRestart the application
storage/db/wx2tg.dbBot bindings and runtime preferencesPreferences apply immediately; startup synchronization runs on next startup
storage/db/webui-messages.dbMessage center history and delivery trackingImmediately
storage/webui-media / storage/webui-avatarsAttachments and avatar cacheImmediately
storage/mcp-settings.jsonMCP enablement, client settings, and tokensImmediately, including token rotation
storage/webui-token, storage/mcp-token, storage/mcp-read-tokenGenerated access credentialsUsed for their respective interfaces

Docker mounts ./config as /app/storage; back it up with save-files, conf, and redis-data. WebUI environment overrides take priority over .env and container environment variables. To restore an environment default, stop the app, remove that key from webui-config.json, and restart. Saved MCP settings take priority over MCP_ENABLED, MCP_TOKEN, and MCP_READ_TOKEN; these variables initialize settings before the first WebUI MCP save. WEBUI_CONFIG_PATH relocates the WebUI file and MCP settings/token directory.

Normal startup leaves the WebUI available if Telegram credentials are missing. For setup without clients or a database, use npm run build then npm run webui; stop the standalone process before starting the normal app. Standalone mode cannot manage bot database preferences or send messages.

⁠Supported Message Types

⁠WeChat Message Type Support List
  • Text messages
  • Enterprise WeChat messages
  • WeChat stickers
  • Image messages
  • Video messages
  • Audio/Video calls (notification only)
  • File messages
  • Link messages
  • Group chat messages
  • Group chat @mentions (converts @everyone and @you to Telegram @you)
  • Official account messages
  • Emoji
  • Location messages
  • Message recall
  • Voice messages
  • Red packet messages (notification only, cannot retrieve content)
  • Mini program messages
⁠Telegram Message Type Support List
  • Text messages
  • Sticker emotes
  • Image messages
  • Video messages
  • File messages
  • Voice messages

⁠Precautions

  1. This project is for technical research and learning purposes only, strictly prohibited for illegal use
  2. Welcome to submit issues for any problems encountered during use
  3. Ensure that the IP of wx2tg-server matches the login region, otherwise a verification code may be required
  4. On arm-64 architecture, due to missing dependencies, the wx2tg-server image cannot be used.
  5. After logging in, you may be logged out once after one day; after logging in again, the connection will remain stable.

⁠Installation & Deployment

See the release notes⁠ for updates.

For a new deployment, copy .env.example to .env and configure the environment variables. Never overwrite existing private configuration, including the user’s home_202.env; merge required changes manually.

Copy app.conf.example to app.conf in the conf directory and set the Redis address to your deployed Redis address. For existing deployments, merge the new settings instead of overwriting your ports, Redis credentials, and callback URL.

Keep MODE=polling in .env and syncmessage=false, msgpush=false on the server. Server-side message archiving now defaults to SQLite at host path ./server-data/messages, independent of the bot database under ./config. Puppet 6.0.12 supports message-bearing callbacks and binary file sections. To switch to callback mode, also configure msgpush=true and a reachable callback URL on the server; see the linked notes.

Use Docker Engine with Docker Compose v2, or Node.js 18+ for local development. Native SQLite, image-processing, and media-conversion dependencies must match the runtime platform.

⁠Docker Compose

The Compose example below uses finalpi/wechat2tg:latest and finalpi/wx2tg-server:v6-latest. Save it as docker-compose.yml; no WebUI override is needed.

The commands below initialize a new stack. For an existing deployment, review your local Compose and preserve private configuration, then update the bot with docker compose pull wechat2tg and docker compose up -d --no-deps wechat2tg.

test -e .env || cp .env.example .env
mkdir -p conf
test -e conf/app.conf || cp app.conf.example conf/app.conf
docker compose pull
docker compose up -d
docker compose exec wechat2tg cat storage/webui-token

In .env, fill in BOT_TOKEN, API_ID, and API_HASH, or enter them through WebUI and restart the app after saving. The bundled example uses BASE_API=http://wx2tg-server:8058/api and redislink=wx2tg-redis:6379. Keep those Compose service names if using the bundled stack.

Open http://<server-address>:17863/ and sign in with the token. Then use Telegram /login to sign in to WeChat. Missing credentials leave the configuration page available. After saving environment settings in WebUI:

docker compose restart wechat2tg

Example Compose configuration:

services:
  wechat2tg:
    image: finalpi/wechat2tg:latest
    container_name: wechat2tg-v6
    environment:
      WEBUI_ENABLED: "${WEBUI_ENABLED:-true}"
      WEBUI_HOST: "0.0.0.0"
      WEBUI_PORT: "${WEBUI_PORT:-17863}"
    ports:
      - "${WEBUI_BIND_ADDRESS:-0.0.0.0}:${WEBUI_PORT:-17863}:${WEBUI_PORT:-17863}"
      # - "8056:8056" # callback 模式且需宿主机访问时启用 / Optional callback exposure
    volumes:
      - ./config:/app/storage
      - ./save-files:/app/save-files # 保存文件夹挂载后贴纸文件不需要重新转换
    env_file: ".env"
    restart: unless-stopped
    depends_on:
      - wx2tg-server

  wx2tg-server:
    image: finalpi/wx2tg-server:v6-latest
    container_name: wx2tg-server
    ports:
      - "8058:8058"
    volumes:
      - ./conf:/usr/wic-go/conf
      - ./server-data:/usr/wic-go/data
      - ./server-logs:/usr/wic-go/logs
    environment:
      MESSAGE_STORE_POSTGRES_DSN: "${MESSAGE_STORE_POSTGRES_DSN:-}"
    restart: unless-stopped
    depends_on:
      - wx2tg-redis

  wx2tg-redis:
    image: redis:7.2
    container_name: wx2tg-redis
    ports:
      - "16379:6379"
    volumes:
      - ./redis-data:/data
    command: ["redis-server", "--appendonly", "yes"]
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 30s
      timeout: 10s
      retries: 3
    restart: unless-stopped
Host portServiceDefault exposure
TCP 17863WebUI and MCP (/mcp)All host interfaces
TCP 8058WeChat protocol serviceAs defined in Compose
TCP 16379Redis (6379 inside the container)As defined in Compose
TCP 8056Optional callback modeCommented out; enable only if needed

Set WEBUI_PORT in .env to change both the container listener and published WebUI port. Set WEBUI_BIND_ADDRESS=127.0.0.1 for local-only access. Compose always uses WEBUI_HOST=0.0.0.0 inside the container. Port/binding or .env changes require recreating the container (docker compose up -d); a process restart alone does not change Docker port mappings.

For Internet access, route a configured HTTPS endpoint to the WebUI port and set that public /mcp URL in the MCP access page. Allow the chosen TCP port through your firewall and router/forwarding setup as applicable. A self-signed deployment needs its CA trusted by the client; the stdio bridge can use NODE_EXTRA_CA_CERTS=/absolute/path/to/ca.pem while retaining TLS validation. Deployment-specific IPs, ports, paths, and certificates belong in private configuration.

⁠Local development
npm install
npm run build
npm run dev

Open http://127.0.0.1:17863/. npm start runs compiled production code. Use .env.example for configuration and keep native dependencies aligned with your OS.

⁠Verification and logs
npm run test:webui
npm run test:mcp
docker compose logs --tail=100 wechat2tg

Tests use isolated message fixtures; they do not send to real WeChat contacts.

⁠Disable Bot Privacy Mode

Disable the bot's privacy mode. Open BotFather, enter /mybots, select your bot. Click Bot Settings - Group Privacy - Turn off. When Privacy mode is disabled for xxx appears, it means the disabling is successful.

⁠Bot Commands

  • /login: Get login QR code; the first person to send this command during initial deployment will become the bot owner

  • /logout: Logout and delete login cache

  • /update: Update group avatar and nickname information

  • /message: Toggle group message reception

  • /forward: Toggle forwarding of messages from other people or bots in the group

  • /user: List WeChat contacts, excluding official accounts; search by name or remark, e.g. /user Zhang, then create a group or bind the contact.

  • /official: List official accounts separately; search by name or remark, e.g. /official WeChat Pay, then create a group or bind the account to the current Telegram group.

  • /room: Get WeChat group list; click the button to create a new group or bind a WeChat group (can search by name or remarks, e.g., /room takeout to find WeChat groups containing "takeout")

  • /contacts [name or remark]: Read-only contact directory. Select a name to view cached WeChat ID, username, remark, region, signature and other available details; pagination and Back preserve your position. Never binds or creates groups. Without arguments in a Telegram group/topic bound to an individual contact, shows that contact directly (also with /contacts@your_bot). An explicit search still opens the list.

  • /members [group name or remark]: Select a WeChat group, browse its members and open member details. Supports pagination and returning to the original group list. Without arguments in a bound Telegram group or topic, opens the corresponding WeChat group directly. Only known profile fields are displayed.

  • /revoke: Revoke message (reply to the message to be revoked)

  • /relogin: Secondary login (use only when unexpectedly logged out after login, try to login with previously cached login information)

  • /getqr: Get personal QR code information

  • /settings: Program settings

  • /ai: Generate AI reply suggestions from the current WeChat chat context (for example, /ai make it more polite; use /ai context 30 to save the default context message count, or /ai -n 30 make it more polite to override it for one request)

  • /unbind: Unbind WeChat group or WeChat user (only supported in group usage)

  • /quit: Exit and disband group

Contact, official-account, and group searches also support bot mentions in groups:

/user@your_bot Zhang San
/official@your_bot WeChat Pay
/room@your_bot Project A (Development)

Replace @your_bot with your bot username. Queries preserve internal spaces and punctuation. List buttons show names or remarks without an added emoji prefix.

Starting with v6.0.15, directories use native Telegram RichMessage: click names and navigation directly inside the message, without duplicate lists or start-link redirects. Pages retain 30 entries, search and Back state. An explicit compatibility mode uses a compact ordinary keyboard, with bounded safe fallback. See directory pagination (Chinese)⁠.

⁠Environment Variables

NameRequiredDescription
BOT_TOKENYesTelegram Bot token, created via BotFather⁠
API_IDYesTelegram API ID
API_HASHYesTelegram API HASH
DEVICE_TYPEYesWeChat login protocol: ipad, car, mac, pad, win, ipadX
BASE_APIYeswx2tg-server container API request address, full path required
PROXY_PROTOCOLNoProxy type optional values (socks5, http, https)
PROXY_HOSTNoProxy URL
PROXY_PORTNoProxy port number
PROXY_USERNAMENoProxy username
PROXY_PASSWORDNoProxy password
ROOM_MESSAGENoDisplay format of WeChat group messages in Bot
OFFICIAL_MESSAGENoDisplay format of official account messages in Bot
CONTACT_MESSAGENoDisplay format of WeChat user messages in Bot
ROOM_MESSAGE_GROUPNoDisplay format of WeChat group messages in group
CONTACT_MESSAGE_GROUPNoDisplay format of WeChat user messages in group
OFFICIAL_MESSAGE_GROUPNoDisplay format of official account messages in group
CREATE_ROOM_NAMENoFormat of group name when automatically creating WeChat groups
CREATE_CONTACT_NAMENoFormat of group name when automatically creating WeChat contacts
MESSAGE_DISPLAYNoDisplay format of text messages
AI_API_KEYNoOpenAI-compatible API key for /ai reply suggestions
AI_API_URLNoOpenAI-compatible c

Tag summary

Content type

Image

Digest

sha256:556420c92…

Size

340.8 MB

Last updated

about 2 hours ago

docker pull finalpi/wechat2tg:v6-dev