/wechat2tg

微信消息转发到telegram

Primary LanguageTypeScriptMIT LicenseMIT

English | 中文

This project is based on wechaty and implements a WeChat message forwarding to Telegram bot using the puppet-wechat4u protocol UOS. Thus, it can circumvent the issue where some accounts are unable to log in to the WeChat web version.

Main Features

  1. Forward WeChat individual messages, group messages, and official account messages to Telegram.
  2. Reply to messages on Telegram to specified users.
  3. Support group blacklist and whitelist modes.
  4. Support for sending videos, files, stickers, images, and voice messages.

Notice

  1. This project is intended only for technical research and learning and must not be used for illegal purposes.
  2. Please submit any issues you encounter to the issue tracker.
  3. Due to limitations in the Telegram Bot API, it is not possible to send files larger than 20MB or receive files larger than 50MB.

Installation

Using in Node.js v16 or higher

  1. Install dependencies:

    npm install
  2. Configure the Telegram bot token and proxy information in the .env file.

  3. Run the program:

    npm start
  4. In Telegram, send /start to begin or /login to log in.

Using in Docker

docker run -itd --env BOT_TOKEN="" --env PROXY_HOST="" --env PROXY_PORT="" --env PROXY_USERNAME="" --env PROXY_PASSWORD="" --env PROXY_PROTOCOL="socks5" finalpi/wechat2tg:latest

Using in docker-compose

create file docker-compose.yml:

version: '3'

services:
  wechat2tg:
    image: finalpi/wechat2tg:latest
    container_name: wx2tg
    volumes:
      - ./config:/app/storage
    environment:
      - BOT_TOKEN=
      # - PROXY_HOST=
      # - PROXY_PORT=
      # 代理类型:socks5,http,https
      # - PROXY_PROTOCOL=socks5
      # 用户名密码可选
      # - PROXY_USERNAME=
      # - PROXY_PASSWORD=
    restart: unless-stopped
docker-compose up -d

BOT Commands Explanation

/login: Retrieve the login QR code

/user: Fetch the user list, click to reply

/room: Fetch the group list, click to reply

/recent: Fetch the most recent users or groups that have sent messages, click to reply

/setting: Program settings:

Message mode switch:

Switch between blacklist or whitelist mode

Whitelist mode: Only receive messages from groups in the whitelist

Blacklist mode: Do not receive messages from groups in the blacklist

Feedback on successful delivery: Whether to provide feedback on the message delivery status

Automatic contact switch: Automatically switches back to replying to a user or group if they reply. Please note that having a message sent to you just before sending may result in an incorrectly sent message!

Receive official account messages: Whether to accept messages from official accounts

Configuration Explanation

BOT_TOKEN (required): Telegram bot token, created via BotFather

Using a Proxy

Use a proxy to forward requests to the Telegram bot, leave blank if not using a proxy:

# Proxy configuration (optional)
# Protocol socks5, http, https
PROXY_PROTOCOL=socks5
PROXY_HOST=
PROXY_PORT=
PROXY_USERNAME=
PROXY_PASSWORD=

License

MIT

Thanks

Thanks to JetBrains for supporting this project

Jetbrains