Loading... <div class="tip share">请注意,本文编写于 256 天前,最后修改于 73 天前,其中某些信息可能已经过时。</div> **Blog 好久没更新了,突发兴趣来更下,虽然隔壁的 IRC 教程被催过很多次了,但是这次依然是咕咕咕(** # 关于 **之前我的 PGM 一直是丢在 DigitalOcean 的白嫖机器上,但最近白嫖账户过期了就得想办法迁移到其他地方去了,毕竟我也不是 MJJ,手上没有那么多机器,思来想去还是找了台甲骨文新加坡 ARM 来放我的两个 PGM 了。** **所以,本教程是基于 ARM 来搭建**`Docker` 环境下的 `PagerMaid`与`PagerMaid-Pyro`。 **关于两个项目在其他架构,平台上的搭建教程,我相信在其他地方已经很完善了。这里就给出来一个** [官方教程](https://xtaolabs.com/) 一笔带过。 **两个项目的官方地址:** * [PagerMaid-Modify](https://gitlab.com/Xtao-Labs/pagermaid-modify/-/tree/master/), 这个项目将要被弃用。 * [PagerMaid-Pyro](https://github.com/TeamPGM/PagerMaid-Pyro),新的项目。 **至于 PGM 即将被弃用的原因,是因为 PGM 使用的轮子是telethon,某次跟作者闲聊提起迁移项目,作者表示 telethon 已经半年没更新了** ~而且代码写的也像屎一样~,所以就早点润掉了。 **但目前 PagerMaid-Pyro 项目依然处于早期阶段,很多 PGM 上的插件都没有被迁移到新项目下,所以产生了多开的需求。** # 环境 * **宿主机** * **4C 24G 甲骨文白嫖来的机器** * **Ubuntu 20.04** * **Docker 虚拟机 Ubuntu22.04** * **PagerMaid-Pyro** * **PagerMaid-Modify** **命令除非特殊说明,均以 Root 用户执行** # 安装 ## Docker **至于为什么要 Docker 而不是直接在宿主机里装 BOT,因为两个 PG 均不支持 ARM 平台,得先套一层 Docker 虚拟化(** **先装下我个人经常用的一些东西。** ```bash apt update && apt upgrade apt-get install htop wget curl git -y ``` **直接跑官方的脚本先给 Docker 装上。** ```bash curl -fsSL https://get.docker.com | bash -s docker ``` ## Docker 里搭建 Ubuntu 22.04 **首先需要先魔改一下 Docker 镜像,Docker 的 Ubuntu 镜像自 18.04 之后就删除了 init 和 ssh。** ```bash cd ~ # 拉一下镜像 docker pull ubuntu:22.04 # 写个 Dockerfile cat <<'EOF' > Dockerfile FROM ubuntu:22.04 RUN apt-get update && apt-get install -y init locales && apt-get clean all \ && rm -rf /var/lib/apt/lists/* \ && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 ENV LANG en_US.utf8 EOF # 构建镜像 docker build -f ./Dockerfile . -t pagermaid/ubuntu # 启动容器 docker run -tid --name pagermaid --privileged=true pagermaid/ubuntu /sbin/init ``` ## 在 Docker 内装环境 **先 exec 进 docker,多多少少先拿到 Docker 内的 shell。** ```bash docker exec -it pagermaid /bin/bash ``` **这里开始都是在 Docker 环境内操作了,所以请先检查你的环境对不对,别整半天发现还在宿主机里。** **进来后,惯例,先 update upgrade 一把梭。** ```bash apt update && apt upgrade apt install git wget curl screen htop vim -y ``` **然后开始装 PGM 和 PGP 的环境,设置 redis 的自启动。** ```bash # 装点必要的包 apt-get install imagemagick neofetch libwebp-dev libzbar-dev libzbar-dev libxml2-dev libxslt-dev tesseract-ocr tesseract-ocr-all redis-server python3-pip iputils-ping -y # redis systemctl start redis-server systemctl enable redis-server ``` **因为换到了 ubuntu22.04,默认自带的 python3 版本是 3.10,所以不再需要编译安装python**,下面的 `编译 python3 备份` 这个步骤直接跳过即可。 <div class="panel panel-default collapse-panel box-shadow-wrap-lg"><div class="panel-heading panel-collapse" data-toggle="collapse" data-target="#collapse-2daef7debeab2e9c1a13032219569dcb61" aria-expanded="true"><div class="accordion-toggle"><span>编译 python3 备份</span> <i class="pull-right fontello icon-fw fontello-angle-right"></i> </div> </div> <div class="panel-body collapse-panel-body"> <div id="collapse-2daef7debeab2e9c1a13032219569dcb61" class="collapse collapse-content"><p></p> ```bash # cd ~ # apt-get --purge remove python3 python3-pip -y # apt install build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev -y # wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz # tar -xzvf Python-3.9.0.tgz # cd Python-3.9.0 # ./configure --prefix=/usr/local/python3 # make # make install ## 做 Python 的软链 # rm -f /usr/bin/python3 # rm -f /usr/local/bin/pip3 # ln -s /usr/local/python3/bin/python3.9 /usr/bin/python3 # ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip3 ``` ~然后尝试执行下 `python3 -V && pip3 -V`,如果提示 python 版本是 3.9.0的话就一切正常,如果不正常的话,尝试使用 `which` 命令来查找下现在用的 python 和 pip,哪个不对删哪个。~ ``` # root@Telegram-User-Bot:~# python3 -V && pip3 -V # Python 3.9.0 # pip 22.1.1 from /usr/local/python3/lib/python3.9/site-packages/pip (python 3.9) ``` ~接下来用你喜欢的文本编辑器,编辑 `/usr/bin/lsb_release` 文件第一行的 `#!/usr/bin/python3 -Es` 为 `#!/usr/bin/python3.5 -Es` 即可。~ <p></p></div></div></div> **开始下载 PGM 和 PGP 的源码。** ```bash # PGM git clone https://gitlab.com/Xtao-Labs/PagerMaid-Modify.git /root/pagermaid # PGP git clone https://github.com/TeamPGM/PagerMaid-Pyro.git /root/pagermaid-pyro ``` **先后进入到 git clone 下来的文件夹中安装下 pip 环境。** ```bash python3 -m pip install --upgrade pip # 更新下 pip cd /root/pagermaid && pip3 install -r requirements.txt cd /root/pagermaid-pyro && pip3 install -r requirements.txt ``` **到这里,基本就可以跑起来了** 将两个项目下的 `config.gen.yml` 依次修改为 `config.yml` 并编辑 `api_id` 和 `api_hash` 以后即可使用 `python3 -m pagermaid` 尝试跑起来了。 如果你出现了这样的提示,那就说明没啥特别大的问题,根据提示填写信息后,会提示你在 TG 客户端内输入 `help` 指令,根据提示输入后,如果能看到消息被编辑,`Ctrl+C` 结束掉即可。  ## 收尾 **写入 systemctl 文件方便管理。** ```bash # PGP cat <<'EOF' > /etc/systemd/system/pagermaid-pyro.service [Unit] Description=PagerMaid-Pyro telegram utility daemon After=network.target [Install] WantedBy=multi-user.target [Service] Type=simple WorkingDirectory=/root/pagermaid-pyro ExecStart=/usr/bin/python3 -m pagermaid Restart=always EOF #PGM cat <<'EOF' > /etc/systemd/system/pagermaid.service [Unit] Description=PagerMaid-Modify telegram utility daemon After=network.target [Install] WantedBy=multi-user.target [Service] Type=simple WorkingDirectory=/root/pagermaid ExecStart=/usr/bin/python3 -m pagermaid Restart=always EOF # 重载 systemctl daemon-reload # 改变系统时区 timedatectl set-timezone Asia/Shanghai # 启动 BOTs systemctl start pagermaid.service systemctl start pagermaid-pyro.service # 开机自启动 systemctl enable pagermaid.service systemctl enable pagermaid-pyro.service ``` 最后修改:2022 年 11 月 27 日 © 允许规范转载 赞 16 给点.jpg
13 条评论
麻烦问下大佬,这个是怎么回事的:
return _run_code(code, main_globals, None,Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)File "/root/pagermaid/pagermaid/__main__.py", line 7, in
from pagermaid.utils import langFile "/root/pagermaid/pagermaid/utils.py", line 12, in
from emoji import get_emoji_regexpImportError: cannot import name 'get_emoji_regexp' from 'emoji' (/usr/local/lib/python3.10/dist-packages/emoji/__init__.py)
cd /root/pagermaid && pip3 install -r requirements.txt
cd /root/pagermaid-pyro && pip3 install -r requirements.txt
这一步我弄了的
有可能是 emoji 新版本语法变化了,我看了下我本地 emoji 的版本,是 1.7.0,可以试试先给这个轮子卸掉,装 1.7.0 版本的 emoji(
换成1.7.0确实可以了
好的 我去试下 感谢大佬回复
apt add-apt-repository ppa:dawidd0811/neofetch # 为了之后安装 neofetch 做准备 这步前面多了个apt吧 报E: Invalid operation add-apt-repository了
apt update && apt upgrade
apt-get install software-properties-common -y
可以尝试先执行这两条命令以后再
apt add-apt-repository ppa:dawidd0811/neofetch
嗯 发现了,朋友也给我报这个问题了。
收不到验证码什么情况
在我这边完全正常,可以尝试去给作者提 issue