前言
EHForwarderBot是一个开源项目,利用Telegram中的Bot来实现在Telegram上收发微信消息的效果。本文参考了官方文档中的相关指引,并综合网上所能查到的资料在CentOS7上搭建成功,希望能帮助到想在CentOS7上搭建该服务的朋友们。(THForwarderBot以下简称TFB)
准备工作
此程序会调用Telegram中的BOT,因此你需要在telegram中事先申请一个BOT,具体教程详见作者博文的0x030章节
设置目录并安装
首先安装git,并进入到你想要安装EHForwarderBot的目录,当然可以在~目录下直接安装,此处我选择把它放在/usr/local目录下
yum install git -y
cd /usr/local
git clone https://github.com/blueset/ehForwarderBot.git
cd ehForwarderBot
进入该目录后再新建一个文件夹来存放日后运行EFB时所要处理的信息
mkdir storage
chmod +rw /usr/local/storage
安装依赖
安装Python3.6
cd ~
yum install -y https://centos7.iuscommunity.org/ius-release.rpm
yum update -y
yum install -y python36u python36u-libs python36u-devel python36u-pip python36u-setuptools
which -a python3.6
运行完成后再shell中键入python3.6看能否进入python,如果能则进入下一步,如果显示路径错误则编辑~/bashrc文件vi ~/.bashrc
在其中键入python3.6='/usr/bin/python3.6'
退出vi编辑器并在shell下键入source ~/.bashrc
保存更改
安装非Python依赖项
sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum install -y libwebp-devel file-devel ffmpeg
后续配置
cd /usr/local/ehForwarderBot/
pip3.6 install -r requirements.txt
cp config.sample.py config.py
vi config.py
配置文件援引作者博客0x31的内容。其中token填写刚刚申请到的BOT密钥。admins填写你的telegramID。ID的获取可以@get_id_bot 发送 /start来获得。
# ##############################
# Configs for EH Forwarder Bot
# ##############################
#
# Basic settings
# ----------------
#
# Master/Slave Channels
#
# Master channel:
# The channel that is mainly used to view/manage messages
# from slave channels.
# Currently only 1 master channel is supported.
#
# Slave channels:
# Channels that are hosted on the server and being delivered
# to and from the master channel.
# You may have more than 1 slave channel.
#
master_channel = 'plugins.eh_telegram_master', 'TelegramChannel'
slave_channels = [('plugins.eh_wechat_slave', 'WeChatChannel')]
#
# Plugin specific settings
# --------------------------
# Plugin specific settings should be written below in the format of:
# `channel_name = {"key1": "value1", "key2": "value2"}`
# Please refer to docs of individual plugin for details
#
eh_telegram_master = {
"token": "12345678:QWFPGJLUYarstdheioZXCVBKM",
"admins": [123456789]
}
启动服务
进入EHB的目录,键入以下命令以开启服务
python3.6 daemon.py start
然后会弹出二维码,扫码即可。
参考文献
https://ehforwarderbot.readthedocs.io/en/latest/ https://blog.1a23.com/2017/01/09/EFB-How-to-Send-and-Receive-Messages-from-WeChat-on-Telegram-zh-CN/