使用单引号

This commit is contained in:
qwerdvd 2023-08-11 10:05:16 +08:00
parent c93773334e
commit db3b1755df
6 changed files with 25 additions and 23 deletions

View File

@ -29,13 +29,13 @@ ark_skd_cred_add = SV('森空岛cred绑定')
(f'{PREFIX}绑定uid', f'{PREFIX}切换uid', f'{PREFIX}删除uid', f'{PREFIX}解绑uid')
)
async def send_link_uid_msg(bot: Bot, ev: Event):
await bot.logger.info("开始执行[绑定/解绑用户信息]")
await bot.logger.info('开始执行[绑定/解绑用户信息]')
qid = ev.user_id
await bot.logger.info(f"[绑定/解绑]UserID: {qid}")
await bot.logger.info(f'[绑定/解绑]UserID: {qid}')
ark_uid = ev.text.strip()
if ark_uid and not ark_uid.isdigit():
return await bot.send("你输入了错误的格式!")
return await bot.send('你输入了错误的格式!')
if '绑定' in ev.command:
data = await ArknightsBind.insert_uid(qid, ev.bot_id, ark_uid, ev.group_id)
@ -67,7 +67,7 @@ async def send_link_uid_msg(bot: Bot, ev: Event):
)
@ark_skd_cred_add.on_prefix(("skd添加cred", "森空岛添加CRED"))
@ark_skd_cred_add.on_prefix(('skd添加cred', '森空岛添加CRED'))
async def send_ark_skd_add_cred_msg(bot: Bot, ev: Event):
im = await deal_skd_cred(ev.bot_id, ev.text, ev.user_id)
await bot.send(im)

View File

@ -1 +1,3 @@
ARK_USER_ME = 'https://zonai.skland.com/api/v1/user/me'
ARK_GEN_CRED_BY_CODE = 'https://zonai.skland.com/api/v1/user/auth/generate_cred_by_code'

View File

@ -13,12 +13,12 @@ from .api import ARK_USER_ME
class BaseArkApi:
ssl_verify = True
_HEADER = {
"Host": "zonai.skland.com",
"Origin": "https://www.skland.com",
"Referer": "https://www.skland.com/",
"content-type": "application/json; charset=UTF-8",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
'Host': 'zonai.skland.com',
'Origin': 'https://www.skland.com',
'Referer': 'https://www.skland.com/',
'content-type': 'application/json; charset=UTF-8',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',
}
async def check_cred_valid(self, Cred: str) -> bool | ArknightsUserMeModel:
@ -33,33 +33,33 @@ class BaseArkApi:
def unpack(self, raw_data: dict | int) -> dict | int:
if isinstance(raw_data, dict):
return raw_data["data"]
return raw_data['data']
else:
return raw_data
async def _ark_request(
self,
url: str,
method: Literal["GET", "POST"] = "GET",
method: Literal['GET', 'POST'] = 'GET',
header: dict[str, Any] = _HEADER,
params: dict[str, Any] | None = None,
data: dict[str, Any] | None = None,
) -> dict | int:
if "Cred" not in header:
if 'Cred' not in header:
target_user_id = (
data["friendUserId"]
if data and "friendUserId" in data
data['friendUserId']
if data and 'friendUserId' in data
else None
)
Cred: str | None = await ArknightsUser.get_random_cookie(
target_user_id if target_user_id else "18888888"
target_user_id if target_user_id else '18888888'
)
if Cred is None:
return -61
arkUser = await ArknightsUser.base_select_data(ArknightsUser, Cred=Cred)
if arkUser is None:
return -61
header["Cred"] = Cred
header['Cred'] = Cred
async with ClientSession(
connector=TCPConnector(verify_ssl=self.ssl_verify)
@ -76,7 +76,7 @@ class BaseArkApi:
raw_data = await resp.json()
except ContentTypeError:
_raw_data = await resp.text()
raw_data = {"code": -999, "data": _raw_data}
raw_data = {'code': -999, 'data': _raw_data}
if (
raw_data
and 'code' in raw_data

View File

@ -16,7 +16,7 @@ async def download_file(
async with sess.get(url) as res:
content = await res.read()
except ClientConnectorError:
logger.warning(f"[wzry]{name}下载失败")
logger.warning(f'[Arknights]{name}下载失败')
return url, path, name
async with aiofiles.open(path / name, "wb") as f:
async with aiofiles.open(path / name, 'wb') as f:
await f.write(content)

View File

@ -51,9 +51,9 @@ async def download_file(
async with sess.get(url) as res:
content = await res.read()
except ClientConnectorError:
logger.warning(f"[cos]{name}下载失败")
logger.warning(f'[cos]{name}下载失败')
return url, resource_type, name
async with aiofiles.open(
PATHDICT[res_type] / resource_type / name, "wb"
PATHDICT[res_type] / resource_type / name, 'wb'
) as f:
await f.write(content)

View File

@ -53,7 +53,7 @@ asyncio_mode = "auto"
[tool.ruff]
select = ["E", "W", "F", "UP", "C", "T", "PYI", "PT", "Q"]
ignore = ["E402", "C901", "UP037", "Q000"]
ignore = ["C901", "Q000"]
line-length = 108
target-version = "py311"