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 QQ
, WeChat, Facebook Messenger
, and other messages on Telegram
. You can also send and receive N
WeChat accounts, N
QQ accounts, etc. Here, I 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
, and 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 the file
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 the Framework
#Install stable version
pip3 install ehforwarderbot
#Install development version, recommended for 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 something else if you prefer
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 module names; refer to the module list → 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 in to one WeChat account. If you want to log in to multiple WeChat accounts simultaneously, the configuration file needs to be changed to:
#For example, 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
You just need to specify an ID
number after #
, 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
. Here’s how to get them:
#Getting Telegram 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 once named, 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.
Next, create a Telegram
module configuration folder and configuration file config.yaml
using the command:
#Also create 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 a QR code link will be provided for you to scan and log in. If you set up to log in to multiple accounts, 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 specific 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 generally, 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 the Docker
method. This method was mentioned a long time ago; refer to → Portal. However, the startup command has changed slightly, which is the command to install 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 for receiving 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 noVNC
at ip:9000
to log in to CoolQ
.
Create a QQ
module configuration file:
mkdir ~/.ehforwarderbot/profiles/default/milkice.qq
nano ~/.ehforwarderbot/profiles/default/milkice.qq/config.yaml
The code to fill in is roughly 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 effective when is_pro is false
upload_to_smms: true # Upload images from EFB main end (usually Telegram) to sm.ms server and send as links to QQ
Finally, use the ehforwarderbot
command to start.
Docker Installation#
Here, I 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 the installation was successful
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 how to obtain 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 start will build the image, so it will be slower
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 how to obtain them
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.
Lastly, no additional configuration files have been 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 messages, location, etc. Generally, it is sufficient. As for QQ
, the functionality is definitely limited by CoolQ
, and it currently cannot 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.