可配置gs重启运行的控制台命令

This commit is contained in:
Wuyi无疑 2023-04-13 00:09:29 +08:00
parent 7808c2b06e
commit 89b016b729
7 changed files with 28 additions and 14 deletions

View File

@ -23,14 +23,14 @@ red_color = (255, 66, 66)
green_color = (74, 189, 119)
max_data = {
'成就': 892,
'成就': 939,
'华丽的宝箱': 185,
'珍贵的宝箱': 487,
'精致的宝箱': 1589,
'普通的宝箱': 2527,
'珍贵的宝箱': 503,
'精致的宝箱': 1629,
'普通的宝箱': 2632,
'奇馈宝箱': 146,
'解锁传送点': 286,
'解锁秘境': 48,
'解锁传送点': 303,
'解锁秘境': 51,
}
award_data = {

View File

@ -17,6 +17,11 @@ CONIFG_DEFAULT: Dict[str, GSC] = {
'用于面板查询的随机图API',
'https://genshin-res.cherishmoon.fun/img?name=',
),
'restart_command': GsStrConfig(
'重启命令',
'自定义使用gs重启时触发的控制台命令(看不懂勿改)',
'poetry run python',
),
'Ann_Groups': GsDictConfig(
'推送公告群组',
'原神公告推送群组',

View File

@ -13,7 +13,7 @@ from .models import (
GsListStrConfig,
)
STR_CONFIG = Literal['proxy', '_pass_API', 'random_pic_API']
STR_CONFIG = Literal['proxy', '_pass_API', 'random_pic_API', 'restart_command']
LIST_INT_CONFIG = Literal['Ann_Ids']
LIST_STR_CONFIG = Literal['SignTime', 'BBSTaskTime']
DICT_CONFIG = Literal['Ann_Groups']

View File

@ -21,7 +21,10 @@ async def import_gachalogs(history_url: str, type: str, uid: str) -> str:
history_data: dict = json.loads(get(history_url).text)
else:
data_bytes = base64.b64decode(history_url)
history_data = json.loads(data_bytes.decode('gbk'))
try:
history_data = json.loads(data_bytes.decode())
except UnicodeDecodeError:
history_data = json.loads(data_bytes.decode('gbk'))
if 'info' in history_data and 'uid' in history_data['info']:
data_uid = history_data['info']['uid']
if data_uid != uid:

View File

@ -5,6 +5,8 @@ import platform
import subprocess
from pathlib import Path
from ..genshinuid_config.gs_config import gsconfig
bot_start = Path(__file__).parents[4] / 'core.py'
restart_sh_path = Path().cwd() / 'gs_restart.sh'
update_log_path = Path(__file__).parent / 'update_log.json'
@ -13,9 +15,11 @@ _restart_sh = '''#!/bin/bash
kill -9 {}
{} &'''
restart_command = gsconfig.get_config('restart_command').data
async def get_restart_sh() -> str:
args = f'poetry run python {str(bot_start.absolute())}'
args = f'{restart_command} {str(bot_start.absolute())}'
return _restart_sh.format(str(bot_start.absolute()), args)
@ -42,12 +46,12 @@ async def restart_genshinuid(
json.dump(update_log, f)
if platform.system() == 'Linux':
subprocess.Popen(
f'kill -9 {pid} & poetry run python {bot_start}',
f'kill -9 {pid} & {restart_command} {bot_start}',
shell=True,
)
else:
subprocess.Popen(
f'taskkill /F /PID {pid} & poetry run python {bot_start}',
f'taskkill /F /PID {pid} & {restart_command} {bot_start}',
shell=True,
)

View File

@ -619,7 +619,8 @@
"茄子",
"紫茄子",
"阿忍",
"忍姐"
"忍姐",
"九岐忍"
],
"神里绫人": [
"Kamisato Ayato",
@ -669,7 +670,8 @@
"Nilou",
"nilou",
"尼露",
"尼禄"
"尼禄",
"红牛"
],
"赛诺": [
"Cyno",

View File

@ -1,2 +1,2 @@
GenshinUID_version = '3.1.0'
GenshinUID_version = '4.0.2'
Genshin_version = '3.6.0'