diff --git a/zhenxun/builtin_plugins/help/__init__.py b/zhenxun/builtin_plugins/help/__init__.py index c74d7e56..0fa6f787 100644 --- a/zhenxun/builtin_plugins/help/__init__.py +++ b/zhenxun/builtin_plugins/help/__init__.py @@ -113,6 +113,11 @@ async def _( ): _is_superuser = is_superuser.result if is_superuser.available else False + if _is_superuser and session.user.id not in bot.config.superusers: + await MessageUtils.build_message("权限不足,无法查看超级用户帮助").finish( + reply_to=True + ) + if name.available: traditional_help_result = await get_plugin_help( session.user.id, name.result, _is_superuser diff --git a/zhenxun/builtin_plugins/superuser/request_manage.py b/zhenxun/builtin_plugins/superuser/request_manage.py index d0e9beb0..8cdd38ef 100644 --- a/zhenxun/builtin_plugins/superuser/request_manage.py +++ b/zhenxun/builtin_plugins/superuser/request_manage.py @@ -17,7 +17,7 @@ from nonebot_plugin_alconna import ( store_true, ) from nonebot_plugin_alconna.uniseg.tools import reply_fetch -from nonebot_plugin_session import EventSession +from nonebot_plugin_uninfo import Uninfo from zhenxun.configs.config import BotConfig from zhenxun.configs.path_config import IMAGE_PATH @@ -33,12 +33,14 @@ from zhenxun.utils.utils import get_user_avatar usage = """ 查看请求 清空请求 -请求处理 -fa [id] / 同意好友请求 [id] # 同意好友请求 -请求处理 -fr [id] / 拒绝好友请求 [id] # 拒绝好友请求 -请求处理 -fi [id] / 忽略好友请求 [id] # 忽略好友请求 -请求处理 -ga [id] / 同意群组请求 [id] # 同意群聊请求 -请求处理 -gr [id] / 拒绝群组请求 [id] # 拒绝群聊请求 -请求处理 -gi [id] / 忽略群组请求 [id] # 忽略群聊请求 +同意请求 [id] +拒绝请求 [id] +忽略请求 [id] + +特别的,在引用消息时,可以不指定id +/引用消息 同意请求 +/引用消息 拒绝请求 +/引用消息 忽略请求 """.strip() @@ -57,11 +59,11 @@ __plugin_meta__ = PluginMetadata( _req_matcher = on_alconna( Alconna( "请求处理", - Args["handle", ["-fa", "-fr", "-fi", "-ga", "-gr", "-gi"]]["id?", int], + Args["handle", ["a", "r", "i"]]["id?", int], meta=CommandMeta( - description="好友/群组请求处理", + description="请求处理", usage=usage, - example="同意好友请求 20", + example="同意请求 20", compact=True, ), ), @@ -108,12 +110,9 @@ _clear_matcher = on_alconna( ) reg_arg_list = [ - (r"同意好友请求\s*(?P\d*)", ["-fa", "{id}"]), - (r"拒绝好友请求\s*(?P\d*)", ["-fr", "{id}"]), - (r"忽略好友请求\s*(?P\d*)", ["-fi", "{id}"]), - (r"同意群组请求\s*(?P\d*)", ["-ga", "{id}"]), - (r"拒绝群组请求\s*(?P\d*)", ["-gr", "{id}"]), - (r"忽略群组请求\s*(?P\d*)", ["-gi", "{id}"]), + (r"同意请求\s*(?P\d*)", ["a", "{id}"]), + (r"拒绝请求\s*(?P\d*)", ["r", "{id}"]), + (r"忽略请求\s*(?P\d*)", ["i", "{id}"]), ] for r in reg_arg_list: @@ -129,7 +128,7 @@ for r in reg_arg_list: async def _( bot: Bot, event: Event, - session: EventSession, + session: Uninfo, handle: str, id: Match[int], arparma: Arparma, @@ -153,7 +152,7 @@ async def _( ).finish(reply_to=True) handle_id = db_data.id req = None - handle_type = type_dict[handle[-1]] + handle_type = type_dict[handle] try: if handle_type == RequestHandleType.APPROVE: req = await FgRequest.approve(bot, handle_id) @@ -187,7 +186,7 @@ async def _( @_read_matcher.handle() async def _( - session: EventSession, + session: Uninfo, arparma: Arparma, is_friend: Query[bool] = AlconnaQuery("friend.value", False), is_group: Query[bool] = AlconnaQuery("group.value", False), @@ -283,7 +282,7 @@ async def _( @_clear_matcher.handle() async def _( - session: EventSession, + session: Uninfo, arparma: Arparma, is_friend: Query[bool] = AlconnaQuery("friend.value", False), is_group: Query[bool] = AlconnaQuery("group.value", False), diff --git a/zhenxun/models/fg_request.py b/zhenxun/models/fg_request.py index 2f1d8252..95677f2a 100644 --- a/zhenxun/models/fg_request.py +++ b/zhenxun/models/fg_request.py @@ -128,12 +128,14 @@ class FgRequest(Model): await bot.set_friend_add_request( flag=req.flag, approve=handle_type == RequestHandleType.APPROVE ) - if BotProfileManager.is_auto_send_profile(): - file_path = await BotProfileManager.build_bot_profile_image( + if ( + handle_type == RequestHandleType.APPROVE + and BotProfileManager.is_auto_send_profile() + ): + if file_path := await BotProfileManager.build_bot_profile_image( bot.self_id - ) - if file_path: - await asyncio.sleep(2) + ): + await asyncio.sleep(1) await PlatformUtils.send_message( bot, req.user_id, diff --git a/zhenxun/services/db_context/__init__.py b/zhenxun/services/db_context/__init__.py index 70ead644..b5ec0be6 100644 --- a/zhenxun/services/db_context/__init__.py +++ b/zhenxun/services/db_context/__init__.py @@ -46,6 +46,8 @@ driver = nonebot.get_driver() def get_config() -> dict: """获取数据库配置""" + if not BotConfig.db_url: + raise DbUrlIsNode("数据库Url连接字符串为空,请检查配置文件(.env.dev)") parsed = urlparse(BotConfig.db_url) # 基础配置 @@ -92,7 +94,7 @@ def get_config() -> dict: config["connections"]["default"] = { "engine": "tortoise.backends.sqlite", "credentials": { - "file_path": parsed.path or ":memory:", + "file_path": parsed.path, }, **SQLITE_CONFIG, } diff --git a/zhenxun/utils/github_utils/func.py b/zhenxun/utils/github_utils/func.py index c18df01d..aeb59c31 100644 --- a/zhenxun/utils/github_utils/func.py +++ b/zhenxun/utils/github_utils/func.py @@ -4,7 +4,6 @@ from zhenxun.utils.http_utils import AsyncHttpx from .const import ( ARCHIVE_URL_FORMAT, - GITEE_RAW_CONTENT_FORMAT, RAW_CONTENT_FORMAT, RELEASE_ASSETS_FORMAT, RELEASE_SOURCE_FORMAT, @@ -22,7 +21,6 @@ async def __get_fastest_formats(formats: dict[str, str]) -> list[str]: async def get_fastest_raw_formats() -> list[str]: """获取最快的raw下载地址格式""" formats: dict[str, str] = { - "https://gitee.com/": GITEE_RAW_CONTENT_FORMAT, "https://raw.githubusercontent.com/": RAW_CONTENT_FORMAT, "https://ghproxy.cc/": f"https://ghproxy.cc/{RAW_CONTENT_FORMAT}", "https://gh-proxy.com/": f"https://gh-proxy.com/{RAW_CONTENT_FORMAT}",