Sign inSign up

finalpi/wechat2tg-v3

By finalpi

•Updated 2 days ago

Telegram收发微信消息

Image
0

6.4K

finalpi/wechat2tg-v3 repository overview

⁠wechat2tg (v6)

中文⁠ | English

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

⁠Telegram Group: @Wx2TgUserGroup⁠

Warning

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

⁠Branch and Server Versions

Choose the branch that matches your wx2tg-server major version:

Repository branchRequired server version
v6wx2tg-server v6
v7wx2tg-server v7

Do not mix the v6 branch with server v7, or the v7 branch with server v6. When switching branches, also switch the server to the matching major version.

Both branches were initialized from the same wx2tg-v3 codebase. Creating these branches does not itself implement or verify compatibility; version-specific changes will be maintained on their respective branches.

⁠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

⁠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 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

Important

All three repositories now target **`v6.0.12`**: bot and puppet package versions are `6.0.12`; bot/server Docker tags are `v6.0.12`. Local Git tags do not mean npm/Docker artifacts have been published. See [release rules (Chinese)](docs/releases.md) and [v6 configuration and message flow notes (Chinese)](docs/server-v6.md). The v7 line is unchanged in this release.

First, copy .env.example to .env and configure the environment variables.

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.

⁠docker-compose

Create a docker-compose.yml file:

version: '3'

services:
  wx2tg-v3:
    image: finalpi/wechat2tg-v3:v6.0.12
    container_name: wx2tg-v3
    # ports:
    #   - "8056:8056" # Only for external callbacks; not needed within the Compose network
    volumes:
      - ./config:/app/storage
      - ./save-files:/app/save-files # After mounting save-files folder, sticker files do not need to be converted again
    env_file: ".env"
    restart: unless-stopped
    depends_on:
      - wx2tg-server

  wx2tg-server:
    image: finalpi/wx2tg-server:v6.0.12
    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
⁠Run
docker-compose up -d
⁠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: Get WeChat user list; click the button to create a new group or bind a user (can search by name or remarks, e.g., /user Zhang to find WeChat users containing "Zhang")

  • /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")

  • /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

⁠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 chat completions URL, e.g. https://api.openai.com/v1/chat/completions
AI_MODELNoAI model name, default: gpt-4o-mini
AI_CONTEXT_LIMITNoFallback default number of recent WeChat conversation messages used as AI context, default: 20; runtime default can be saved with /ai context <count> and overridden per request with /ai -n <count>

⁠Settings Command /settings

  1. WeChat emoji display as image links: When enabled, friend-sent Minions emojis will be converted to image links

  2. Synchronize group information on startup: When enabled, all user information will be synchronized when the program starts, updating group avatars and names

⁠Voice-to-Text

  1. Configure TENCENT_SECRET_ID and TENCENT_SECRET_KEY, which can be activated in the Tencent Speech Recognition Console⁠. Free usage quota is available.

  2. Enable automatic text-to-speech function in /settings

⁠Obtaining API_ID and API_HASH

  1. Log in to telegram account⁠

  2. Click "API development tools" and fill in application details (only application title and short name are required)

  3. Finally, click "Create application"

⁠Custom Message Templates

If you want to modify the message sender's format, you can modify the environment variables in docker or the .env file

Custom message template placeholders:

#[alias]: Contact remarks

#[name]: Contact nickname

#[topic]: Group chat nickname

#[alias_first]: Remarks priority, if no remarks, display contact's nickname

#[identity]: Identity information text

#[body]: Message body text

#[br]: Line break

⁠How to @everyone

Send a message starting with @all to @everyone, only supports text messages @everyone


⁠Frequently Asked Questions

⁠Why am I prompted to enter a verification code

wx2tg-server needs to be in the same region as your login. If you encounter a verification code prompt, check if they are in the same region.

If not in the same region, you can configure WeChat proxy login in environment variables, or migrate already logged Redis data.

⁠Participating in Development

  1. Fork the project and create a feature branch from v6; keep v7 work separate.

  2. Submit a Pull Request to the matching maintenance branch and follow the release rules (Chinese)⁠.

⁠License

MIT⁠

⁠Thanks

Thanks to Jetbrains for supporting this project

Tag summary

Content type

Image

Digest

sha256:3fc2261fd…

Size

555.3 MB

Last updated

27 days ago

docker pull finalpi/wechat2tg-v3