banner
moeyy

moeyy

一条有远大理想的咸鱼。
github
mastodon
email

Use EH Forwarder Bot to send and receive multiple WeChat/QQ messages on Telegram simultaneously.

Description: EH Forwarder Bot is an extensible chat tunnel framework that allows users to send and receive messages from multiple IM platforms simultaneously and ultimately manage their accounts remotely. Currently, it supports sending and receiving messages from QQ, WeChat, Facebook Messenger, etc., on Telegram. You can also send and receive messages from N WeChat accounts, N QQ accounts, etc. Here, we will discuss the manual installation and Docker installation for sending and receiving WeChat/QQ messages on Telegram.

Sending and Receiving WeChat Messages#

Project Address: https://github.com/blueset/ehForwarderBot

Module addresses used:

#Telegram Module
https://github.com/blueset/efb-telegram-master
#WeChat Module
https://github.com/blueset/efb-wechat-slave

Other module addresses → Portal, including modules like Facebook Messenger, which you can check out if interested.

Environment Requirements: Python 3.6+, EH Forwarder Bot 2.0+, ffmpeg, libmagic, libwebp

The manual tutorial is suitable for Debian, CentOS, Ubuntu. If you want to use Ubuntu, it is best to use version 18.04+.

1. Install Dependencies

#CentOS System
yum install file-devel libwebp-tools git screen -y

#Debian/Ubuntu System
apt install libwebp-dev libmagic-dev git screen -y

2. Install Python 3.6

#CentOS System
wget https://www.moeyy.cn/usr/shell/Python3/CentOS_Python3.6.sh && sh CentOS_Python3.6.sh
#Debian System
wget https://www.moeyy.cn/usr/shell/Python3/Debian_Python3.6.sh && sh Debian_Python3.6.sh
#Ubuntu System
apt update
apt install python3-pip python3-setuptools python3-dev -y

3. Install ffmpeg

#Download ffmpeg binary
wget https://www.moeyy.cn/usr/down/ffmpeg/ffmpeg-git-$(getconf LONG_BIT)bit-static.tar.xz
#Extract files
tar xvf ffmpeg-git-*-static.tar.xz
#Move ffmpeg executable files
mv ffmpeg-git-*/ffmpeg  ffmpeg-git-*/ffprobe /usr/bin/
#Delete files
rm -rf ffmpeg-git-*

4. Install Framework

#Install stable version
pip3 install ehforwarderbot

#Install development version, recommended as it has quicker bug fixes and new features
pip3 install git+https://github.com/blueset/ehforwarderbot.git

5. Install TG and WeChat Modules

pip3 install efb-telegram-master efb-wechat-slave

6. Enable Modules
First, create a configuration folder and configuration file config.yaml using the command:

#default is the default folder for configuration files, you can name it differently, just use default if unsure
mkdir -p ~/.ehforwarderbot/profiles/default
nano ~/.ehforwarderbot/profiles/default/config.yaml

The reference code is:

#Please modify according to actual situation
master_channel: foo.demo_master
slave_channels:
- foo.demo_slave
- bar.dummy
middlewares:
- foo.null

The above corresponds to the module names, refer to the module → Portal. For example, here the author only used the Telegram and WeChat modules, so the configuration would be:

master_channel: blueset.telegram
slave_channels:
- blueset.wechat

Then use Ctrl+x, y to save and exit.

This only logs into one WeChat account. If you want to log into multiple WeChat accounts simultaneously, the configuration file needs to be changed to:

#For example, if I want to log in and send/receive messages from 3 WeChat accounts
master_channel: blueset.telegram
slave_channels:
- blueset.wechat
- blueset.wechat#moe123
- blueset.wechat#rats321

Just use # to specify an ID number at the end, which can only contain letters, numbers, and underscores, i.e., the regular expression [a-zA-Z0-9_]+. Add as many as you want to log in. If you are using QQ or Facebook Messenger modules, the setup method is the same.

7. Create TG Configuration File
Before creating the configuration file, you need to obtain the Token and Userid from Telegram. The method to obtain them is as follows:

#Getting Telegram's Token
1. Follow @BotFather on Telegram
2. In the chat window, enter: /start=>/newbot, then you will be asked to name the bot (e.g., MoeratsBot), and upon naming, you will receive a Token.

#Getting Telegram Group Userid
1. First, chat with your bot and send any message.
2. In the browser, enter https://api.telegram.org/botxx:xx/getUpdates (where xx:xx is the Token), then the id after chat is your userid.

Then create a Telegram module configuration folder and configuration file config.yaml using the command:

#Also create it in the default folder; if you changed the default folder above, change it here as well
mkdir ~/.ehforwarderbot/profiles/default/blueset.telegram
nano ~/.ehforwarderbot/profiles/default/blueset.telegram/config.yaml

Fill in the following code:

token: "12345:moerats" 
admins:
- 765432 

Then use Ctrl+x, y to save and exit. The parameters correspond to Token and Userid. For more ways to use the Telegram module, refer to → Portal.

8. Start

#This command will read information from the default folder by default; if you created a moeyy.cn folder, the command should be ehforwarderbot -p moerats
ehforwarderbot

At this point, a WeChat QR code or QR code link will be provided to you. Open it in a browser and scan to log in. If you set it to log in to multiple accounts simultaneously, you will need to log in to each one.

Then use Ctrl+C to disconnect, and run the command in the background:

screen -dmS EHF ehforwarderbot

Finally, your WeChat messages will be sent to you via the bot, and you can also send messages to designated friends through the bot.

Sending and Receiving QQ Messages#

