mirror of
https://github.com/TeamPGM/PagerMaid-Pyro.git
synced 2024-11-21 10:48:22 +00:00
🔖 Update to v1.0.1
This commit is contained in:
parent
5d8f863585
commit
bf0fc9f5ec
8
.deepsource.toml
Normal file
8
.deepsource.toml
Normal file
@ -0,0 +1,8 @@
|
||||
version = 1
|
||||
|
||||
[[analyzers]]
|
||||
name = "python"
|
||||
enabled = true
|
||||
|
||||
[analyzers.meta]
|
||||
runtime_version = "3.x.x"
|
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
custom: ['https://afdian.net/@xtaodada']
|
24
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
24
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
## Description
|
||||
|
||||
Please carefully read the [Contributing note](https://github.com/TeamPGM/PagerMaid-Pyro/blob/stable/CONTRIBUTING.md) and [Code of conduct](https://github.com/TeamPGM/PagerMaid-Pyro/blob/development/CODE_OF_CONDUCT.md) before making any pull requests.
|
||||
And, **Do not make a pull request to merge into master unless it is a hotfix. Use the development branch instead.**
|
||||
|
||||
## Issues fixed by this PR
|
||||
|
||||
<!--- Put the links of issues that may be fixed by this PR here (if any). -->
|
||||
|
||||
## Type of changes
|
||||
|
||||
<!--- Put an `x` in all the boxes that apply your changes. -->
|
||||
|
||||
- [ ] Bug fix
|
||||
- [ ] New feature
|
||||
- [ ] Enhancement
|
||||
- [ ] Documentation
|
||||
|
||||
## Checklist:
|
||||
|
||||
- [ ] My code follows the style guidelines of this project
|
||||
- [ ] My pull request is unique and no other pull requests have been opened for these changes
|
||||
- [ ] I have read the [Contributing note](https://github.com/TeamPGM/PagerMaid-Pyro/blob/stable/CONTRIBUTING.md) and [Code of conduct](https://github.com/TeamPGM/PagerMaid-Pyro/blob/development/CODE_OF_CONDUCT.md)
|
||||
- [ ] I am responsible for any copyright issues with my code if it occurs in the future.
|
74
.github/workflows/docker.yml
vendored
Normal file
74
.github/workflows/docker.yml
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
name: "Docker Build"
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the master branch
|
||||
workflow_dispatch: ~
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: docker build and publish
|
||||
env:
|
||||
DOCKER_BUILDKIT: 1
|
||||
DOCKER_CLI_EXPERIMENTAL: enabled
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKERHUB_REPOSITORY: ${{ secrets.DOCKER_REPO }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: crazy-max/ghaction-docker-buildx@v3
|
||||
|
||||
- name: Buildx cache
|
||||
uses: actions/cache@v2
|
||||
id: buildx-cache
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
declare -a IMAGES
|
||||
|
||||
echo "Build amd64"
|
||||
docker buildx build \
|
||||
--cache-from "type=local,src=/tmp/.buildx-cache" \
|
||||
--cache-to "type=local,dest=/tmp/.buildx-cache" \
|
||||
--output "type=image,push=true" \
|
||||
--platform linux/amd64 \
|
||||
--build-arg "S6_ARCH=amd64" \
|
||||
--tag "${DOCKERHUB_REPOSITORY}:latest-amd64" \
|
||||
-f Dockerfile \
|
||||
.
|
||||
IMAGES+=( "${DOCKERHUB_REPOSITORY}:latest-amd64" )
|
||||
|
||||
echo "Build arm64-v8"
|
||||
docker buildx build \
|
||||
--cache-from "type=local,src=/tmp/.buildx-cache" \
|
||||
--cache-to "type=local,dest=/tmp/.buildx-cache" \
|
||||
--output "type=image,push=true" \
|
||||
--platform linux/arm64/v8 \
|
||||
--build-arg "S6_ARCH=aarch64" \
|
||||
--tag "${DOCKERHUB_REPOSITORY}:latest-arm64-v8" \
|
||||
-f Dockerfile \
|
||||
.
|
||||
IMAGES+=( "${DOCKERHUB_REPOSITORY}:latest-arm64-v8" )
|
||||
|
||||
echo "Create manifest lists"
|
||||
docker manifest create "${DOCKERHUB_REPOSITORY}:latest" "${IMAGES[@]}"
|
||||
|
||||
echo "Annotate manifest lists to add architecture variants that aren't picked up automatically"
|
||||
docker manifest annotate "${DOCKERHUB_REPOSITORY}:latest" "${DOCKERHUB_REPOSITORY}:latest-arm64-v8" --variant "v8"
|
||||
|
||||
echo "Push manifest lists & delete local copies"
|
||||
docker manifest push --purge "${DOCKERHUB_REPOSITORY}:latest"
|
123
Dockerfile
Normal file
123
Dockerfile
Normal file
@ -0,0 +1,123 @@
|
||||
FROM ubuntu:latest
|
||||
ARG S6_VERSION=v2.2.0.3
|
||||
ARG S6_ARCH=amd64
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ARG USER_NAME=pagermaid
|
||||
ARG WORK_DIR=/pagermaid/workdir
|
||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
||||
SHELL=/bin/bash \
|
||||
LANG=zh_CN.UTF-8 \
|
||||
PS1="\u@\h:\w \$ " \
|
||||
RUN_AS_ROOT=true
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
WORKDIR $WORK_DIR
|
||||
RUN source ~/.bashrc \
|
||||
## 安装运行环境依赖,自编译建议修改为国内镜像源
|
||||
# && sed -i 's/archive.ubuntu.com/mirrors.bfsu.edu.cn/g' /etc/apt/sources.list \
|
||||
# && sed -i 's/security.ubuntu.com/mirrors.bfsu.edu.cn/g' /etc/apt/sources.list \
|
||||
# && sed -i 's/ports.ubuntu.com/mirrors.bfsu.edu.cn/g' /etc/apt/sources.list \
|
||||
&& apt-get update \
|
||||
&& apt-get upgrade -y \
|
||||
&& apt-get install --no-install-recommends -y \
|
||||
python3 \
|
||||
python3-pip \
|
||||
tesseract-ocr \
|
||||
tesseract-ocr-eng \
|
||||
tesseract-ocr-chi-sim \
|
||||
language-pack-zh-hans \
|
||||
sudo \
|
||||
git \
|
||||
openssl \
|
||||
curl \
|
||||
wget \
|
||||
neofetch \
|
||||
imagemagick \
|
||||
ffmpeg \
|
||||
fortune-mod \
|
||||
figlet \
|
||||
libmagic1 \
|
||||
libzbar0 \
|
||||
iputils-ping \
|
||||
## 安装s6
|
||||
&& curl -L -o /tmp/s6-overlay-installer https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-${S6_ARCH}-installer \
|
||||
&& chmod +x /tmp/s6-overlay-installer \
|
||||
&& /tmp/s6-overlay-installer / \
|
||||
## 安装编译依赖
|
||||
&& apt-get update \
|
||||
&& apt-get install --no-install-recommends -y \
|
||||
## 这是跨平台交叉编译要用到的包,如果自行构建,有可能不需要
|
||||
build-essential \
|
||||
apt-utils \
|
||||
python3-dev \
|
||||
libxslt1-dev \
|
||||
libxml2-dev \
|
||||
libssl-dev \
|
||||
libffi-dev \
|
||||
zlib1g-dev \
|
||||
tcl8.6-dev \
|
||||
tk8.6-dev \
|
||||
libimagequant-dev \
|
||||
libraqm-dev \
|
||||
libjpeg-dev \
|
||||
libtiff5-dev \
|
||||
libopenjp2-7-dev \
|
||||
libfreetype6-dev \
|
||||
liblcms2-dev \
|
||||
libwebp-dev \
|
||||
python3-tk \
|
||||
libharfbuzz-dev \
|
||||
libfribidi-dev \
|
||||
libxcb1-dev \
|
||||
pkg-config \
|
||||
## 设置时区
|
||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone \
|
||||
## python软链接
|
||||
&& ln -sf /usr/bin/python3 /usr/bin/python \
|
||||
## 升级pip
|
||||
# && pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
|
||||
&& python -m pip install --upgrade pip \
|
||||
## 添加用户
|
||||
&& useradd $USER_NAME -u 917 -U -r -m -d /$USER_NAME -s /bin/bash \
|
||||
&& usermod -aG sudo,users $USER_NAME \
|
||||
&& echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USER_NAME \
|
||||
## 克隆仓库
|
||||
&& git clone -b master https://github.com/TeamPGM/PagerMaid-Pyro.git $WORK_DIR \
|
||||
&& git config --global pull.ff only \
|
||||
## 复制s6启动脚本
|
||||
&& cp -r s6/* / \
|
||||
## pip install
|
||||
&& pip install -r requirements.txt \
|
||||
## 卸载编译依赖,清理安装缓存
|
||||
&& sudo apt-get purge --auto-remove -y \
|
||||
build-essential \
|
||||
apt-utils \
|
||||
python3-dev \
|
||||
libxslt1-dev \
|
||||
libxml2-dev \
|
||||
libssl-dev \
|
||||
libffi-dev \
|
||||
zlib1g-dev \
|
||||
tcl8.6-dev \
|
||||
tk8.6-dev \
|
||||
libimagequant-dev \
|
||||
libraqm-dev \
|
||||
libjpeg-dev \
|
||||
libtiff5-dev \
|
||||
libopenjp2-7-dev \
|
||||
libfreetype6-dev \
|
||||
liblcms2-dev \
|
||||
libwebp-dev \
|
||||
python3-tk \
|
||||
libharfbuzz-dev \
|
||||
libfribidi-dev \
|
||||
libxcb1-dev \
|
||||
pkg-config \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf \
|
||||
## 删除apt和pip的安装缓存
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/* \
|
||||
~/.cache
|
||||
ENTRYPOINT ["/init"]
|
@ -8,7 +8,7 @@ from pagermaid.config import Config
|
||||
import pyromod.listen
|
||||
from pyrogram import Client
|
||||
|
||||
pgm_version = "1.0.0"
|
||||
pgm_version = "1.0.1"
|
||||
CMD_LIST = {}
|
||||
module_dir = __path__[0]
|
||||
working_dir = getcwd()
|
||||
|
34
pagermaid/sub_utils.py
Normal file
34
pagermaid/sub_utils.py
Normal file
@ -0,0 +1,34 @@
|
||||
from typing import List
|
||||
from pagermaid.single_utils import sqlite
|
||||
|
||||
|
||||
class Sub:
|
||||
def __init__(self, name: str):
|
||||
self.name = name
|
||||
|
||||
def get_subs(self) -> List:
|
||||
return sqlite.get(f"{self.name}.sub", [])
|
||||
|
||||
def clear_subs(self) -> None:
|
||||
sqlite[f"{self.name}.sub"] = []
|
||||
del sqlite[f"{self.name}.sub"]
|
||||
|
||||
def add_id(self, uid: int) -> bool:
|
||||
data = self.get_subs()
|
||||
if uid in data:
|
||||
return False
|
||||
data.append(uid)
|
||||
sqlite[f"{self.name}.sub"] = data
|
||||
return True
|
||||
|
||||
def del_id(self, uid: int) -> bool:
|
||||
data = self.get_subs()
|
||||
if uid not in data:
|
||||
return False
|
||||
data.remove(uid)
|
||||
sqlite[f"{self.name}.sub"] = data
|
||||
return True
|
||||
|
||||
def check_id(self, uid: int) -> bool:
|
||||
data = self.get_subs()
|
||||
return uid in data
|
8
s6/etc/cont-init.d/10-adduser
Normal file
8
s6/etc/cont-init.d/10-adduser
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
if [[ $RUN_AS_ROOT != true ]]; then
|
||||
PUID=${PUID:-917}
|
||||
PGID=${PGID:-917}
|
||||
groupmod -o -g "$PGID" pagermaid
|
||||
usermod -o -u "$PUID" pagermaid
|
||||
fi
|
11
s6/etc/cont-init.d/20-update
Normal file
11
s6/etc/cont-init.d/20-update
Normal file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
cd /pagermaid/workdir
|
||||
git remote set-url origin https://github.com/TeamPGM/PagerMaid-Pyro.git
|
||||
git pull
|
||||
|
||||
pip install -r requirements.txt
|
||||
if [ -s requirements2.txt ]; then
|
||||
pip install -r requirements2.txt
|
||||
fi
|
||||
exit 0
|
5
s6/etc/cont-init.d/30-config
Normal file
5
s6/etc/cont-init.d/30-config
Normal file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
if [[ $RUN_AS_ROOT != true ]]; then
|
||||
chown -R pagermaid:pagermaid /pagermaid
|
||||
fi
|
9
s6/etc/services.d/pagermaid/run
Normal file
9
s6/etc/services.d/pagermaid/run
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
cd /pagermaid/workdir
|
||||
if [[ $RUN_AS_ROOT != true ]]; then
|
||||
exec s6-setuidgid pagermaid python -m pagermaid
|
||||
else
|
||||
exec s6-setuidgid root python -m pagermaid
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user