EFB v2.0 Ubuntu 部署教程 (3/3)

| 原创 | 教程 Telegram EFB

🆗 在 Ubuntu 上部署 EhForwarderBot,实现从微信到 Telegram 的迁移

📌 这个系列此前的文章:

1、EFB 介绍 (1/3)
2、EFB v1.0 CentOS 部署教程 (2/3)

📌 更新日志:

  • 2018-06-22

bug:发送 /link/chat 指令后一直显示在处理中,log日志输出 Nonetype 错误
状态: 已修复

  • 2018-04-30

Ubuntu 18.04 测试通过,修改了进入 miniconda 环境的命令。

📌 详细解决方案:

# [zh-cn]前言:你可以通过下面的方法一步一步在服务器配置EFB
# [en]Prefix: You can follow the commands to set up your EFB on your VPS.
# [zh-cn]注意:这不是一个自动化脚本,仅提供思路和步骤参考
# [en]Caution: This is not a sh file, only cover with my way to success.
# Ubuntu 16.04.3 LTS / 18.04 LTS with sudo

# [zh-cn]首先,升级你的软件包并安装所需的依赖
sudo apt update && sudo apt upgrade -y && 
sudo apt install wget curl screen vim ffmpeg libmagic-dev libwebp-dev libsqlite3-dev -y

# [zh-cn]下载Miniconda并安装
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash ./Miniconda3-latest-Linux-x86_64.sh

# [en]Restart your terminal
# [en]If you are connect with ssh, you should first `exit` and then `ssh ip` again
conda create -n efb pip
source activate efb

# [zh-cn]这是python环境安装的替代方法,如果上面的miniconda无法正常安装,请参考这里
# curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
# export PATH="$HOME/.pyenv/bin:$PATH"
# eval "$(pyenv init -)"
# eval "$(pyenv virtualenv-init -)"
# pyenv install 3.6.4
# pyenv global 3.6.4

# [zh-cn]接着你需要在Telegram获取到你的bot api、bot管理员id
# [en]for TG bot token and admin id, you can refer to this url: https://www.ynewtime.com/EFB-sh
export TGBOTTOKEN=""
export TGADMIN=""

# [zh-cn]初始化python环境并安装ehforwarderbot
pip install ehforwarderbot efb-telegram-master efb-wechat-slave imageio_ffmpeg

# [zh-cn]创建并写入EFB的配置文件
mkdir -p ~/.ehforwarderbot/profiles/default/blueset.telegram

cat>~/.ehforwarderbot/profiles/default/config.yaml<<EOF
master_channel: "blueset.telegram"
slave_channels:
- "blueset.wechat"
EOF

cat>~/.ehforwarderbot/profiles/default/blueset.telegram/config.yaml<<EOF
token: "$TGBOTTOKEN"
admins:
- $TGADMIN
EOF

# [zh-cn]使用screen启动ehforwarderbot
# [zh-cn]注意:启动成功后退出screen环境要用快捷键ctrl+a -> ctrl+d
# [en]press ctrl+a and ctrl+d to go back to terminal
# [zh-cn]注意:ctrl+c会导致screen进程终止,请谨慎使用
screen ehforwarderbot

# 后续:
# 按照上面的步骤创建完的bot是没有显式的把命令标注在bot底端输入栏的,
# 因此,你需要去@BotFather那儿自定义一串命令,操作步骤是:
# /mybots - (选择你的bot) - Edit Bot - Bot Commands - 输入下面的文字:
# chat - 开启会话
# link - 将会话绑定到Telegram群组
# extra - 获取
# 搞定。

# 2018-10-18补充:如果要将某些特定的群组或会话绑定到Telegram的自定义群组,
# 请记得在 @BotFather 处将你的 bot 修改为 inline bot,根据上面类似的步骤即可。

# enjoy

本文收录于 【互联网社区贡献的资源