Note: This is just a brief mention; understanding it is sufficient. It is recommended to use the Docker installation method below.

Module addresses used:

#Telegram Module
https://github.com/blueset/efb-telegram-master
#QQ Module
https://github.com/milkice233/efb-qq-slave

Since the method is written very roughly, you need to understand the method for sending and receiving WeChat messages. Here, EH Forwarder Bot only supports the CoolQ client, and it is generally installed on Linux using Docker. This method was mentioned a long time ago, refer to → Portal, but the startup command has changed, which is the command for installing wine-coolq.

Install TG and QQ modules:

pip3 install efb-telegram-master efb-qq-slave

Install wine-coolq:

mkdir coolq  #Contains CoolQ program files
docker run -ti --rm --name cqhttp-test --net="host" \
     -v $(pwd)/coolq:/home/user/coolq     `#mount coolq folder` \
     -p 9000:9000                         `#Web noVNC port` \
     -p 5700:5700                         `#CoolQ API interface port` \
     -e VNC_PASSWD=MAX8char               `#Please change the VNC password!!!!` \
     -e COOLQ_PORT=5700                   `#CoolQ API interface port` \
     -e COOLQ_ACCOUNT=123456              `#Enter the QQ number to log in here; although optional, it is recommended to fill in` \
     -e CQHTTP_POST_URL=http://127.0.0.1:8000   `#efb-qq-slave listening port/address to receive incoming messages` \
     -e CQHTTP_SERVE_DATA_FILES=yes       `#Allow HTTP access to CoolQ data files` \
     -e CQHTTP_ACCESS_TOKEN=ac0f790e1fb74ebcaf45da77a6f9de47  `#Access Token` \
     -e CQHTTP_POST_MESSAGE_FORMAT=array  `# Use array when returning messages (required)` \
     richardchien/cqhttp:latest

Then access ip:9000 to log in to noVNC for CoolQ.

Create a QQ module configuration file:

mkdir ~/.ehforwarderbot/profiles/default/milkice.qq
nano ~/.ehforwarderbot/profiles/default/milkice.qq/config.yaml

Fill in the code as follows:

Client: CoolQ                         #Specify the QQ client to use (here it is CoolQ)
CoolQ:
    type: HTTP                        #Specify the communication method between efb-qq-slave and CoolQ; currently only supports HTTP
    access_token: ac0f790e1fb74ebcaf45da77a6f9de47
    api_root: http://127.0.0.1:5700/  # CoolQ API interface address/port
    host: 127.0.0.1                   # Address that efb-qq-slave listens to for receiving messages
    port: 8000                        # Same as above
    is_pro: false                      # If it is CoolQ Pro, set to true; otherwise, false
    air_option:                       # Configuration options included in air_option are only valid when is_pro is false
        upload_to_smms: true          # Upload images from the EFB main end (usually Telegram) to sm.ms server and send as links to QQ

Finally, start it using the ehforwarderbot command.

Docker Installation#

Here, we choose 2 of the latest Docker images, which are also officially recommended. Project addresses:

#Telegram Sending and Receiving QQ Messages
https://github.com/Earth-Online/efb-qq-coolq-docker
#Telegram Sending and Receiving WeChat Messages
https://www.github.com/Mikubill/efb-wechat-docker

1. Install Docker

#CentOS 6
rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum update -y
yum -y install docker-io
service docker start
chkconfig docker on

#CentOS 7, Debian, Ubuntu
curl -sSL https://get.docker.com/  sh
systemctl start docker
systemctl enable docker

2. Telegram Sending and Receiving QQ Messages
Install docker-compose:

curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
#Verify if installed successfully
docker-compose --version
#If the following information is returned, the installation is successful
docker-compose version 1.23.2, build 1110ad01

Pull Docker source code:

git clone https://github.com/Earth-Online/efb-qq-coolq-docker.git
cd efb-qq-coolq-docker
#Edit config.yaml configuration file
nano ehforward_config/profiles/default/blueset.telegram/config.yaml

Modify as follows:

#Refer to the manual installation tutorial above for obtaining token and userid parameters
token: "Your TG Bot Token"
admins:
- Your Userid

Then edit the docker-compose.yml file:

nano docker-compose.yml

Modify as follows:

- VNC_PASSWD=Your Password
- COOLQ_ACCOUNT=Your QQ Account

Start in the background:

#The first startup will build the image, so it will be a bit slow
docker-compose up -d

Then open ip:9801 to log in to novnc and complete the CoolQ login operation. If this address does not open, please check the firewall.

3. Telegram Sending and Receiving WeChat Messages

#Pull the source code
git clone https://github.com/mikubill/efb-wechat-docker.git
#Build the image
cd efb-wechat-docker && docker build -t mikubill/efbwechat .
#Start the image, TOKEN is the TG Bot Token, ADMIN is your Userid, refer to the manual installation tutorial above for obtaining methods
docker run -d -t --name "efbwechat" -e TOKEN=xxxx -e ADMIN=xxxx mikubill/efbwechat

Finally, obtain the WeChat login verification code using the command:

docker logs -f efbwechat 

Scan to log in.

Finally, no additional configuration files were provided for WeChat here; the default WeChat configuration is used directly. If you want to extend WeChat functionality, you can refer to → Portal, but since the module uses the WeChat web version, the supported features are limited, such as: no Moments, cannot send voice, location, etc. Generally, it is sufficient, and for QQ, the functionality is definitely limited by CoolQ, and it cannot currently handle friend request processing, group request processing, voice sending/receiving, etc. For the Facebook Messenger module, those interested can try installing and configuring it themselves.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.