这是一篇发布于 627 天前的文章,部分信息可能已发生改变。
Blog 好久没更新了,突发兴趣来更下,虽然隔壁的 IRC 教程被催过很多次了,但是这次依然是咕咕咕(
关于
之前我的 PGM 一直是丢在 DigitalOcean 的白嫖机器上,但最近白嫖账户过期了就得想办法迁移到其他地方去了,毕竟我也不是 MJJ,手上没有那么多机器,思来想去还是找了台甲骨文新加坡 ARM 来放我的两个 PGM 了。
所以,本教程是基于 ARM 来搭建 Docker
环境下的 PagerMaid
与 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 虚拟化(
先装下我个人经常用的一些东西。
1 2
| apt update -y && apt upgrade -y apt-get install htop wget curl git -y
|
直接跑官方的脚本先给 Docker 装上。
1
| curl -fsSL https://get.docker.com | bash -s docker
|
Docker 里搭建 Ubuntu 22.04
首先需要先魔改一下 Docker 镜像,Docker 的 Ubuntu 镜像自 18.04 之后就删除了 init 和 ssh。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| cd ~
docker pull ubuntu:22.04
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
|
启动容器
请注意,下面的命令按照注释二选一复制粘贴即可。
1 2 3 4 5
| docker run -tid --name pagermaid --privileged=true pagermaid/ubuntu /sbin/init
docker run -tid -p 3333:3333 --name pagermaid --privileged=true pagermaid/ubuntu /sbin/init
|
在 Docker 内装环境
先 exec 进 docker,多多少少先拿到 Docker 内的 shell。
1
| docker exec -it pagermaid /bin/bash
|
这里开始都是在 Docker 环境内操作了,所以请先检查你的环境对不对,别整半天发现还在宿主机里。
进来后,惯例,先 update upgrade 一把梭。
1 2
| apt update -y && apt upgrade -y apt install git wget curl screen htop vim -y
|
然后开始装 PGM 和 PGP 的环境,设置 redis 的自启动。
1 2 3 4 5
| 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
systemctl start redis-server systemctl enable redis-server
|
因为换到了 ubuntu22.04,默认自带的 python3 版本是 3.10,所以不再需要编译安装python,下面的一部分是编译 python3 的备份,这个步骤直接跳过即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
|
开始下载 PGM 和 PGP 的源码。
1 2 3 4
| git clone https://gitlab.com/Xtao-Labs/PagerMaid-Modify.git /root/pagermaid
git clone https://github.com/TeamPGM/PagerMaid-Pyro.git /root/pagermaid-pyro
|
先后进入到 git clone 下来的文件夹中安装下 pip 环境。
1 2 3
| python3 -m pip install --upgrade 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
尝试跑起来了。为方便,我这里也给个配置文件的说明吧,自己看注释即可,PGP 和 PGM 的配置文件大同小异。
这里给出配置文件的修改方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| # =================================================================== # __________ _____ .__ .___ # \______ \_____ ____ ___________ / \ _____ |__| __| _/ # | ___/\__ \ / ___\_/ __ \_ __ \/ \ / \\__ \ | |/ __ | # | | / __ \_/ /_/ > ___/| | \/ Y \/ __ \| / /_/ | # |____| (____ /\___ / \___ >__| \____|__ (____ /__\____ | # \//_____/ \/ \/ \/ \/ # ===================================================================
# 下面两条是你的 API 信息,可以去 https://my.telegram.org/apps 拿到 api_id: "ID_HERE" # 必填 api_hash: "HASH_HERE" # 必填 # 是否启用二维码登录 qrcode_login: "False"
# 是否启用 debug 模式和错误上报,保持默认即可。 debug: "False" error_report: "True"
# web 控制面板 web_interface: enable: "False" # 启用填 True,默认不启用 secret_key: "RANDOM_STRING_HERE" # web 控制面板的密码,不要太简单,最好是一串随机字符 host: "127.0.0.1" # 最好填 0.0.0.0 port: "3333" # 端口,没有特殊需求保持默认即可 origins: ["*"]
# 语言、时区设置,默认即可 application_language: "zh-cn" application_region: "China" application_tts: "zh-CN" timezone: "Asia/ShangHai"
# 日志启用及日志群组 log: "False" log_chatid: "503691334"
# Disabled Built-in Commands disabled_cmd: - example1 - example2
# Google search preferences result_length: "5"
# TopCloud image output preferences width: "1920" height: "1080" background: "#101010" margin: "20"
# socks5 or http or MTProto proxy_addr: "" proxy_port: "" http_addr: "" http_port: "" mtp_addr: "" mtp_port: "" mtp_secret: ""
# Apt Git source git_source: "https://raw.githubusercontent.com/TeamPGM/PagerMaid_Plugins_Pyro/v2/" git_ssh: "https://github.com/TeamPGM/PagerMaid-Pyro.git"
# Update Notice update_check: "True" update_time: "86400" update_username: "PagerMaid_Modify_bot" update_delete: "True"
# ipv6 ipv6: "False"
# Analytics allow_analytic: "True"
# Speed_test cli path speed_test_path: ""
# Time format https://www.runoob.com/python/att-time-strftime.html # 24 default time_form: "%H:%M" date_form: "%A %y/%m/%d" # only support %m %d %H %M %S start_form: "%m/%d %H:%M"
# Silent to reduce editing times silent: "True"
|
如果你出现了这样的提示,那就说明没啥特别大的问题,根据提示填写信息后,会提示你在 TG 客户端内输入 help
指令,根据提示输入后,如果能看到消息被编辑,Ctrl+C
结束掉即可。

收尾
写入 systemctl 文件方便管理。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| 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
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
apt-get install tzdata -y timedatectl set-timezone Asia/Shanghai
systemctl start pagermaid.service systemctl start pagermaid-pyro.service
systemctl enable pagermaid.service systemctl enable pagermaid-pyro.service
|