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.
- Forward WeChat individual messages, group messages, and official account messages to Telegram.
- Reply to messages on Telegram to specified users.
- Support group blacklist and whitelist modes.
- Support for sending videos, files, stickers, images, and voice messages.
- This project is intended only for technical research and learning and must not be used for illegal purposes.
- Please submit any issues you encounter to the issue tracker.
- Due to limitations in the Telegram Bot API, it is not possible to send files larger than 20MB or receive files larger than 50MB.
-
Install dependencies:
npm install
-
Configure the Telegram bot token and proxy information in the
.env
file. -
Run the program:
npm start
-
In Telegram, send
/start
to begin or/login
to log in.
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
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=
# Telegram API配置(可选:发送大文件,自动创建group分组所需)
#- API_ID=
#- API_HASH=
restart: unless-stopped
docker-compose up -d
/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
BOT_TOKEN
(required): Telegram bot token, created via BotFather
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=
Due to Telegram Bot API limitations, files larger than 20MB cannot be sent, and files larger than 50MB cannot be received. If you need to send or receive larger files, please configure your API_ID
and API_HASH
.
How to obtain API_ID
and API_HASH
:
-
Log in to your telegram account
-
Click on "API development tools" and fill in your application details (only the application title and short name are required).
-
Finally, click "Create application."
Note: Because wechaty-puppet-wechat4u changes the ID each time it logs in again, it is not possible to obtain a unique key for each contact and group. The method to determine whether it is the same contact or group is by the contact's remark and nickname. This method may incorrectly bind to contacts and groups upon the next login if the remarks or nicknames are not unique, or if the name of the contact or group changes, which might cause binding failure. In such cases, re-binding is required.
-
Turn off the bot's privacy mode. Open BotFather, enter /mybots, select your bot, click Bot Settings - Group Privacy - Turn off. When you see Privacy mode is disabled for xxx, it means it has been successfully turned off.
-
Create a telegram group, add the bot to the group, and bind according to the prompts. Afterward, messages from the contact or group will be forwarded to the group.
/bind
: View the contacts or groups currently bound to the group.
/unbind
: Unbind the contacts or groups currently bound to the group.
/cgdata
: Set the group avatar and nickname to the WeChat contact or group (requires admin privileges).
- Configure
API_ID
andAPI_HASH
- Turn off the bot's privacy mode. Open BotFather, enter
/mybots
, select your bot, clickBot Settings
->Group Privacy
->Turn off
. When you see the messagePrivacy mode is disabled for xxx
, it means the privacy mode has been successfully turned off. - Use the
/autocg
command to enable automatic grouping mode. Follow the prompts to log in to Telegram.
MIT
Thanks to JetBrains for supporting this project