From f963194124ab718570817f1e8d18f91c628dfdea Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Tue, 10 Dec 2024 16:32:54 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=A7=81=E8=81=8A=E4=B8=8B=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95=E4=B8=8D=E6=8B=A6=E6=88=AA=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/pipeline/waking_check/stage.py | 1 + astrbot/core/pipeline/whitelist_check/stage.py | 2 ++ astrbot/dashboard/routes/auth.py | 10 +++++----- packages/astrbot/main.py | 11 +++++------ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/astrbot/core/pipeline/waking_check/stage.py b/astrbot/core/pipeline/waking_check/stage.py index 53c212761..8528fcaad 100644 --- a/astrbot/core/pipeline/waking_check/stage.py +++ b/astrbot/core/pipeline/waking_check/stage.py @@ -15,6 +15,7 @@ class WakingCheckStage(Stage): 2. 机器人的消息被提到了 3. 以 wake_prefix 前缀开头 4. 插件(Star)的 handler filter 通过 + 5. 私聊情况下,位于 admins_id 列表中的管理员的消息 ''' async def initialize(self, ctx: PipelineContext) -> None: diff --git a/astrbot/core/pipeline/whitelist_check/stage.py b/astrbot/core/pipeline/whitelist_check/stage.py index a7d00f194..a27df67a6 100644 --- a/astrbot/core/pipeline/whitelist_check/stage.py +++ b/astrbot/core/pipeline/whitelist_check/stage.py @@ -14,6 +14,8 @@ class WhitelistCheckStage(Stage): async def process(self, event: AstrMessageEvent) -> Union[None, AsyncGenerator[None, None]]: # 检查是否在白名单 + if event.role == 'admin' and event.get_message_type() == MessageType.FRIEND_MESSAGE: + return if event.unified_msg_origin not in self.whitelist: logger.info(f"会话 {event.unified_msg_origin} 不在会话白名单中,已终止事件传播。") event.stop_event() \ No newline at end of file diff --git a/astrbot/dashboard/routes/auth.py b/astrbot/dashboard/routes/auth.py index dd295a68d..e538f77cf 100644 --- a/astrbot/dashboard/routes/auth.py +++ b/astrbot/dashboard/routes/auth.py @@ -13,8 +13,8 @@ class AuthRoute(Route): self.register_routes() async def login(self): - username = self.config.dashboard.username - password = self.config.dashboard.password + username = self.config['dashboard']['username'] + password = self.config['dashboard']['password'] post_data = await request.json if post_data["username"] == username and post_data["password"] == password: return Response().ok({ @@ -25,7 +25,7 @@ class AuthRoute(Route): return Response().error("用户名或密码错误").__dict__ async def edit_account(self): - password = self.config.dashboard.password + password = self.config['dashboard']['password'] post_data = await request.json if post_data["password"] != password: @@ -37,9 +37,9 @@ class AuthRoute(Route): return Response().error("新用户名和新密码不能同时为空,你改了个寂寞").__dict__ if new_pwd: - self.config.dashboard.password = new_pwd + self.config['dashboard']['password'] = new_pwd if new_username: - self.config.dashboard.username = new_username + self.config['dashboard']['username'] = new_username self.config.save_config() diff --git a/packages/astrbot/main.py b/packages/astrbot/main.py index 6d69e3359..ee7b3e92b 100644 --- a/packages/astrbot/main.py +++ b/packages/astrbot/main.py @@ -51,9 +51,8 @@ class Main(star.Star): @filter.command("plugin") async def plugin(self, event: AstrMessageEvent): plugin_list_info = "已加载的插件:\n" - for plugin in self.context.registered_plugins: - plugin_list_info += f"- `{plugin.metadata.plugin_name}` By { - plugin.metadata.author}: {plugin.metadata.desc}\n" + for plugin in self.context.get_all_stars(): + plugin_list_info += f"- `{plugin.name}` By {plugin.author}: {plugin.desc}\n" if plugin_list_info.strip() == "": plugin_list_info = "没有加载任何插件。" @@ -62,12 +61,12 @@ class Main(star.Star): @filter.command("t2i") async def t2i(self, event: AstrMessageEvent): config = self.context.get_config() - if config.t2i: - config.t2i = False + if config['t2i']: + config['t2i'] = False config.save_config() event.set_result(MessageEventResult().message("已关闭文本转图片模式。")) return - config.t2i = True + config['t2i'] = True config.save_config() event.set_result(MessageEventResult().message("已开启文本转图片模式。"))