GithubHelp home page GithubHelp logo

monster1237 / wechat2tg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from finalpi/wechat2tg

0.0 0.0 0.0 551 KB

微信消息转发到telegram

License: MIT License

JavaScript 0.28% TypeScript 99.32% Dockerfile 0.40%

wechat2tg's Introduction

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=
      # Telegram API配置(可选:发送大文件,自动创建group分组所需)
      #- API_ID=
      #- API_HASH=
    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=

Receiving and Sending Large Files

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:

  1. Log in to your telegram account

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

  3. Finally, click "Create application."

Manual grouping of messages

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.

  1. 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.

  2. 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).

Automatic Grouping of Messages

  1. Configure API_ID and API_HASH
  2. Turn off the bot's privacy mode. Open BotFather, enter /mybots, select your bot, click Bot Settings -> Group Privacy -> Turn off. When you see the message Privacy mode is disabled for xxx, it means the privacy mode has been successfully turned off.
  3. Use the /autocg command to enable automatic grouping mode. Follow the prompts to log in to Telegram.

License

MIT

Thanks

Thanks to JetBrains for supporting this project

Jetbrains

wechat2tg's People

Contributors

finalpi avatar nimbly8836 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.