From f22221f78198fe77c59324013dc3f345708990d5 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Tue, 17 Feb 2026 18:02:41 +0800 Subject: [PATCH] fix: improve permission denied message for local execution in Python and shell tools --- astrbot/core/computer/tools/python.py | 7 +++++-- astrbot/core/computer/tools/shell.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/astrbot/core/computer/tools/python.py b/astrbot/core/computer/tools/python.py index 2c4ae6c8a..9c4768320 100644 --- a/astrbot/core/computer/tools/python.py +++ b/astrbot/core/computer/tools/python.py @@ -88,8 +88,11 @@ class LocalPythonTool(FunctionTool): self, context: ContextWrapper[AstrAgentContext], code: str, silent: bool = False ) -> ToolExecResult: if context.context.event.role != "admin": - return "error: Permission denied. Local Python execution is only allowed for admin users. Tell user to set admins in AstrBot WebUI." - + return ( + "error: Permission denied. Local Python execution is only allowed for admin users. " + "Tell user to set admins in AstrBot WebUI by adding their user ID to the admins list if they need this feature." + f"User's ID is: {context.context.event.get_sender_id()}. User's ID can be found by using /sid command." + ) sb = get_local_booter() try: result = await sb.python.exec(code, silent=silent) diff --git a/astrbot/core/computer/tools/shell.py b/astrbot/core/computer/tools/shell.py index eeeb3f9d4..e63124d2d 100644 --- a/astrbot/core/computer/tools/shell.py +++ b/astrbot/core/computer/tools/shell.py @@ -47,7 +47,11 @@ class ExecuteShellTool(FunctionTool): env: dict = {}, ) -> ToolExecResult: if context.context.event.role != "admin": - return "error: Permission denied. Shell execution is only allowed for admin users. Tell user to Set admins in AstrBot WebUI." + return ( + "error: Permission denied. Local shell execution is only allowed for admin users. " + "Tell user to set admins in AstrBot WebUI by adding their user ID to the admins list if they need this feature." + f"User's ID is: {context.context.event.get_sender_id()}. User's ID can be found by using /sid command." + ) if self.is_local: sb = get_local_booter()