EhforwarderBot主要用于信息聚合,可以把微信/QQ等多个聊天软件的消息同一收集在一个软件上处理。我之前的EFB搭建在Azure100的韩国服务器上,近期尝试续期失败,决定迁移。目前EFB的安装过程感觉依旧较为麻烦,故作记录。

本次的目标是通过EFB实现微信-TG转移,具体搭建过程,原理分析请看:这个

配置环境

安装EFB/依赖

1
2
3
4
5
6
7
8
9
apt update && apt install python3 python3-pip python3-setuptools python3-yaml ffmpeg  libcairo2-dev  libcairo2 nano -y
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

pip3 install ehforwarderbot
pip3 install efb-telegram-master
pip3 install efb-wechat-slave
pip3 install --upgrade Pillow
pip3 install "efb-telegram-master[tgs]"

安装失败请看文末的方法。

安装中间件

我已经正在使用了一些中间件,包括一些自动语音识别之类的,也需要安装。Github上有同名的仓库,具体介绍了使用方法。

1
2
pip install efb-mp-instantview-middleware 
pip install efb-voice-recog-middleware

配置文件

接下来应该是配置文件了,当然是迁移,所以只需要将配置文件完整copy过来就行了。

首先关闭旧机子上的EFB程序,在退出EFB之前,记得先在微信里退出网页端,不然下次启动会出现重复发消息的bug(非常折磨,会在启动时把进几个小时发过的消息都再发送一遍)。

1
2
3
root@bailu:~# systemctl stop efb # slowly~
...
root@bailu:~#

(会卡住 非常久…当然为了数据不出问题还是不要强制停止了)

接下来使用rsync同步文件(记得在原服务器和新服务器上都安装):

1
2
3
4
5
6
7
8
9
10
11
12
root@bailu:~# rsync -avzhe ssh /root/.ehforwarderbot/ root@114.5.1.4:/root/.ethforwarderbot/

root@114.5.1.4's password:
sending incremental file list
created directory /root/.thforwarderbot
./
readme.md
...

sent 11.97M bytes received 320 bytes 2.18M bytes/sec
total size is 38.44M speedup is 3.21
root@bailu:~#

rsync具体解释如下:

-a表示以归档模式同步文件和目录(包括权限、所有者信息、时间戳等),-v表示输出详细日志,-z表示压缩传输,-h表示人性化显示文件大小,-e ssh表示通过SSH加密连接传输数据。把“/root/.ehforwarderbot/ ”替换成源服务器上efb目录的路径,“root”替换成目标服务器上的用户名,“114.5.1.4”替换成目标服务器的IP地址,“/root/.ethforwarderbot/”替换成目标服务器上存放efb目录的路径。

貌似没什么问题,接下来就是试启动了。

启动/守护进程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
root@bailu:~# ehforwarderbot


Confirm on your phone.
^[2023-06-05 11:20:56,758 [Level 99]: plugins.blueset.wechat.WeChatChannel (__init__.console_qr_code; __init__.py:198)
Successfully logged in.
2023-06-05 11:21:02,608 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:140)
Slave channel WeChat Slave (blueset.wechat) # Default profile is initialized.
2023-06-05 11:21:02,608 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:143)
Initializing master blueset.telegram...
2023-06-05 11:21:15,855 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:153)
Master channel Telegram Master (blueset.telegram) # Default profile is initialized.
2023-06-05 11:21:15,855 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:155)
All channels initialized.
2023-06-05 11:21:15,855 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:157)
Initializing middleware catbaron.voice_recog...
2023-06-05 11:21:15,860 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:167)
Middleware Voice Recognition Middleware (catbaron.voice_recog) # Default profile is initialized.
2023-06-05 11:21:15,861 [Level 99]: ehforwarderbot.__main__ (__main__.init; __main__.py:169)
All middlewares are initialized.

试着发一条消息测试tg的link是否正常,嗯非常正常,在这里基本上整个过程就结束了。

接下来就是守护进程的部署,先Ctrl+C退出EFB(注意先在微信退出网页端)然后创建守护进程配置文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
vim /etc/systemd/system/efb.service

# 复制 保存
[Unit]
Description=ehforwarderbot
After=network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
WorkingDirectory=/root
ExecStart=/usr/local/bin/ehforwarderbot
Restart=always

systemctl daemon-reload #重新加载进程守护
systemctl start efb.service
systemctl status efb #看不到二维码?没关系,点击日志中的链接在浏览器中打开二维码
systemctl enable efb.service # 开机启动

自动创建link及群组

差点忘了这个,来源于第三方更改的telegram主端:https://github.com/mlch911/efb-telegram-master, https://github.com/QQ-War/efb-telegram-master

首先要暂停efb-安装第三方的主端-启动(第一次安装注意配置blueset.telegram配置文件,详情见仓库readme后半段,注意两个仓库配置文件有细微差别)

1
2
3
systemctl stop efb
pip install git+https://github.com/QQ-War/efb-telegram-master.git
systemctl start efb

圆满结束。

安装报错:Cannot uninstall ‘PyYAML’

第一种办法

Cannot uninstall ‘PyYAML’

1
2
3
4
5
6
7
8
root@xxxxx:~# pip3 install efb-wechat-slave
Collecting efb-wechat-slave
Using cached efb_wechat_slave-2.0.4-py3-none-any.whl (216 kB)
省略``
Installing collected packages: PyYaml, itchat, efb-wechat-slave
Attempting uninstall: PyYaml
Found existing installation: PyYAML 3.12
ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

最后一句红字报错,翻译过来就是,错误:无法卸载“ PyYAML”。 这是一个 distutils 安装的项目,因此我们无法准确确定属于该文件的文件,这只会导致部分卸载。
pip 10 不再卸载 distutils 软件包。所以降级到 pip 8.1.1,根目录下:

1
sudo -H pip3 install pip==8.1.1

再次安装 efb-wechat-slave即可

第二种办法

这样也是可以的,来自网页,据说没有什么负面影响,仅仅会产生一些系统垃圾。

1
pip3 install --ignore-installed PyYAML