🐛 修复一些BUG

This commit is contained in:
Wuyi无疑 2023-03-11 21:41:16 +08:00
parent 74a20a54db
commit 10cb2701b1
6 changed files with 34 additions and 23 deletions

View File

@ -5,8 +5,8 @@ from typing import Union
from nonebot.log import logger
from PIL import Image, ImageDraw
from .gs_config import gsconfig
from ..utils.database import get_sqla
from .config_default import CONIFG_DEFAULT
from ..utils.image.convert import convert_img
from ..utils.image.image_tools import CustomizeImage
from ..utils.resource.RESOURCE_PATH import TEXT2D_PATH
@ -25,7 +25,7 @@ async def draw_config_img(bot_id: str) -> Union[bytes, str]:
sqla = get_sqla(bot_id)
# 获取背景图片各项参数
based_w = 850
based_h = 850 + 155 * (len(CONIFG_DEFAULT) - 5)
based_h = 850 + 155 * (len(gsconfig) - 5)
CI_img = CustomizeImage('', based_w, based_h)
img = CI_img.bg_img
@ -52,8 +52,8 @@ async def draw_config_img(bot_id: str) -> Union[bytes, str]:
tasks = []
index = 0
for name in CONIFG_DEFAULT:
if isinstance(CONIFG_DEFAULT[name].data, bool):
for name in gsconfig:
if isinstance(gsconfig[name].data, bool):
tasks.append(_draw_config_line(img, name, index))
index += 1
await asyncio.gather(*tasks)
@ -64,15 +64,15 @@ async def draw_config_img(bot_id: str) -> Union[bytes, str]:
async def _draw_config_line(img: Image.Image, name: str, index: int):
detail = CONIFG_DEFAULT[name].desc
detail = gsconfig[name].desc
config_line = Image.open(TEXT_PATH / 'config_line.png')
config_line_draw = ImageDraw.Draw(config_line)
if name.startswith('定时'):
name += '(全部)'
title = CONIFG_DEFAULT[name].title
title = gsconfig[name].title
config_line_draw.text((52, 46), title, first_color, gs_font_36, 'lm')
config_line_draw.text((52, 80), detail, second_color, gs_font_24, 'lm')
if CONIFG_DEFAULT[name].data:
if gsconfig[name].data:
config_line.paste(config_on, (613, 21), config_on)
else:
config_line.paste(config_off, (613, 21), config_off)

View File

@ -20,6 +20,15 @@ class StringConfig:
self.config: Dict[str, GSC] = {}
self.update_config()
def __len__(self):
return len(self.config)
def __iter__(self):
return iter(self.config)
def __getitem__(self, key) -> GSC:
return self.config[key]
def write_config(self):
with open(CONFIG_PATH, 'wb') as file:
file.write(msgjson.format(msgjson.encode(self.config), indent=4))

View File

