Skip to content

Commit

Permalink
🔖 Update to v1.4.3
Browse files Browse the repository at this point in the history
Change all data to data folder
  • Loading branch information
omg-xtao committed Dec 12, 2023
1 parent 08542df commit 5b49941
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docker-compose.gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
# ports: # 是否开启网页控制面板
# - "3333:3333"
volumes:
- ./:/pagermaid/workdir
- ./data:/pagermaid/workdir/data
environment:
# - WEB_ENABLE=true
# - WEB_SECRET_KEY=控制台密码
Expand Down
10 changes: 6 additions & 4 deletions pagermaid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
)
from os import getcwd

import pagermaid.update
from pagermaid.config import Config
from pagermaid.scheduler import scheduler
import pyromod.listen
from pyrogram import Client

pgm_version = "1.4.2"
pgm_version_code = 1402
pgm_version = "1.4.3"
pgm_version_code = 1403
CMD_LIST = {}
module_dir = __path__[0]
working_dir = getcwd()
Expand All @@ -47,9 +48,9 @@
root_logger.setLevel(DEBUG if Config.DEBUG else CRITICAL)
root_logger.addHandler(logging_handler)
pyro_logger = getLogger("pyrogram")
pyro_logger.setLevel(CRITICAL)
pyro_logger.setLevel(INFO if Config.DEBUG else CRITICAL)
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))
root_logger.addHandler(file_handler)
basicConfig(level=DEBUG if Config.DEBUG else INFO)
Expand Down Expand Up @@ -77,6 +78,7 @@
ipv6=Config.IPV6,
proxy=Config.PROXY,
app_version=f"PGP {pgm_version}",
workdir="data",
)
bot.job = scheduler

Expand Down
4 changes: 2 additions & 2 deletions pagermaid/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def strtobool(val, default=False):


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:
print(
"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)


Expand Down
2 changes: 1 addition & 1 deletion pagermaid/modules/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def backup(message: Message):
os.remove(f"data{os.sep}{i}")

# 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:
try:
await upload_attachment(pgm_backup_zip_name, Config.LOG_ID, None)
Expand Down
5 changes: 5 additions & 0 deletions pagermaid/update/__init__.py
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions pagermaid/update/v1402.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion pyromod/methods/sign_in_qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def authorize_by_qrcode(
if isinstance(qrcode, str):
qr_obj = QRCode(qrcode)
try:
qr_obj.png("qrcode.png", scale=6)
qr_obj.png("data/qrcode.png", scale=6)
except Exception:
print("Save qrcode.png failed.")
print(qr_obj.terminal())
Expand Down
6 changes: 3 additions & 3 deletions utils/docker-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ login () {
echo "请在账户授权完毕后,按 Ctrl + C 使 Docker 在后台模式下运行。"
echo "如果已开启网页登录,请直接使用 Ctrl + C 使 Docker 在后台模式下运行。"
echo
echo "Hello world!" > /pagermaid/workdir/install.lock
echo "Hello world!" > /pagermaid/workdir/data/install.lock
sleep 2
python -m pagermaid
exit 0
}

main () {
cd /pagermaid/workdir || exit
if [ ! -s "/pagermaid/workdir/install.lock" ]; then
if [ ! -s "/pagermaid/workdir/data/install.lock" ]; then
welcome
configure
login
else
if [ ! -f "/pagermaid/workdir/pagermaid.session" ]; then
if [ ! -f "/pagermaid/workdir/data/pagermaid.session" ]; then
welcome
configure
fi
Expand Down
2 changes: 1 addition & 1 deletion utils/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ need_web_login () {
PGM_WEB_LOGIN=false
case $PGM_WEB in
true)
printf "请问是否需要启用 Web 登录界面 [Y/n] :"
printf "请问是否需要启用通过 Web 登录?(不建议开启) [Y/n] :"
read -r web_login <&1
case $web_login in
[yY][eE][sS] | [yY])
Expand Down

0 comments on commit 5b49941

Please sign in to comment.