Skip to content

Commit

Permalink
fix pydantic bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kitUIN committed Apr 12, 2024
1 parent 08c5a87 commit 1d82754
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions nonebot-plugin-ncm/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional

import nonebot
from pydantic import BaseModel, Extra

Expand All @@ -9,10 +11,10 @@ class Config(BaseModel, extra=Extra.ignore):
ncm_admin_level: int = 1
'''设置命令权限(1:仅限superusers和群主,2:在1的基础上管理员,3:所有用户)'''

ncm_phone: str = ""
ncm_phone: Optional[int] = None
'''手机号'''

ncm_ctcode: str = "86"
ncm_ctcode: int = 86
'''手机号区域码,默认86'''

ncm_password: str = ""
Expand Down
8 changes: 4 additions & 4 deletions nonebot-plugin-ncm/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def load_user(session: str):

def login(self) -> bool:
try:
self.api.login.LoginViaCellphone(phone=ncm_config.ncm_phone, password=ncm_config.ncm_password)
self.api.login.LoginViaCellphone(phone=str(ncm_config.ncm_phone), password=ncm_config.ncm_password)
self.get_user_info()
return True
except Exception as e:
Expand All @@ -80,8 +80,8 @@ def get_user_info(self) -> str:
return message

def get_phone_login(self):
phone = ncm_config.ncm_phone
ctcode = int(ncm_config.ncm_ctcode)
phone: str = str(ncm_config.ncm_phone)
ctcode: int = ncm_config.ncm_ctcode
result = self.api.login.SetSendRegisterVerifcationCodeViaCellphone(cell=phone, ctcode=ctcode)
if not result.get('code', 0) == 200:
logger.error(result)
Expand Down Expand Up @@ -312,7 +312,7 @@ async def start_upload(self, ids: List[int], event: Union[GroupMessageEvent, Pri
logger.info("检测到缓存,自动加载用户")
nncm.load_user(info[0]['session'])
nncm.get_user_info()
elif ncm_config.ncm_phone == "":
elif ncm_config.ncm_phone is None:
logger.warning("您未填写账号,自动进入二维码登录模式")
nncm.get_qrcode()
elif ncm_config.ncm_password == "":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot-plugin-ncm"
version = "1.6.10"
version = "1.6.11"
description = "基于go-cqhttp与nonebot2的 网易云 无损音乐下载"
license = "Apache License 2.0"
authors = ["kitUIN <[email protected]>"]
Expand Down

0 comments on commit 1d82754

Please sign in to comment.