diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index ab62aa2..9298714 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -57,17 +57,12 @@ body: validations: required: true - # Env | VM Arch - - type: dropdown + # Env | Nonebot 2 Version + - type: textarea id: env-nb2-ver attributes: label: Nonebot 2 版本 - description: 选择运行机器人 Nonebot 2 的系统架构 - options: - - 2.0.1 - - 2.1.0 - - 2.1.1 - - 其它(请在下方说明) + description: 选择运行机器人 Nonebot 2 的版本 validations: required: true diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 97d8d26..835ee1a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -8,14 +8,14 @@ on: - nonebot_plugin_skland_arksign/** - tests/** - pyproject.toml - - poetry.lock + - pdm.lock - .github/** pull_request: paths: - nonebot_plugin_skland_arksign/** - tests/** - pyproject.toml - - poetry.lock + - pdm.lock - .github/** concurrency: @@ -36,7 +36,7 @@ jobs: PYTHON_VERSION: ${{ matrix.python-version }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Python environment uses: ./.github/actions/setup-python diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 120a071..da08a02 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,30 +7,30 @@ 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.6 + rev: v0.1.9 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] stages: [commit] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort stages: [commit] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black stages: [commit] - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.3 + rev: v4.0.0-alpha.8 hooks: - id: prettier + args: [--write] types_or: [javascript, jsx, ts, tsx, markdown, yaml, json] - exclude: "admin-frontend/" stages: [commit] exclude: "CHANGELOG.md" diff --git a/README.md b/README.md index 0079da8..28e32e4 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,11 @@ skland del 游戏账号ID/备注 ``` > [!WARNING] -> 注意:非[超级用户](https://nonebot.dev/docs/appendices/config#superusers)只可删除自己绑定的账号,超级用户可以删除bot数据库内所有账号 +> 超级用户可以删除bot数据库内的任意账号 +> +> [OneBot V11](https://onebot.adapters.nonebot.dev/) 适配器中的 QQ 群管理员以上权限的用户可以在群内删除本群内的任意账号 +> +> 非[超级用户](https://nonebot.dev/docs/appendices/config#superusers)只可在私聊中删除自己绑定的账号 ### 列出账号 @@ -167,17 +171,25 @@ skland del 游戏账号ID/备注 skland list ``` +### 更新账号数据 + +```shell +skland update 游戏账号ID/备注 [-u 可选UID] [-t 可选token] [-n 可选备注] +``` + > [!WARNING] -> 仅超级用户可用 +> 因可能涉及token变更,本指令只允许[超级用户](https://nonebot.dev/docs/appendices/config#superusers)或单独的用户删除自己能处理的账户 + +### 重新绑定账号对应的用户数据模型 -### 更新账号 +在更新至[`>=v0.7.0`](https://pypi.org/project/nonebot-plugin-skland-arksign/0.7.0/)([#39](https://github.com/GuGuMur/nonebot-plugin-skland-arksign/issues/39)) 后,使用这一指令重新绑定账号对应的用户数据模型 ```shell -skland update 游戏账号ID/备注 [-u 可选UID] [-t 可选token] [-n 可选备注] +skland rebind 游戏账号ID ``` > [!WARNING] -> 仅超级用户可用 +> 因涉及用户数据模型变更,本指令只允许用户处理自己的账号,**超级用户亦只可以处理自己的账号** ### 立即手动签到 @@ -200,11 +212,7 @@ skland signin !all ## ♿️ FAQ -1. 为什么这么多仅超级用户可用的命令? - 因为当前的数据库模型没有记录添加者的信息,只记录了需要发送到的用户信息,所以暂时只能通过超级用户来操作 - 未来可能会加入权限系统,以及增加数据库模型字段 - -2. 使用例子? +1. 使用例子? ```shell skland add 114514 1919810 -n hhhaaa @@ -218,22 +226,23 @@ skland signin !all skland signin 1919810 ``` -3. 为什么我刚获取token并绑定好,一会就用不了了? +2. 为什么我刚获取token并绑定好,一会就用不了了? - 当您使用浏览器获取token时,**不要去登出账号,否则鹰角网络通行证会失效!** - 如果要添加多个账号,请删除浏览器缓存。或者使用浏览器自带的隐私浏览模式,拿到Token后,关闭隐私窗口,再登录一次即可 - 注意:电脑在用密码登录后,手机客户端有可能会被挤掉,但一定不要点客户端里的清理会话,否则所有的登录状态**都会被清空!** -4. 报错`{'code': 10001, 'message': '当前用户未经授权'}`? +3. 报错`{'code': 10001, 'message': '当前用户未经授权'}`? - 参考 [#更新账号](#更新账号) 一栏重新绑定游戏账号ID - 参考issue:[#29](https://github.com/GuGuMur/nonebot-plugin-skland-arksign/issues/29) -5. 报错`Client error '400 Bad Request' for url xxx`? +4. 报错`Client error '400 Bad Request' for url xxx`? - 请检查token复制过程中是否有错漏,以及游戏账号ID是否与您输入的token相符 +- 参考[#立即手动签到](#立即手动签到) 一栏执行手动签到操作 -6. 报错`Client error '401 Unauthorized' for url xxx`? +5. 报错`Client error '401 Unauthorized' for url xxx`? - 参考 [#配置](#配置) 一栏修改`skland_timestamp_delay`的数值 - 参考值:`5`,`10` diff --git a/nonebot_plugin_skland_arksign/alc_parser.py b/nonebot_plugin_skland_arksign/alc_parser.py index ae74239..b91101a 100644 --- a/nonebot_plugin_skland_arksign/alc_parser.py +++ b/nonebot_plugin_skland_arksign/alc_parser.py @@ -2,7 +2,7 @@ from .config import plugin_config -skland_alc = Alconna( +skland_cmd = Alconna( "skland", Subcommand( "add", @@ -10,18 +10,28 @@ Option("-n|--note", Args["note", str]), help_text="添加一个新的签到账号", ), + Subcommand( + "bind", + Args["token", str], + help_text="在私聊绑定一个在群聊中添加的签到账号", + ), + Subcommand( + "rebind", + Args["uid", str], + help_text="更新数据库结构后重新绑定账户的信息", + ), Subcommand( "list", help_text="列出所有签到账号", ), Subcommand( "del", - Args["identifier", str], + Args["identifier", str]["position?", int], help_text="使用uid或者备注删除一个签到账号", ), Subcommand( "update", - Args["identifier", str], + Args["identifier", str]["position?", int], [ Option("-u|--uid", Args["uid", str]), Option("-t|--token", Args["token", str]), @@ -29,14 +39,9 @@ ], help_text="使用uid或者备注更新一个签到账号", ), - Subcommand( - "bind", - Args["token", str], - help_text="在私聊绑定一个在群聊中添加的签到账号", - ), Subcommand( "signin", - Args["identifier", str], + Args["identifier", str]["position?", int], help_text="使用uid或者备注立刻签到一个账号", ), meta=CommandMeta( diff --git a/nonebot_plugin_skland_arksign/command.py b/nonebot_plugin_skland_arksign/command.py index 4e7273d..94a9386 100644 --- a/nonebot_plugin_skland_arksign/command.py +++ b/nonebot_plugin_skland_arksign/command.py @@ -4,19 +4,19 @@ from nonebot.typing import T_State from nonebot.adapters import Bot, Event from nonebot.permission import SUPERUSER -from nonebot_plugin_alconna import on_alconna +from nonebot_plugin_session import EventSession from sqlalchemy.ext.asyncio import AsyncSession from nonebot_plugin_datastore import get_session from nonebot_plugin_saa import Text, PlatformTarget from nonebot_plugin_session_saa import get_saa_target -from nonebot_plugin_session import EventSession, extract_session +from nonebot_plugin_alconna import AlconnaArg, UniMessage, AlconnaMatcher, on_alconna -from .utils import cleantext from .sched import sched_sign from .signin import run_signin -from .alc_parser import skland_alc +from .alc_parser import skland_cmd from .model import SklandSubscribe -from .depends import skland_session_extract +from .utils import cleantext, report_maker, compare_user_info +from .depends import skland_is_group, skland_list_subscribes, skland_session_extract SessionId1 = str BindUid = str @@ -24,15 +24,23 @@ wait_bind_dict: dict[SessionId1, BindUid] = {} skland = on_alconna( - skland_alc, + skland_cmd, aliases={"skd", "skl", "森空岛"}, use_cmd_start=True, # use_cmd_sep=True, auto_send_output=True, ) +skland_add = skland.dispatch("add") +skland_bind = skland.dispatch("bind") +skland_list = skland.dispatch("list") +skland_del = skland.dispatch("del") +skland_update = skland.dispatch("update") +skland_signin = skland.dispatch("signin") +skland_signin_all = skland.dispatch("signin.identifier", "!all") +skland_rebind = skland.dispatch("rebind") -@skland.assign("add") +@skland_add.handle() async def add( state: T_State, uid: str, @@ -42,19 +50,30 @@ async def add( db_session: AsyncSession = Depends(get_session), ): logger.debug(f"匹配到的参数:{state}") - user_account = get_saa_target(event_session) - if not user_account: + send_to_dict = get_saa_target(event_session).dict() + event_session_dict = event_session.dict() + if not send_to_dict: await skland.finish("未能获取到当前会话的可发送用户信息,请检查") - logger.debug(f"当前会话的用户信息:{user_account.dict()}") - - # 判断是否为私信/群聊 + # logger.debug(f"当前会话的用户信息:{send_to_target.dict()}") # 先添加一个record - stmt = select(SklandSubscribe).where(SklandSubscribe.uid == uid) - result = await db_session.scalar(stmt) - if result: - await skland.finish("该UID已经被注册,请检查") - new_record = SklandSubscribe(user=user_account.dict(), uid=uid, token=token, cred="", note=note) + # 1. 检查UID是否被注册 + async with db_session.begin(): + stmt = select(SklandSubscribe).where(SklandSubscribe.uid == uid) + result = await db_session.scalar(stmt) + if result: + await skland.finish("该UID已经被您或其他用户注册,请检查") + + # 2. 检查用户绑定的 note 是否与自己绑的重复 + if note is not None: + async with db_session.begin(): + stmt = select(SklandSubscribe).where(SklandSubscribe.note == note) + result: list[SklandSubscribe] = (await db_session.scalars(stmt)).all() + if any(i for i in result if compare_user_info(i, event_session)): + await skland.finish("该note已经被您注册,请检查") + + # 3. 绑定到数据库里 + new_record = SklandSubscribe(uid=uid, user=event_session_dict, sendto=send_to_dict, token=token, cred="", note=note) db_session.add(new_record) await db_session.commit() await db_session.refresh(new_record) @@ -78,7 +97,7 @@ async def add( # 这是私信 else: if not token: - await skland.finish("请提供token!") + await skland.finish("请通过 /森空岛 update 指令提供token!") await skland.send(cleantext(f""" [森空岛明日方舟签到器]已添加新账号! @@ -90,7 +109,7 @@ async def add( await skland.finish(f"立即执行签到操作完成!\n{runres.text}") -@skland.assign("bind") +@skland_bind.handle() async def bind( state: T_State, token: str, @@ -142,32 +161,62 @@ async def bind( await msg.send_to(PlatformTarget.deserialize(user)) -# 删除功能可以在各处使用 -@skland.assign("del") -async def del_( +@skland_list.handle() +async def list_( bot: Bot, event: Event, + state: T_State, + matcher: AlconnaMatcher, + event_session: EventSession, + db_session: AsyncSession = Depends(get_session), +): + is_group = skland_is_group(bot, event) + all_subscribes: list[SklandSubscribe] = await skland_list_subscribes(bot, event, matcher, db_session) + if not all_subscribes: + await skland.finish("当前没有绑定任何森空岛签到账号!") + await skland.finish("您可查询的森空岛签到账号如下:\n" + report_maker(all_subscribes, is_group)) + + +@skland_del.handle() +async def del_1( + bot: Bot, + event: Event, + state: T_State, identifier: str, - event_session: EventSession = Depends(extract_session), + matcher: AlconnaMatcher, + event_session: EventSession, db_session: AsyncSession = Depends(get_session), ): - # identifier 可以是uid或者备注, 需要都尝试一下 - stmt = select(SklandSubscribe).where((SklandSubscribe.uid == identifier) | (SklandSubscribe.note == identifier)) - result = await db_session.scalar(stmt) - if not result: + all_subscribes = await skland_list_subscribes(bot, event, matcher, db_session) + is_group = skland_is_group(bot, event) + + all_subscribes = [i for i in all_subscribes if (i.uid == identifier) | (i.note == identifier)] + if not all_subscribes: await skland.finish("未能使用uid或备注匹配到任何账号,请检查") + state["prompt"] = ( + "您可执行操作的森空岛签到账号如下:\n" + report_maker(all_subscribes, is_group) + "\n请输入对应序号完成操作!" + ) - if not await SUPERUSER(bot, event): - user = get_saa_target(event_session) - if not user: - await skland.finish("未能获取到当前会话的用户信息,请检查") + state["all_subscribes"] = all_subscribes + if len(all_subscribes) == 1: + matcher.set_path_arg("del.position", 0) - if user.dict() != result.user: - await skland.finish("您无权删除该账号!") +@skland_del.got_path("del.position", prompt=UniMessage.template("{prompt}")) +async def del_2( + bot: Bot, + event: Event, + state: T_State, + matcher: AlconnaMatcher, + event_session: EventSession, + position: int | None = AlconnaArg("del.position"), + db_session: AsyncSession = Depends(get_session), +): + if position >= len(state["all_subscribes"]): + await skland.reject("输入的序号超出了您所能控制的账号数,请重新输入!") + result = state["all_subscribes"][position] uid = result.uid note = result.note or "无" - await db_session.delete(result) await db_session.commit() @@ -178,61 +227,54 @@ async def del_( """)) -@skland.assign("list", parameterless=[Depends(skland_session_extract)]) -async def list_( +@skland_update.handle() +async def update_1( bot: Bot, event: Event, state: T_State, + identifier: str, + matcher: AlconnaMatcher, + event_session: EventSession, + uid: str | None = None, + token: str | None = None, + note: str | None = None, db_session: AsyncSession = Depends(get_session), ): + # 动token的操作 还是自己来吧 + is_group = skland_is_group(bot, event) + stmt = select(SklandSubscribe).where((SklandSubscribe.uid == identifier) | (SklandSubscribe.note == identifier)) + all_subscribes = (await db_session.scalars(stmt)).all() if not await SUPERUSER(bot, event): - await skland.finish("您无权查看账号列表!") + all_subscribes = [i for i in all_subscribes if compare_user_info(i, event_session)] + if not all_subscribes: + await skland.finish("未能使用uid或备注匹配到任何账号,请检查") - is_group = state.get("is_group") + if len(all_subscribes) == 1: + matcher.set_path_arg("update.position", 0) + state["prompt"] = ( + "您可执行操作的森空岛签到账号如下:\n" + report_maker(all_subscribes, is_group) + "\n请输入对应序号完成操作!" + ) - def show_token(token: str): - if not token: - return "未绑定" - else: - if is_group: - return "已绑定" - return token - - def report_maker(subscribes: list[SklandSubscribe]): - report = [] - for i in subscribes: - report.append(cleantext(f""" - UID:{i.uid} - TOKEN:{show_token(i.token)} - 备注:{i.note} - """)) - return "\n\n".join(report) - - stmt = select(SklandSubscribe) - result = (await db_session.scalars(stmt)).all() - if not result: - await skland.finish("未能查询到任何账号,请检查") - await skland.finish(report_maker(list(result))) + state["all_subscribes"] = all_subscribes -@skland.assign("update", parameterless=[Depends(skland_session_extract)]) -async def update( +@skland_update.got_path("update.position", prompt=UniMessage.template("{prompt}")) +async def update_2( bot: Bot, event: Event, identifier: str, + matcher: AlconnaMatcher, + state: T_State, + event_session: EventSession, uid: str | None = None, token: str | None = None, note: str | None = None, + position: int | None = AlconnaArg("update.position"), db_session: AsyncSession = Depends(get_session), ): - if not await SUPERUSER(bot, event): - await skland.finish("您无权更新账号信息!") - - stmt = select(SklandSubscribe).where((SklandSubscribe.uid == identifier) | (SklandSubscribe.note == identifier)) - result = await db_session.scalar(stmt) - if not result: - await skland.finish("未能使用uid或备注匹配到任何账号,请检查") - + if position >= len(state["all_subscribes"]): + await skland.reject("输入的序号超出了您所能控制的账号数,请重新输入!") + result = state["all_subscribes"][position] if uid: result.uid = uid if token: @@ -249,30 +291,72 @@ async def update( """)) -@skland.assign("signin.identifier", "!all") +@skland_signin_all.handle() async def signin_all(): await sched_sign() await skland.finish("所有账号已经手动重新触发签到!") -# 手动签到功能可以在各处使用 -@skland.assign("signin") -async def signin( +@skland_signin.handle() +async def signin_1( bot: Bot, event: Event, + state: T_State, identifier: str, + matcher: AlconnaMatcher, + event_session: EventSession, db_session: AsyncSession = Depends(get_session), ): - if not await SUPERUSER(bot, event): - await skland.finish("您无权手动签到!") - - stmt = select(SklandSubscribe).where((SklandSubscribe.uid == identifier) | (SklandSubscribe.note == identifier)) - result = await db_session.scalar(stmt) - if not result: + is_group = skland_is_group(bot, event) + all_subscribes = await skland_list_subscribes(bot, event, matcher, db_session) + all_subscribes = [i for i in all_subscribes if (i.uid == identifier) | (i.note == identifier)] + if not all_subscribes: await skland.finish("未能使用uid或备注匹配到任何账号,请检查") + state["prompt"] = ( + "您可执行操作的森空岛签到账号如下:\n" + report_maker(all_subscribes, is_group) + "\n请输入对应序号完成操作!" + ) + state["all_subscribes"] = all_subscribes + if len(all_subscribes) == 1: + matcher.set_path_arg("signin.position", 0) + +@skland_signin.got_path("signin.position", prompt=UniMessage.template("{prompt}")) +async def signin_2( + bot: Bot, + event: Event, + state: T_State, + matcher: AlconnaMatcher, + event_session: EventSession, + position: int | None = AlconnaArg("signin.position"), + db_session: AsyncSession = Depends(get_session), +): + if position >= len(state["all_subscribes"]): + await skland.reject("输入的序号超出了您所能控制的账号数,请重新输入!") + result = state["all_subscribes"][position] sign_res = await run_signin(uid=result.uid, token=result.token) await skland.finish(cleantext(f""" [森空岛明日方舟签到器]已为账号{result.uid}手动签到! 信息如下:{sign_res.text} """)) + + +@skland_rebind.handle() +async def rebind( + state: T_State, + uid: str, + event_session: EventSession, + db_session: AsyncSession = Depends(get_session), +): + stmt = select(SklandSubscribe).where(SklandSubscribe.uid == uid) + result: SklandSubscribe | None = await db_session.scalar(stmt) + if not result: + await skland.finish("没有找到需要重新绑定的账户,请检查") + old_user = result.sendto + now_sendto_dict = get_saa_target(event_session).dict() + if old_user == now_sendto_dict: + result.user = event_session.dict() + await db_session.flush() + await db_session.commit() + await skland.finish(f"已完成UID:{uid}的森空岛账号的用户信息重绑定!") + else: + await skland.finish("该账户此前并非您所有,请检查") diff --git a/nonebot_plugin_skland_arksign/constants.py b/nonebot_plugin_skland_arksign/constants.py index 024c0a8..c3eef63 100644 --- a/nonebot_plugin_skland_arksign/constants.py +++ b/nonebot_plugin_skland_arksign/constants.py @@ -12,14 +12,14 @@ class _CONSTANTS: @property def REQUEST_HEADERS_BASE(self) -> dict[str, str]: return { - "User-Agent": "Skland/1.5.1 (com.hypergryph.skland; build:100501001; Android 34; ) Okhttp/4.11.0", + "User-Agent": "Skland/1.7.0 (com.hypergryph.skland; build:100700063; Android 34; ) Okhttp/4.11.0", "Accept-Encoding": "gzip", "Connection": "close", } @property def SIGN_HEADERS_BASE(self) -> dict[str, str]: - return {"platform": "1", "timestamp": "", "dId": "de9759a5afaa634f", "vName": "1.5.1"} + return {"platform": "1", "timestamp": "", "dId": "de9759a5afaa634f", "vName": "1.7.0"} CONSTANTS = _CONSTANTS() diff --git a/nonebot_plugin_skland_arksign/depends.py b/nonebot_plugin_skland_arksign/depends.py index 3f31fd7..d047f49 100644 --- a/nonebot_plugin_skland_arksign/depends.py +++ b/nonebot_plugin_skland_arksign/depends.py @@ -1,12 +1,28 @@ +from typing import TYPE_CHECKING + +from sqlalchemy import select from nonebot.typing import T_State -from nonebot.matcher import Matcher from nonebot.adapters import Bot, Event +from nonebot.permission import SUPERUSER +from sqlalchemy.ext.asyncio import AsyncSession +from nonebot_plugin_alconna import AlconnaMatcher from nonebot_plugin_session import Session, SessionLevel, extract_session from .config import plugin_config +from .model import SklandSubscribe +from .utils import compare_user_info + + +def skland_is_group(bot: Bot, event: Event) -> bool: + """不用于会话处理的群消息判断""" + session = extract_session(bot, event) + if session.level != SessionLevel.LEVEL1: + if plugin_config.skland_arksign_allow_group: + return True + return False -async def skland_session_extract(bot: Bot, event: Event, matcher: Matcher, state: T_State) -> Session: +async def skland_session_extract(bot: Bot, event: Event, matcher: AlconnaMatcher, state: T_State) -> Session: """ 从当前会话中提取Session, 按照 plugin_config.skland_arksign_allow_group 的值判断是否允许群聊使用 """ @@ -19,3 +35,50 @@ async def skland_session_extract(bot: Bot, event: Event, matcher: Matcher, state await matcher.finish("请在私聊中使用该指令!") return session + + +async def skland_list_subscribes( + bot: Bot, + event: Event, + matcher: AlconnaMatcher, + db_session: AsyncSession, +) -> list[SklandSubscribe]: + """ + 根据用户组生成其能获取的订阅列表,文本生成逻辑应写在业务处 + """ + event_session = extract_session(bot, event) + is_group = skland_is_group(bot, event) + flag: bool = False + # SUPERUSER 的 list:返回全部 + if await SUPERUSER(bot, event): + flag = True + stmt = select(SklandSubscribe) + result = (await db_session.scalars(stmt)).all() + + # QQ群管理的list:返回当前群聊的所有绑定 + elif is_group and flag is False: + flag = True + if not bot.adapter.get_name() == "OneBot V11": + await matcher.finish("当前的森空岛签到插件无法提供Onebot V11外的群聊绑定记录...") + if TYPE_CHECKING: + from nonebot.adapters.onebot.v11.bot import Bot as OneBotV11Bot + + assert isinstance(bot, OneBotV11Bot) + from nonebot.adapters.onebot.v11 import GROUP_ADMIN, GROUP_OWNER + + if not (await GROUP_ADMIN(bot, event) or await GROUP_OWNER(bot, event)): + await matcher.finish("您不是本群的管理员或群主,请通过私聊获取您的个人绑定记录!") + + stmt = select(SklandSubscribe) + result = (await db_session.scalars(stmt)).all() + result = [i for i in result if i.sendto.get("group_to") == event_session.id2] + + # 普通用户的list:返回该用户绑定的所有账号 + else: + stmt = select(SklandSubscribe) + result: list[SklandSubscribe] = (await db_session.scalars(stmt)).all() + result = [i for i in result if compare_user_info(i, event_session)] + + if not result: + await matcher.finish("未能查询到任何账号,请检查") + return result diff --git a/nonebot_plugin_skland_arksign/migrations/b488a7927868_remove_unique_note.py b/nonebot_plugin_skland_arksign/migrations/b488a7927868_remove_unique_note.py new file mode 100644 index 0000000..2477178 --- /dev/null +++ b/nonebot_plugin_skland_arksign/migrations/b488a7927868_remove_unique_note.py @@ -0,0 +1,31 @@ +"""remove_unique_note + +Revision ID: b488a7927868 +Revises: f9eda5d9d24e +Create Date: 2023-12-17 11:14:36.273477 + +""" + +from alembic import op + +# revision identifiers, used by Alembic. +revision = "b488a7927868" +down_revision = "f9eda5d9d24e" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("skland_subscribe", schema=None) as batch_op: + batch_op.drop_constraint("uq_skland_subscribe_note", type_="unique") + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table("skland_subscribe", schema=None) as batch_op: + batch_op.create_unique_constraint("uq_skland_subscribe_note", ["note"]) + + # ### end Alembic commands ### diff --git a/nonebot_plugin_skland_arksign/migrations/f9eda5d9d24e_database_update.py b/nonebot_plugin_skland_arksign/migrations/f9eda5d9d24e_database_update.py new file mode 100644 index 0000000..a9cf389 --- /dev/null +++ b/nonebot_plugin_skland_arksign/migrations/f9eda5d9d24e_database_update.py @@ -0,0 +1,38 @@ +"""database_update + +Revision ID: f9eda5d9d24e +Revises: d89239244530 +Create Date: 2023-12-17 10:43:59.367604 + +""" + +import sqlalchemy as sa +from alembic import op +from sqlalchemy.dialects import sqlite, postgresql + +# revision identifiers, used by Alembic. +revision = "f9eda5d9d24e" +down_revision = "d89239244530" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + with op.batch_alter_table("skland_subscribe", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "sendto", sa.JSON().with_variant(postgresql.JSONB(astext_type=sa.Text()), "postgresql"), nullable=True + ) + ) + op.execute("UPDATE skland_subscribe SET sendto = user") + with op.batch_alter_table("skland_subscribe", schema=None) as batch_op: + batch_op.alter_column("user", existing_type=sqlite.JSON(), nullable=True) + + +def downgrade() -> None: + with op.batch_alter_table("skland_subscribe", schema=None) as batch_op: + batch_op.alter_column("user", existing_type=sqlite.JSON(), nullable=False) + + op.execute("UPDATE skland_subscribe SET user = sendto") + with op.batch_alter_table("skland_subscribe", schema=None) as batch_op: + batch_op.drop_column("sendto") diff --git a/nonebot_plugin_skland_arksign/model.py b/nonebot_plugin_skland_arksign/model.py index f1707bc..f5466f4 100644 --- a/nonebot_plugin_skland_arksign/model.py +++ b/nonebot_plugin_skland_arksign/model.py @@ -11,7 +11,8 @@ class SklandSubscribe(Model): __table_args__ = {"extend_existing": True} uid: Mapped[str] = mapped_column(String, primary_key=True, doc="森空岛账号ID") - user: Mapped[dict] = mapped_column(JSON().with_variant(JSONB, "postgresql"), doc="订阅用户信息") + user: Mapped[dict] = mapped_column(JSON().with_variant(JSONB, "postgresql"), doc="订阅用户信息", nullable=True) + sendto: Mapped[dict] = mapped_column(JSON().with_variant(JSONB, "postgresql"), doc="发送位置", nullable=True) cred: Mapped[str] = mapped_column(String, doc="森空岛账号CRED") token: Mapped[str] = mapped_column(String, doc="森空岛账号TOKEN", nullable=True) - note: Mapped[str] = mapped_column(String, doc="备注", nullable=True, unique=True) + note: Mapped[str] = mapped_column(String, doc="备注", nullable=True) diff --git a/nonebot_plugin_skland_arksign/sched.py b/nonebot_plugin_skland_arksign/sched.py index 8a2e49d..c61c03d 100644 --- a/nonebot_plugin_skland_arksign/sched.py +++ b/nonebot_plugin_skland_arksign/sched.py @@ -24,7 +24,7 @@ async def sched_sign(): sub_groups: dict[PlatformTarget, list[SignResult]] = {} for sub in subscribes: - target = PlatformTarget.deserialize(sub.user) + target = PlatformTarget.deserialize(sub.sendto) logger.debug(f"target: {target.dict()}") if not sub.token: await Text(f"账号{sub.uid}未绑定Token,请重新绑定!").send_to(target) diff --git a/nonebot_plugin_skland_arksign/signin.py b/nonebot_plugin_skland_arksign/signin.py index 5a12a96..75b2fc6 100644 --- a/nonebot_plugin_skland_arksign/signin.py +++ b/nonebot_plugin_skland_arksign/signin.py @@ -139,11 +139,11 @@ def parse(sign_response: dict[str, Any]) -> SignResult: resource.update(award.get("resource", {})) text += f"奖励ID:{resource['id']}\n" text += f"签到奖励:{resource['name']} × {award.get('count')}\n" - text += f"类型:{resource['type']} {award.get('type', '')}\n" + text += f"类型:{resource['type']} {award.get('type', '')}\n\n" else: status = False text = f"[{server}] {drname} UID:{uid} 签到失败\n请检查以下信息:\n{sign_response}" - return SignResult(status, text) + return SignResult(status, text.strip()) async with AsyncClient() as client: sign_response = await client.post( diff --git a/nonebot_plugin_skland_arksign/utils.py b/nonebot_plugin_skland_arksign/utils.py index 14ea395..54aaf01 100644 --- a/nonebot_plugin_skland_arksign/utils.py +++ b/nonebot_plugin_skland_arksign/utils.py @@ -1,5 +1,37 @@ +from nonebot_plugin_session import EventSession + +from .model import SklandSubscribe + + def cleantext(text: str) -> str: lines = text.strip().split("\n") cleaned_lines = [line.strip() for line in lines] result = "\n".join(cleaned_lines) return result + + +def compare_user_info(dict1: SklandSubscribe, dict2: EventSession): + includes = ["bot_type", "platform", "id1"] + filter1 = {k: dict1.user.get(k) for k in includes} + filter2 = {k: dict2.__dict__.get(k) for k in includes} + return filter1 == filter2 + + +def show_token(token: str, is_group: bool) -> str: + if not token: + return "未绑定" + elif is_group: + return "已绑定" + return token + + +def report_maker(subscribes: list[SklandSubscribe], is_group: bool) -> str: + report = [] + for n, i in enumerate(subscribes): + report.append(cleantext(f""" + {n}: + UID:{i.uid} + TOKEN:{show_token(i.token, is_group)} + 备注:{i.note} + """)) + return "\n\n".join(report) diff --git a/pdm.lock b/pdm.lock index 15ce2c6..e703cfe 100644 --- a/pdm.lock +++ b/pdm.lock @@ -3,10 +3,9 @@ [metadata] groups = ["default", "dev", "test"] -cross_platform = true -static_urls = false -lock_version = "4.3" -content_hash = "sha256:71249f04f728c33109a46f6c0d2c390819d6345ae56d9b2e452024e53461e44d" +strategy = ["cross_platform"] +lock_version = "4.4.1" +content_hash = "sha256:e70fae0abaa748dd388d8cb361335cd3b9e47e965b1c333c2c207e3fd4bfabb3" [[package]] name = "aiosqlite" @@ -65,7 +64,7 @@ files = [ [[package]] name = "arclet-alconna" -version = "1.7.36" +version = "1.7.39" requires_python = ">=3.8" summary = "A High-performance, Generality, Humane Command Line Arguments Parser Library." dependencies = [ @@ -74,8 +73,8 @@ dependencies = [ "typing-extensions>=4.5.0", ] files = [ - {file = "arclet_alconna-1.7.36-py3-none-any.whl", hash = "sha256:9bfe081f1bfa9883c28cd242c1587c9ea9cd0abd2b13c84ce26270cdbb0f4374"}, - {file = "arclet_alconna-1.7.36.tar.gz", hash = "sha256:680ea48485db0dbed32083a6a1160e5520d8acec0425e8f423d999c0f27bf0ab"}, + {file = "arclet_alconna-1.7.39-py3-none-any.whl", hash = "sha256:7743892bc496cc630c44ed552a68ad9782efa44289362cb07c05bb197f880f89"}, + {file = "arclet_alconna-1.7.39.tar.gz", hash = "sha256:90b466c8471ef9e10be4053efa19663c6806b521100abdb398abe19dab49b113"}, ] [[package]] @@ -145,7 +144,7 @@ files = [ [[package]] name = "black" -version = "23.11.0" +version = "23.12.1" requires_python = ">=3.8" summary = "The uncompromising code formatter." dependencies = [ @@ -158,16 +157,20 @@ dependencies = [ "typing-extensions>=4.0.1; python_version < \"3.11\"", ] files = [ - {file = "black-23.11.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dbea0bb8575c6b6303cc65017b46351dc5953eea5c0a59d7b7e3a2d2f433a911"}, - {file = "black-23.11.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:412f56bab20ac85927f3a959230331de5614aecda1ede14b373083f62ec24e6f"}, - {file = "black-23.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d136ef5b418c81660ad847efe0e55c58c8208b77a57a28a503a5f345ccf01394"}, - {file = "black-23.11.0-cp310-cp310-win_amd64.whl", hash = "sha256:6c1cac07e64433f646a9a838cdc00c9768b3c362805afc3fce341af0e6a9ae9f"}, - {file = "black-23.11.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cf57719e581cfd48c4efe28543fea3d139c6b6f1238b3f0102a9c73992cbb479"}, - {file = "black-23.11.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:698c1e0d5c43354ec5d6f4d914d0d553a9ada56c85415700b81dc90125aac244"}, - {file = "black-23.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:760415ccc20f9e8747084169110ef75d545f3b0932ee21368f63ac0fee86b221"}, - {file = "black-23.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:58e5f4d08a205b11800332920e285bd25e1a75c54953e05502052738fe16b3b5"}, - {file = "black-23.11.0-py3-none-any.whl", hash = "sha256:54caaa703227c6e0c87b76326d0862184729a69b73d3b7305b6288e1d830067e"}, - {file = "black-23.11.0.tar.gz", hash = "sha256:4c68855825ff432d197229846f971bc4d6666ce90492e5b02013bcaca4d9ab05"}, + {file = "black-23.12.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0aaf6041986767a5e0ce663c7a2f0e9eaf21e6ff87a5f95cbf3675bfd4c41d2"}, + {file = "black-23.12.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c88b3711d12905b74206227109272673edce0cb29f27e1385f33b0163c414bba"}, + {file = "black-23.12.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a920b569dc6b3472513ba6ddea21f440d4b4c699494d2e972a1753cdc25df7b0"}, + {file = "black-23.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:3fa4be75ef2a6b96ea8d92b1587dd8cb3a35c7e3d51f0738ced0781c3aa3a5a3"}, + {file = "black-23.12.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8d4df77958a622f9b5a4c96edb4b8c0034f8434032ab11077ec6c56ae9f384ba"}, + {file = "black-23.12.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:602cfb1196dc692424c70b6507593a2b29aac0547c1be9a1d1365f0d964c353b"}, + {file = "black-23.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c4352800f14be5b4864016882cdba10755bd50805c95f728011bcb47a4afd59"}, + {file = "black-23.12.1-cp311-cp311-win_amd64.whl", hash = "sha256:0808494f2b2df923ffc5723ed3c7b096bd76341f6213989759287611e9837d50"}, + {file = "black-23.12.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:25e57fd232a6d6ff3f4478a6fd0580838e47c93c83eaf1ccc92d4faf27112c4e"}, + {file = "black-23.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2d9e13db441c509a3763a7a3d9a49ccc1b4e974a47be4e08ade2a228876500ec"}, + {file = "black-23.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1bd9c210f8b109b1762ec9fd36592fdd528485aadb3f5849b2740ef17e674e"}, + {file = "black-23.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:ae76c22bde5cbb6bfd211ec343ded2163bba7883c7bc77f6b756a1049436fbb9"}, + {file = "black-23.12.1-py3-none-any.whl", hash = "sha256:78baad24af0f033958cad29731e27363183e140962595def56423e626f4bee3e"}, + {file = "black-23.12.1.tar.gz", hash = "sha256:4ce3ef14ebe8d9509188014d96af1c456a910d5b5cbf434a09fef7e024b3d0d5"}, ] [[package]] @@ -488,34 +491,34 @@ files = [ [[package]] name = "httpx" -version = "0.25.1" +version = "0.26.0" requires_python = ">=3.8" summary = "The next generation HTTP client." dependencies = [ "anyio", "certifi", - "httpcore", + "httpcore==1.*", "idna", "sniffio", ] files = [ - {file = "httpx-0.25.1-py3-none-any.whl", hash = "sha256:fec7d6cc5c27c578a391f7e87b9aa7d3d8fbcd034f6399f9f79b45bcc12a866a"}, - {file = "httpx-0.25.1.tar.gz", hash = "sha256:ffd96d5cf901e63863d9f1b4b6807861dbea4d301613415d9e6e57ead15fc5d0"}, + {file = "httpx-0.26.0-py3-none-any.whl", hash = "sha256:8915f5a3627c4d47b73e8202457cb28f1266982d1159bd5779d86a80c0eab1cd"}, + {file = "httpx-0.26.0.tar.gz", hash = "sha256:451b55c30d5185ea6b23c2c793abf9bb237d2a7dfb901ced6ff69ad37ec1dfaf"}, ] [[package]] name = "httpx" -version = "0.25.1" +version = "0.26.0" extras = ["http2"] requires_python = ">=3.8" summary = "The next generation HTTP client." dependencies = [ "h2<5,>=3", - "httpx==0.25.1", + "httpx==0.26.0", ] files = [ - {file = "httpx-0.25.1-py3-none-any.whl", hash = "sha256:fec7d6cc5c27c578a391f7e87b9aa7d3d8fbcd034f6399f9f79b45bcc12a866a"}, - {file = "httpx-0.25.1.tar.gz", hash = "sha256:ffd96d5cf901e63863d9f1b4b6807861dbea4d301613415d9e6e57ead15fc5d0"}, + {file = "httpx-0.26.0-py3-none-any.whl", hash = "sha256:8915f5a3627c4d47b73e8202457cb28f1266982d1159bd5779d86a80c0eab1cd"}, + {file = "httpx-0.26.0.tar.gz", hash = "sha256:451b55c30d5185ea6b23c2c793abf9bb237d2a7dfb901ced6ff69ad37ec1dfaf"}, ] [[package]] @@ -560,12 +563,12 @@ files = [ [[package]] name = "isort" -version = "5.12.0" +version = "5.13.2" requires_python = ">=3.8.0" summary = "A Python utility / library to sort Python imports." files = [ - {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, - {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, + {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, + {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, ] [[package]] @@ -763,7 +766,7 @@ files = [ [[package]] name = "nb-cli" -version = "1.2.6" +version = "1.2.8" requires_python = ">=3.8, <4.0" summary = "CLI for nonebot2" dependencies = [ @@ -783,8 +786,8 @@ dependencies = [ "wcwidth~=0.2", ] files = [ - {file = "nb-cli-1.2.6.tar.gz", hash = "sha256:33ca8ffdb721ea50751c47788789c84cd7594afc888ccfb2439f06ff95cbbd7c"}, - {file = "nb_cli-1.2.6-py3-none-any.whl", hash = "sha256:2aa52e0d21fb8a5a08662b691fa6cd521c99140aa0e24a81503264129f4b3045"}, + {file = "nb-cli-1.2.8.tar.gz", hash = "sha256:8e17c73ca494ce16b3a18a18d4d611b5ffb27e37ee3de2c7a510c7e32b7df002"}, + {file = "nb_cli-1.2.8-py3-none-any.whl", hash = "sha256:080a07c4bb94f93a662844d7f1fe8b9672cb61daf6a9c3ae74bbc42ed17a35a7"}, ] [[package]] @@ -831,19 +834,19 @@ files = [ [[package]] name = "nonebot-plugin-alconna" -version = "0.33.5" +version = "0.35.1" requires_python = ">=3.8" summary = "Alconna Adapter for Nonebot" dependencies = [ "arclet-alconna-tools<0.7.0,>=0.6.7", - "arclet-alconna<2.0.0,>=1.7.31", + "arclet-alconna<2.0.0,>=1.7.38", "fleep>=1.0.1", "nepattern<0.6.0,>=0.5.14", "nonebot2>=2.1.0", ] files = [ - {file = "nonebot_plugin_alconna-0.33.5-py3-none-any.whl", hash = "sha256:57414d52fbe586479c6a372a58213346ceeccf7aeec261a18df5351f9a489069"}, - {file = "nonebot_plugin_alconna-0.33.5.tar.gz", hash = "sha256:ecb5213402cff4cd93a04e7a8c618d434972ca144eb2a6010df6e85b47f520fa"}, + {file = "nonebot_plugin_alconna-0.35.1-py3-none-any.whl", hash = "sha256:70dd86b477642dc1d154aef1ceb142e5350475852f87f4b3413dfc0c7d929d87"}, + {file = "nonebot_plugin_alconna-0.35.1.tar.gz", hash = "sha256:0940af2ddfd8cedde59123b2e3dc77aacb4efab1751d9744091d6baa69920e94"}, ] [[package]] @@ -892,7 +895,7 @@ files = [ [[package]] name = "nonebot-plugin-send-anything-anywhere" -version = "0.3.2" +version = "0.4.0" requires_python = ">=3.8,<4.0" summary = "An adaptor for nonebot2 adaptors" dependencies = [ @@ -902,42 +905,42 @@ dependencies = [ "strenum<0.5.0,>=0.4.8", ] files = [ - {file = "nonebot_plugin_send_anything_anywhere-0.3.2-py3-none-any.whl", hash = "sha256:2dac60653f49aa25f3a08eb75544ecb155e30b2496f1f7a16e27ddc76ff09796"}, - {file = "nonebot_plugin_send_anything_anywhere-0.3.2.tar.gz", hash = "sha256:19a54c8f69d01f2000b1f2536eea4076acd8fe219f7f0d9060a8120bd7052d52"}, + {file = "nonebot_plugin_send_anything_anywhere-0.4.0-py3-none-any.whl", hash = "sha256:d089729458e247d4717db195fe679ca2d47b86394f1dc20ce9f06eea300c2227"}, + {file = "nonebot_plugin_send_anything_anywhere-0.4.0.tar.gz", hash = "sha256:c72d4cfbed963ba07a9e29cb40fd0174dce01a49f6f9944f4bbfda0bb8322630"}, ] [[package]] name = "nonebot-plugin-session" -version = "0.2.0" +version = "0.2.3" requires_python = ">=3.8,<4.0" summary = "Nonebot2 会话信息提取与会话id定义" dependencies = [ - "nonebot2[fastapi]<3.0.0,>=2.0.0", + "nonebot2<3.0.0,>=2.0.0", "strenum<0.5.0,>=0.4.8", ] files = [ - {file = "nonebot_plugin_session-0.2.0-py3-none-any.whl", hash = "sha256:00859872b7c7d2967e1eaabf161c8a47dc83bc85791629b659922b2f425d4854"}, - {file = "nonebot_plugin_session-0.2.0.tar.gz", hash = "sha256:5f92706dfeb6e21dcce04998bc3b8dafc59f5af50d2908aceeed0faf9d88a67c"}, + {file = "nonebot_plugin_session-0.2.3-py3-none-any.whl", hash = "sha256:5f652a0c082231c1cea72deb994a81e50f77ba532e14d30fdec09772f69079fd"}, + {file = "nonebot_plugin_session-0.2.3.tar.gz", hash = "sha256:33af37400f5005927c4ff861e593774bedc314fba00cfe06f482e582d9f447b7"}, ] [[package]] name = "nonebot-plugin-session-saa" -version = "0.1.0" +version = "0.1.1" requires_python = ">=3.8,<4.0" summary = "session 插件 saa 扩展" dependencies = [ - "nonebot-plugin-send-anything-anywhere<0.4.0,>=0.3.1", + "nonebot-plugin-send-anything-anywhere<0.5.0,>=0.4.0", "nonebot-plugin-session<0.3.0,>=0.2.0", "nonebot2[fastapi]<3.0.0,>=2.0.1", ] files = [ - {file = "nonebot_plugin_session_saa-0.1.0-py3-none-any.whl", hash = "sha256:eb067e1e81261f85aae550a37aad1d6e1be20c64b78e60c34812d2d44fed487d"}, - {file = "nonebot_plugin_session_saa-0.1.0.tar.gz", hash = "sha256:a278ed490160722d6e1e0c165993a9ee3fed093814e87fdb6a2a0cc20fb5d2d4"}, + {file = "nonebot_plugin_session_saa-0.1.1-py3-none-any.whl", hash = "sha256:ba9666bf49534df6129dd9170b55d20cbc80b86693a1370948dcf210a5feabce"}, + {file = "nonebot_plugin_session_saa-0.1.1.tar.gz", hash = "sha256:d0fc55d91e5ca2a21948069816b82cb94d7091a45b345d89f3eaf08c3ffb8579"}, ] [[package]] name = "nonebot2" -version = "2.1.2" +version = "2.1.3" requires_python = ">=3.8,<4.0" summary = "An asynchronous python bot framework." dependencies = [ @@ -949,39 +952,39 @@ dependencies = [ "yarl<2.0.0,>=1.7.2", ] files = [ - {file = "nonebot2-2.1.2-py3-none-any.whl", hash = "sha256:a4df78e4c8b81773ea70b4b68d4ac3a5027d69517661d756772f11edf3cd3b1f"}, - {file = "nonebot2-2.1.2.tar.gz", hash = "sha256:afb3c141c67645cd038125287d0583aec2220eca998a8392e42ba87722f6659f"}, + {file = "nonebot2-2.1.3-py3-none-any.whl", hash = "sha256:c36c1a60ce4355d9777fee431c08619f22ffd60f7060993fbbbd1fe67b6368f7"}, + {file = "nonebot2-2.1.3.tar.gz", hash = "sha256:e750e615f1ad2503721ce055fbe55ec3b061277135d995be112fecd27f7232e5"}, ] [[package]] name = "nonebot2" -version = "2.1.2" +version = "2.1.3" extras = ["fastapi"] requires_python = ">=3.8,<4.0" summary = "An asynchronous python bot framework." dependencies = [ "fastapi<1.0.0,>=0.93.0", - "nonebot2==2.1.2", + "nonebot2==2.1.3", "uvicorn[standard]<1.0.0,>=0.20.0", ] files = [ - {file = "nonebot2-2.1.2-py3-none-any.whl", hash = "sha256:a4df78e4c8b81773ea70b4b68d4ac3a5027d69517661d756772f11edf3cd3b1f"}, - {file = "nonebot2-2.1.2.tar.gz", hash = "sha256:afb3c141c67645cd038125287d0583aec2220eca998a8392e42ba87722f6659f"}, + {file = "nonebot2-2.1.3-py3-none-any.whl", hash = "sha256:c36c1a60ce4355d9777fee431c08619f22ffd60f7060993fbbbd1fe67b6368f7"}, + {file = "nonebot2-2.1.3.tar.gz", hash = "sha256:e750e615f1ad2503721ce055fbe55ec3b061277135d995be112fecd27f7232e5"}, ] [[package]] name = "nonebot2" -version = "2.1.2" +version = "2.1.3" extras = ["httpx"] requires_python = ">=3.8,<4.0" summary = "An asynchronous python bot framework." dependencies = [ "httpx[http2]<1.0.0,>=0.20.0", - "nonebot2==2.1.2", + "nonebot2==2.1.3", ] files = [ - {file = "nonebot2-2.1.2-py3-none-any.whl", hash = "sha256:a4df78e4c8b81773ea70b4b68d4ac3a5027d69517661d756772f11edf3cd3b1f"}, - {file = "nonebot2-2.1.2.tar.gz", hash = "sha256:afb3c141c67645cd038125287d0583aec2220eca998a8392e42ba87722f6659f"}, + {file = "nonebot2-2.1.3-py3-none-any.whl", hash = "sha256:c36c1a60ce4355d9777fee431c08619f22ffd60f7060993fbbbd1fe67b6368f7"}, + {file = "nonebot2-2.1.3.tar.gz", hash = "sha256:e750e615f1ad2503721ce055fbe55ec3b061277135d995be112fecd27f7232e5"}, ] [[package]] @@ -1056,8 +1059,8 @@ files = [ [[package]] name = "pre-commit" -version = "3.5.0" -requires_python = ">=3.8" +version = "3.6.0" +requires_python = ">=3.9" summary = "A framework for managing and maintaining multi-language pre-commit hooks." dependencies = [ "cfgv>=2.0.0", @@ -1067,8 +1070,8 @@ dependencies = [ "virtualenv>=20.10.0", ] files = [ - {file = "pre_commit-3.5.0-py2.py3-none-any.whl", hash = "sha256:841dc9aef25daba9a0238cd27984041fa0467b4199fc4852e27950664919f660"}, - {file = "pre_commit-3.5.0.tar.gz", hash = "sha256:5804465c675b659b0862f07907f96295d490822a450c4c40e747d0b1c6ebcb32"}, + {file = "pre_commit-3.6.0-py2.py3-none-any.whl", hash = "sha256:c255039ef399049a5544b6ce13d135caba8f2c28c3b4033277a788f434308376"}, + {file = "pre_commit-3.6.0.tar.gz", hash = "sha256:d30bad9abf165f7785c15a21a1f46da7d0677cb00ee7ff4c579fd38922efe15d"}, ] [[package]] @@ -1170,7 +1173,7 @@ files = [ [[package]] name = "pytest" -version = "7.4.3" +version = "7.4.4" requires_python = ">=3.7" summary = "pytest: simple powerful testing with Python" dependencies = [ @@ -1182,26 +1185,26 @@ dependencies = [ "tomli>=1.0.0; python_version < \"3.11\"", ] files = [ - {file = "pytest-7.4.3-py3-none-any.whl", hash = "sha256:0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac"}, - {file = "pytest-7.4.3.tar.gz", hash = "sha256:d989d136982de4e3b29dabcc838ad581c64e8ed52c11fbe86ddebd9da0818cd5"}, + {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, + {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, ] [[package]] name = "pytest-asyncio" -version = "0.21.1" -requires_python = ">=3.7" +version = "0.23.3" +requires_python = ">=3.8" summary = "Pytest support for asyncio" dependencies = [ "pytest>=7.0.0", ] files = [ - {file = "pytest-asyncio-0.21.1.tar.gz", hash = "sha256:40a7eae6dded22c7b604986855ea48400ab15b069ae38116e8c01238e9eeb64d"}, - {file = "pytest_asyncio-0.21.1-py3-none-any.whl", hash = "sha256:8666c1c8ac02631d7c51ba282e0c69a8a452b211ffedf2599099845da5c5c37b"}, + {file = "pytest-asyncio-0.23.3.tar.gz", hash = "sha256:af313ce900a62fbe2b1aed18e37ad757f1ef9940c6b6a88e2954de38d6b1fb9f"}, + {file = "pytest_asyncio-0.23.3-py3-none-any.whl", hash = "sha256:37a9d912e8338ee7b4a3e917381d1c95bfc8682048cb0fbc35baba316ec1faba"}, ] [[package]] name = "pytest-xdist" -version = "3.4.0" +version = "3.5.0" requires_python = ">=3.7" summary = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" dependencies = [ @@ -1209,8 +1212,8 @@ dependencies = [ "pytest>=6.2.0", ] files = [ - {file = "pytest-xdist-3.4.0.tar.gz", hash = "sha256:3a94a931dd9e268e0b871a877d09fe2efb6175c2c23d60d56a6001359002b832"}, - {file = "pytest_xdist-3.4.0-py3-none-any.whl", hash = "sha256:e513118bf787677a427e025606f55e95937565e06dfaac8d87f55301e57ae607"}, + {file = "pytest-xdist-3.5.0.tar.gz", hash = "sha256:cbb36f3d67e0c478baa57fa4edc8843887e0f6cfc42d677530a36d7472b32d8a"}, + {file = "pytest_xdist-3.5.0-py3-none-any.whl", hash = "sha256:d075629c7e00b611df89f490a5063944bee7a4362a5ff11c7cc7824a03dfce24"}, ] [[package]] @@ -1321,27 +1324,27 @@ files = [ [[package]] name = "ruff" -version = "0.1.6" +version = "0.1.11" requires_python = ">=3.7" summary = "An extremely fast Python linter and code formatter, written in Rust." files = [ - {file = "ruff-0.1.6-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:88b8cdf6abf98130991cbc9f6438f35f6e8d41a02622cc5ee130a02a0ed28703"}, - {file = "ruff-0.1.6-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:5c549ed437680b6105a1299d2cd30e4964211606eeb48a0ff7a93ef70b902248"}, - {file = "ruff-0.1.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1cf5f701062e294f2167e66d11b092bba7af6a057668ed618a9253e1e90cfd76"}, - {file = "ruff-0.1.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:05991ee20d4ac4bb78385360c684e4b417edd971030ab12a4fbd075ff535050e"}, - {file = "ruff-0.1.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:87455a0c1f739b3c069e2f4c43b66479a54dea0276dd5d4d67b091265f6fd1dc"}, - {file = "ruff-0.1.6-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:683aa5bdda5a48cb8266fcde8eea2a6af4e5700a392c56ea5fb5f0d4bfdc0240"}, - {file = "ruff-0.1.6-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:137852105586dcbf80c1717facb6781555c4e99f520c9c827bd414fac67ddfb6"}, - {file = "ruff-0.1.6-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bd98138a98d48a1c36c394fd6b84cd943ac92a08278aa8ac8c0fdefcf7138f35"}, - {file = "ruff-0.1.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a0cd909d25f227ac5c36d4e7e681577275fb74ba3b11d288aff7ec47e3ae745"}, - {file = "ruff-0.1.6-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:e8fd1c62a47aa88a02707b5dd20c5ff20d035d634aa74826b42a1da77861b5ff"}, - {file = "ruff-0.1.6-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:fd89b45d374935829134a082617954120d7a1470a9f0ec0e7f3ead983edc48cc"}, - {file = "ruff-0.1.6-py3-none-musllinux_1_2_i686.whl", hash = "sha256:491262006e92f825b145cd1e52948073c56560243b55fb3b4ecb142f6f0e9543"}, - {file = "ruff-0.1.6-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:ea284789861b8b5ca9d5443591a92a397ac183d4351882ab52f6296b4fdd5462"}, - {file = "ruff-0.1.6-py3-none-win32.whl", hash = "sha256:1610e14750826dfc207ccbcdd7331b6bd285607d4181df9c1c6ae26646d6848a"}, - {file = "ruff-0.1.6-py3-none-win_amd64.whl", hash = "sha256:4558b3e178145491e9bc3b2ee3c4b42f19d19384eaa5c59d10acf6e8f8b57e33"}, - {file = "ruff-0.1.6-py3-none-win_arm64.whl", hash = "sha256:03910e81df0d8db0e30050725a5802441c2022ea3ae4fe0609b76081731accbc"}, - {file = "ruff-0.1.6.tar.gz", hash = "sha256:1b09f29b16c6ead5ea6b097ef2764b42372aebe363722f1605ecbcd2b9207184"}, + {file = "ruff-0.1.11-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:a7f772696b4cdc0a3b2e527fc3c7ccc41cdcb98f5c80fdd4f2b8c50eb1458196"}, + {file = "ruff-0.1.11-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:934832f6ed9b34a7d5feea58972635c2039c7a3b434fe5ba2ce015064cb6e955"}, + {file = "ruff-0.1.11-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ea0d3e950e394c4b332bcdd112aa566010a9f9c95814844a7468325290aabfd9"}, + {file = "ruff-0.1.11-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9bd4025b9c5b429a48280785a2b71d479798a69f5c2919e7d274c5f4b32c3607"}, + {file = "ruff-0.1.11-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e1ad00662305dcb1e987f5ec214d31f7d6a062cae3e74c1cbccef15afd96611d"}, + {file = "ruff-0.1.11-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:4b077ce83f47dd6bea1991af08b140e8b8339f0ba8cb9b7a484c30ebab18a23f"}, + {file = "ruff-0.1.11-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c4a88efecec23c37b11076fe676e15c6cdb1271a38f2b415e381e87fe4517f18"}, + {file = "ruff-0.1.11-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5b25093dad3b055667730a9b491129c42d45e11cdb7043b702e97125bcec48a1"}, + {file = "ruff-0.1.11-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:231d8fb11b2cc7c0366a326a66dafc6ad449d7fcdbc268497ee47e1334f66f77"}, + {file = "ruff-0.1.11-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:09c415716884950080921dd6237767e52e227e397e2008e2bed410117679975b"}, + {file = "ruff-0.1.11-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0f58948c6d212a6b8d41cd59e349751018797ce1727f961c2fa755ad6208ba45"}, + {file = "ruff-0.1.11-py3-none-musllinux_1_2_i686.whl", hash = "sha256:190a566c8f766c37074d99640cd9ca3da11d8deae2deae7c9505e68a4a30f740"}, + {file = "ruff-0.1.11-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:6464289bd67b2344d2a5d9158d5eb81025258f169e69a46b741b396ffb0cda95"}, + {file = "ruff-0.1.11-py3-none-win32.whl", hash = "sha256:9b8f397902f92bc2e70fb6bebfa2139008dc72ae5177e66c383fa5426cb0bf2c"}, + {file = "ruff-0.1.11-py3-none-win_amd64.whl", hash = "sha256:eb85ee287b11f901037a6683b2374bb0ec82928c5cbc984f575d0437979c521a"}, + {file = "ruff-0.1.11-py3-none-win_arm64.whl", hash = "sha256:97ce4d752f964ba559c7023a86e5f8e97f026d511e48013987623915431c7ea9"}, + {file = "ruff-0.1.11.tar.gz", hash = "sha256:f9d4d88cb6eeb4dfe20f9f0519bd2eaba8119bde87c3d5065c541dbae2b5a2cb"}, ] [[package]] @@ -1380,7 +1383,7 @@ version = "2.0.23" requires_python = ">=3.7" summary = "Database Abstraction Library" dependencies = [ - "greenlet!=0.4.17; platform_machine == \"aarch64\" or (platform_machine == \"ppc64le\" or (platform_machine == \"x86_64\" or (platform_machine == \"amd64\" or (platform_machine == \"AMD64\" or (platform_machine == \"win32\" or platform_machine == \"WIN32\")))))", + "greenlet!=0.4.17; platform_machine == \"win32\" or platform_machine == \"WIN32\" or platform_machine == \"AMD64\" or platform_machine == \"amd64\" or platform_machine == \"x86_64\" or platform_machine == \"ppc64le\" or platform_machine == \"aarch64\"", "typing-extensions>=4.2.0", ] files = [ @@ -1614,7 +1617,7 @@ dependencies = [ "python-dotenv>=0.13", "pyyaml>=5.1", "uvicorn==0.24.0.post1", - "uvloop!=0.15.0,!=0.15.1,>=0.14.0; sys_platform != \"win32\" and (sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\")", + "uvloop!=0.15.0,!=0.15.1,>=0.14.0; (sys_platform != \"cygwin\" and sys_platform != \"win32\") and platform_python_implementation != \"PyPy\"", "watchfiles>=0.13", "websockets>=10.4", ] diff --git a/pyproject.toml b/pyproject.toml index dbd74ff..12aa8f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,15 +7,15 @@ authors = [ {name = "Azide", email = "rukuy@qq.com"}, ] dependencies = [ - "nonebot2>=2.1.2", - "httpx>=0.25.1", + "nonebot2>=2.1.3", + "httpx>=0.26.0", "pydantic>=1.10.13", "nonebot-plugin-apscheduler>=0.3.0", - "nonebot-plugin-alconna>=0.33.5", + "nonebot-plugin-alconna>=0.35.1", "nonebot-plugin-datastore>=1.1.2", - "nonebot-plugin-session>=0.2.0", - "nonebot-plugin-session-saa>=0.1.0", - "nonebot-plugin-send-anything-anywhere>=0.3.2", + "nonebot-plugin-session>=0.2.3", + "nonebot-plugin-session-saa>=0.1.1", + "nonebot-plugin-send-anything-anywhere>=0.4.0", ] requires-python = ">=3.10" readme = "README.md" @@ -32,18 +32,18 @@ build-backend = "pdm.backend" [tool.pdm.dev-dependencies] dev = [ - "pre-commit>=3.5.0", - "black>=23.11.0", - "ruff>=0.1.6", - "isort>=5.12.0", - "nb-cli>=1.2.6", + "pre-commit>=3.6.0", + "black>=23.12.1", + "ruff>=0.1.11", + "isort>=5.13.2", + "nb-cli>=1.2.8", "nonebot-adapter-onebot>=2.3.1", ] test = [ "nonebug>=0.3.5", - "pytest>=7.4.3", - "pytest-asyncio>=0.21.1", - "pytest-xdist>=3.4.0", + "pytest>=7.4.4", + "pytest-asyncio>=0.23.3", + "pytest-xdist>=3.5.0", ] [tool.nonebot]