Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ 更新Pydantic V2 #56

Merged
merged 10 commits into from
Mar 10, 2024
Merged
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ci:
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.3.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -20,7 +20,7 @@ repos:
stages: [commit]

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.2.0
hooks:
- id: black
stages: [commit]
Expand Down
64 changes: 48 additions & 16 deletions nonebot_plugin_skland_arksign/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,31 @@ async def add(
else:
wait_bind_dict[event_session.id1] = uid

await skland.finish(cleantext(f"""
await skland.finish(
cleantext(
f"""
[森空岛明日方舟签到器]已在群聊{event_session.id2}添加新账号!
UID:{uid}
备注:{note or "无"}
接下来,请你通过`私信`bot /森空岛 bind [该账号对应的token] 来完成定时签到服务!"""))
接下来,请你通过`私信`bot /森空岛 bind [该账号对应的token] 来完成定时签到服务!"""
)
)

# 这是私信
else:
if not token:
await skland.finish("请提供token!")

await skland.send(cleantext(f"""
await skland.send(
cleantext(
f"""
[森空岛明日方舟签到器]已添加新账号!
UID:{uid}
TOKEN:{token}
备注:{note or "无"}
"""))
"""
)
)
runres = await run_signin(uid=uid, token=token)
await skland.finish(f"立即执行签到操作完成!\n{runres.text}")

Expand Down Expand Up @@ -125,19 +133,27 @@ async def bind(
del wait_bind_dict[event_session.id1]

# 发送成功信息(私聊)
await skland.send(cleantext(f"""
await skland.send(
cleantext(
f"""
[森空岛明日方舟签到器]已经为绑定在群聊的游戏账号绑定TOKEN!
群聊:{user}
游戏账号UID:{uid}
TOKEN:{token}
备注:{note}
"""))
"""
)
)
# 再到群聊通知一下
runres = await run_signin(uid=uid, token=token)
msg = Text(cleantext(f"""
msg = Text(
cleantext(
f"""
[森空岛明日方舟签到器]用户{event_session.id1}已经通过私信绑定账号{uid}的token!
立即执行签到操作完成!
信息如下:{runres.text}"""))
信息如下:{runres.text}"""
)
)
await msg.send_to(PlatformTarget.deserialize(user))


Expand Down Expand Up @@ -170,11 +186,15 @@ async def del_(
await db_session.delete(result)
await db_session.commit()

await skland.finish(cleantext(f"""
await skland.finish(
cleantext(
f"""
[森空岛明日方舟签到器]已删除旧账号!
UID:{uid}
备注:{note or "无"}
"""))
"""
)
)


@skland.assign("list", parameterless=[Depends(skland_session_extract)])
Expand All @@ -200,11 +220,15 @@ def show_token(token: str):
def report_maker(subscribes: list[SklandSubscribe]):
report = []
for i in subscribes:
report.append(cleantext(f"""
report.append(
cleantext(
f"""
UID:{i.uid}
TOKEN:{show_token(i.token)}
备注:{i.note}
"""))
"""
)
)
return "\n\n".join(report)

stmt = select(SklandSubscribe)
Expand Down Expand Up @@ -240,12 +264,16 @@ async def update(
result.note = note
await db_session.flush()
await db_session.commit()
await skland.finish(cleantext(f"""
await skland.finish(
cleantext(
f"""
[森空岛明日方舟签到器]已更新账号信息!
UID:{uid or "未更改"}
TOKEN:{token or "未更改"}
备注:{note or "未更改"}
"""))
"""
)
)


@skland.assign("signin.identifier", "!all")
Expand All @@ -271,7 +299,11 @@ async def signin(
await skland.finish("未能使用uid或备注匹配到任何账号,请检查")

sign_res = await run_signin(uid=result.uid, token=result.token)
await skland.finish(cleantext(f"""
await skland.finish(
cleantext(
f"""
[森空岛明日方舟签到器]已为账号{result.uid}手动签到!
信息如下:{sign_res.text}
"""))
"""
)
)
28 changes: 18 additions & 10 deletions nonebot_plugin_skland_arksign/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from nonebot import get_driver
from pydantic import BaseModel
from nonebot import get_plugin_config

from .utils import cleantext

Expand All @@ -12,36 +12,44 @@ class Config(BaseModel):
@property
def init_des(self) -> str:
if self.skland_arksign_allow_group is True:
return cleantext("""
return cleantext(
"""
森空岛自动签到插件
私信使用:森空岛 add [游戏账号ID] [森空岛token]
群聊使用:森空岛 add [游戏账号ID] ; 之后通过与bot私聊输入token
如何获取token:登录森空岛(https://www.skland.com/ )后访问网址(https://web-api.skland.com/account/info/hg ),看到的"content"中内容即为token。
注意:如果在群聊使用请注意安全问题!
""")
"""
)
else:
return cleantext("""
return cleantext(
"""
森空岛自动签到插件
使用:森空岛 add [游戏账号ID] [森空岛token]
如何获取token:登录森空岛(https://www.skland.com/ )后访问网址(https://web-api.skland.com/account/info/hg ),看到的"content"中内容即为token。
""")
"""
)

@property
def del_des(self) -> str:
return cleantext("""
return cleantext(
"""
删除森空岛账号
使用:森空岛 del [游戏账号ID]
注意:非超级用户只可删除自己绑定的账号;超级用户可以删除bot数据库内所有账号
""")
"""
)

@property
def use_example(self) -> str:
return cleantext("""
return cleantext(
"""
/森空岛 add [游戏账号ID] [森空岛token]
/森空岛 del [游戏账号ID]
/森空岛 list
* 注意检查 游戏账号ID 和 森空岛token 是否正确和配对
""")
"""
)


plugin_config: Config = Config.parse_obj(get_driver().config)
plugin_config = get_plugin_config(Config)
Loading
Loading