mirror of
https://github.com/TeamPGM/PagerMaid-Pyro.git
synced 2024-11-21 18:58:21 +00:00
🔖 Update to v1.4.3
Change all data to data folder
This commit is contained in:
parent
08542df723
commit
5b49941eed
@ -8,7 +8,7 @@ services:
|
|||||||
# ports: # 是否开启网页控制面板
|
# ports: # 是否开启网页控制面板
|
||||||
# - "3333:3333"
|
# - "3333:3333"
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/pagermaid/workdir
|
- ./data:/pagermaid/workdir/data
|
||||||
environment:
|
environment:
|
||||||
# - WEB_ENABLE=true
|
# - WEB_ENABLE=true
|
||||||
# - WEB_SECRET_KEY=控制台密码
|
# - WEB_SECRET_KEY=控制台密码
|
||||||
|
@ -16,13 +16,14 @@ from logging import (
|
|||||||
)
|
)
|
||||||
from os import getcwd
|
from os import getcwd
|
||||||
|
|
||||||
|
import pagermaid.update
|
||||||
from pagermaid.config import Config
|
from pagermaid.config import Config
|
||||||
from pagermaid.scheduler import scheduler
|
from pagermaid.scheduler import scheduler
|
||||||
import pyromod.listen
|
import pyromod.listen
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
|
|
||||||
pgm_version = "1.4.2"
|
pgm_version = "1.4.3"
|
||||||
pgm_version_code = 1402
|
pgm_version_code = 1403
|
||||||
CMD_LIST = {}
|
CMD_LIST = {}
|
||||||
module_dir = __path__[0]
|
module_dir = __path__[0]
|
||||||
working_dir = getcwd()
|
working_dir = getcwd()
|
||||||
@ -47,9 +48,9 @@ root_logger = getLogger()
|
|||||||
root_logger.setLevel(DEBUG if Config.DEBUG else CRITICAL)
|
root_logger.setLevel(DEBUG if Config.DEBUG else CRITICAL)
|
||||||
root_logger.addHandler(logging_handler)
|
root_logger.addHandler(logging_handler)
|
||||||
pyro_logger = getLogger("pyrogram")
|
pyro_logger = getLogger("pyrogram")
|
||||||
pyro_logger.setLevel(CRITICAL)
|
pyro_logger.setLevel(INFO if Config.DEBUG else CRITICAL)
|
||||||
pyro_logger.addHandler(logging_handler)
|
pyro_logger.addHandler(logging_handler)
|
||||||
file_handler = FileHandler(filename="pagermaid.log.txt", mode="w", encoding="utf-8")
|
file_handler = FileHandler(filename="data/pagermaid.log.txt", mode="w", encoding="utf-8")
|
||||||
file_handler.setFormatter(Formatter(logging_format))
|
file_handler.setFormatter(Formatter(logging_format))
|
||||||
root_logger.addHandler(file_handler)
|
root_logger.addHandler(file_handler)
|
||||||
basicConfig(level=DEBUG if Config.DEBUG else INFO)
|
basicConfig(level=DEBUG if Config.DEBUG else INFO)
|
||||||
@ -77,6 +78,7 @@ bot = Client(
|
|||||||
ipv6=Config.IPV6,
|
ipv6=Config.IPV6,
|
||||||
proxy=Config.PROXY,
|
proxy=Config.PROXY,
|
||||||
app_version=f"PGP {pgm_version}",
|
app_version=f"PGP {pgm_version}",
|
||||||
|
workdir="data",
|
||||||
)
|
)
|
||||||
bot.job = scheduler
|
bot.job = scheduler
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ def strtobool(val, default=False):
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
config: Dict = load(open(r"config.yml", encoding="utf-8"), Loader=FullLoader)
|
config: Dict = load(open(r"data/config.yml", encoding="utf-8"), Loader=FullLoader)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(
|
print(
|
||||||
"The configuration file does not exist, and a new configuration file is being generated."
|
"The configuration file does not exist, and a new configuration file is being generated."
|
||||||
)
|
)
|
||||||
copyfile(f"{os.getcwd()}{os.sep}config.gen.yml", "config.yml")
|
copyfile(f"{os.getcwd()}{os.sep}config.gen.yml", "data/config.yml")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ async def backup(message: Message):
|
|||||||
os.remove(f"data{os.sep}{i}")
|
os.remove(f"data{os.sep}{i}")
|
||||||
|
|
||||||
# run backup function
|
# run backup function
|
||||||
make_tar_gz(pgm_backup_zip_name, ["data", "plugins", "config.yml"])
|
make_tar_gz(pgm_backup_zip_name, ["data", "plugins"])
|
||||||
if Config.LOG:
|
if Config.LOG:
|
||||||
try:
|
try:
|
||||||
await upload_attachment(pgm_backup_zip_name, Config.LOG_ID, None)
|
await upload_attachment(pgm_backup_zip_name, Config.LOG_ID, None)
|
||||||
|
5
pagermaid/update/__init__.py
Normal file
5
pagermaid/update/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import pkgutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
for _, file, _ in pkgutil.iter_modules([str(Path(__file__).parent.absolute())]):
|
||||||
|
__import__(file, globals(), level=1)
|
16
pagermaid/update/v1402.py
Normal file
16
pagermaid/update/v1402.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# move file
|
||||||
|
# session
|
||||||
|
session = Path("pagermaid.session")
|
||||||
|
if session.exists():
|
||||||
|
session.rename("data/pagermaid.session")
|
||||||
|
# config
|
||||||
|
config = Path("config.yml")
|
||||||
|
if config.exists():
|
||||||
|
config.rename("data/config.yml")
|
||||||
|
# delete file
|
||||||
|
# log
|
||||||
|
log = Path("pagermaid.log.txt")
|
||||||
|
if log.exists():
|
||||||
|
log.unlink()
|
@ -103,7 +103,7 @@ async def authorize_by_qrcode(
|
|||||||
if isinstance(qrcode, str):
|
if isinstance(qrcode, str):
|
||||||
qr_obj = QRCode(qrcode)
|
qr_obj = QRCode(qrcode)
|
||||||
try:
|
try:
|
||||||
qr_obj.png("qrcode.png", scale=6)
|
qr_obj.png("data/qrcode.png", scale=6)
|
||||||
except Exception:
|
except Exception:
|
||||||
print("Save qrcode.png failed.")
|
print("Save qrcode.png failed.")
|
||||||
print(qr_obj.terminal())
|
print(qr_obj.terminal())
|
||||||
|
@ -49,7 +49,7 @@ login () {
|
|||||||
echo "请在账户授权完毕后,按 Ctrl + C 使 Docker 在后台模式下运行。"
|
echo "请在账户授权完毕后,按 Ctrl + C 使 Docker 在后台模式下运行。"
|
||||||
echo "如果已开启网页登录,请直接使用 Ctrl + C 使 Docker 在后台模式下运行。"
|
echo "如果已开启网页登录,请直接使用 Ctrl + C 使 Docker 在后台模式下运行。"
|
||||||
echo
|
echo
|
||||||
echo "Hello world!" > /pagermaid/workdir/install.lock
|
echo "Hello world!" > /pagermaid/workdir/data/install.lock
|
||||||
sleep 2
|
sleep 2
|
||||||
python -m pagermaid
|
python -m pagermaid
|
||||||
exit 0
|
exit 0
|
||||||
@ -57,12 +57,12 @@ login () {
|
|||||||
|
|
||||||
main () {
|
main () {
|
||||||
cd /pagermaid/workdir || exit
|
cd /pagermaid/workdir || exit
|
||||||
if [ ! -s "/pagermaid/workdir/install.lock" ]; then
|
if [ ! -s "/pagermaid/workdir/data/install.lock" ]; then
|
||||||
welcome
|
welcome
|
||||||
configure
|
configure
|
||||||
login
|
login
|
||||||
else
|
else
|
||||||
if [ ! -f "/pagermaid/workdir/pagermaid.session" ]; then
|
if [ ! -f "/pagermaid/workdir/data/pagermaid.session" ]; then
|
||||||
welcome
|
welcome
|
||||||
configure
|
configure
|
||||||
fi
|
fi
|
||||||
|
@ -78,7 +78,7 @@ need_web_login () {
|
|||||||
PGM_WEB_LOGIN=false
|
PGM_WEB_LOGIN=false
|
||||||
case $PGM_WEB in
|
case $PGM_WEB in
|
||||||
true)
|
true)
|
||||||
printf "请问是否需要启用 Web 登录界面 [Y/n] :"
|
printf "请问是否需要启用通过 Web 登录?(不建议开启) [Y/n] :"
|
||||||
read -r web_login <&1
|
read -r web_login <&1
|
||||||
case $web_login in
|
case $web_login in
|
||||||
[yY][eE][sS] | [yY])
|
[yY][eE][sS] | [yY])
|
||||||
|
Loading…
Reference in New Issue
Block a user