@ -436,7 +436,7 @@ class MysApi:
server_id = 'cn_qd01' if uid[0] == '5' else 'cn_gf01'
authkey_rawdata = await self.get_authkey_by_cookie(uid)
if isinstance(authkey_rawdata, int):
return -1
return authkey_rawdata
authkey = authkey_rawdata['authkey']
data = await self._mys_request(
url=_API['GET_GACHA_LOG_URL'],
@ -561,7 +561,7 @@ class MysApi:
HEADER['Cookie'] = stoken
HEADER['DS'] = get_web_ds_token(True)
HEADER['User-Agent'] = 'okhttp/4.8.0'
HEADER['x-rpc-app_version'] = '2.35.2'
HEADER['x-rpc-app_version'] = '2.44.1'
HEADER['x-rpc-sys_version'] = '12'
HEADER['x-rpc-client_type'] = '5'
HEADER['x-rpc-channel'] = 'mihoyo'

View File

@ -258,7 +258,9 @@ class SQLA:
return data.stoken if data and data.stoken else None
async def get_all_user(self) -> List[GsUser]:
sql = select(GsUser).where(GsUser.cookie)
sql = select(GsUser).where(
GsUser.cookie is not None and GsUser.cookie != ''
)
result = await self.session.execute(sql)
data: List[GsUser] = result.scalars().all()
return data

22
poetry.lock generated
View File

@ -593,25 +593,25 @@ test = ["pytest (>=6)"]
[[package]]
name = "fastapi"
version = "0.93.0"
version = "0.94.0"
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "fastapi-0.93.0-py3-none-any.whl", hash = "sha256:d6e6db5f096d67b475e2a09e1124983554f634fad50297de85fc3de0583df13a"},
{file = "fastapi-0.93.0.tar.gz", hash = "sha256:c2944febec6da706f4c82cdfa0de48afda960c8fbde29dec88697d55a67d7718"},
{file = "fastapi-0.94.0-py3-none-any.whl", hash = "sha256:898d7f6616dea49e78fa00e34401f9ace238fc670aafe4e30a16a384e3a671e1"},
{file = "fastapi-0.94.0.tar.gz", hash = "sha256:08ce0bc6f381ef1b6431e84a31d26eca0b60d6e1ac575adba4af95cc5a36cb62"},
]
[package.dependencies]
pydantic = ">=1.6.2,<1.7 || >1.7,<1.7.1 || >1.7.1,<1.7.2 || >1.7.2,<1.7.3 || >1.7.3,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0"
starlette = ">=0.25.0,<0.26.0"
starlette = ">=0.26.0,<0.27.0"
[package.extras]
all = ["email-validator (>=1.1.1)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "python-multipart (>=0.0.5)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"]
dev = ["pre-commit (>=2.17.0,<3.0.0)", "ruff (==0.0.138)", "uvicorn[standard] (>=0.12.0,<0.21.0)"]
doc = ["mdx-include (>=1.4.1,<2.0.0)", "mkdocs (>=1.1.2,<2.0.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.3.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "pyyaml (>=5.3.1,<7.0.0)", "typer-cli (>=0.0.13,<0.0.14)", "typer[all] (>=0.6.1,<0.8.0)"]
test = ["anyio[trio] (>=3.2.1,<4.0.0)", "black (==22.10.0)", "coverage[toml] (>=6.5.0,<8.0)", "databases[sqlite] (>=0.3.2,<0.7.0)", "email-validator (>=1.1.1,<2.0.0)", "flask (>=1.1.2,<3.0.0)", "httpx (>=0.23.0,<0.24.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.982)", "orjson (>=3.2.1,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "peewee (>=3.13.3,<4.0.0)", "pytest (>=7.1.3,<8.0.0)", "python-jose[cryptography] (>=3.3.0,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "pyyaml (>=5.3.1,<7.0.0)", "ruff (==0.0.138)", "sqlalchemy (>=1.3.18,<1.4.43)", "types-orjson (==3.6.2)", "types-ujson (==5.6.0.0)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)"]
test = ["anyio[trio] (>=3.2.1,<4.0.0)", "black (==23.1.0)", "coverage[toml] (>=6.5.0,<8.0)", "databases[sqlite] (>=0.3.2,<0.7.0)", "email-validator (>=1.1.1,<2.0.0)", "flask (>=1.1.2,<3.0.0)", "httpx (>=0.23.0,<0.24.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.982)", "orjson (>=3.2.1,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "peewee (>=3.13.3,<4.0.0)", "pytest (>=7.1.3,<8.0.0)", "python-jose[cryptography] (>=3.3.0,<4.0.0)", "python-multipart (>=0.0.5,<0.0.7)", "pyyaml (>=5.3.1,<7.0.0)", "ruff (==0.0.138)", "sqlalchemy (>=1.3.18,<1.4.43)", "types-orjson (==3.6.2)", "types-ujson (==5.7.0.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)"]
[[package]]
name = "fastapi-amis-admin"
@ -2142,14 +2142,14 @@ test = ["pytest (>=7.1.3)"]
[[package]]
name = "starlette"
version = "0.25.0"
version = "0.26.0.post1"
description = "The little ASGI library that shines."
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "starlette-0.25.0-py3-none-any.whl", hash = "sha256:774f1df1983fd594b9b6fb3ded39c2aa1979d10ac45caac0f4255cbe2acb8628"},
{file = "starlette-0.25.0.tar.gz", hash = "sha256:854c71e73736c429c2bdb07801f2c76c9cba497e7c3cf4988fde5e95fe4cdb3c"},
{file = "starlette-0.26.0.post1-py3-none-any.whl", hash = "sha256:5b80b546ed60d43da45f80113c05ff9f4c44fae95ee884945958eba685c56253"},
{file = "starlette-0.26.0.post1.tar.gz", hash = "sha256:af0e54d08afed70fcbc53ae01e71c9c62c8ab038ff8cfd3f7477bf0f086b5ab4"},
]
[package.dependencies]
@ -2267,14 +2267,14 @@ test = ["pytest (>=4.3)", "pytest-mock (>=3.3)"]
[[package]]
name = "urllib3"
version = "1.26.14"
version = "1.26.15"
description = "HTTP library with thread-safe connection pooling, file post, and more."
category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
files = [
{file = "urllib3-1.26.14-py2.py3-none-any.whl", hash = "sha256:75edcdc2f7d85b137124a6c3c9fc3933cdeaa12ecb9a6a959f22797a0feca7e1"},
{file = "urllib3-1.26.14.tar.gz", hash = "sha256:076907bf8fd355cde77728471316625a4d2f7e713c125f51953bb5b3eecf4f72"},
{file = "urllib3-1.26.15-py2.py3-none-any.whl", hash = "sha256:aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42"},
{file = "urllib3-1.26.15.tar.gz", hash = "sha256:8a388717b9476f934a21484e8c8e61875ab60644d29b9b39e11e4b9dc1c6b305"},
]
[package.extras]

View File

@ -17,7 +17,7 @@ email-validator==1.3.1 ; python_full_version >= "3.8.1" and python_full_version
et-xmlfile==1.1.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-amis-admin==0.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-user-auth==0.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi==0.93.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi==0.94.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
frozenlist==1.3.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
gitdb==4.0.10 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
gitpython==3.1.31 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
@ -55,7 +55,7 @@ sqlalchemy2-stubs==0.0.2a32 ; python_full_version >= "3.8.1" and python_full_ver
sqlalchemy==1.4.41 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
sqlmodel==0.0.8 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
sqlmodelx==0.0.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
starlette==0.25.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
starlette==0.26.0.post1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
tomlkit==0.11.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
typing-extensions==4.5.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
tzdata==2022.7 ; python_full_version >= "3.8.1" and python_version < "4.0"