From eaaff4298d3195a213633fd94c5f30182bddf7fc Mon Sep 17 00:00:00 2001 From: Dt8333 <25431943+Dt8333@users.noreply.github.com> Date: Mon, 6 Oct 2025 16:12:05 +0800 Subject: [PATCH] fix(Python-Interpreter): fix incorrect file read method (#2970) fix getting file by property(Sync) in an async handler #2960 --- packages/python_interpreter/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/python_interpreter/main.py b/packages/python_interpreter/main.py index b63885634..505b57903 100644 --- a/packages/python_interpreter/main.py +++ b/packages/python_interpreter/main.py @@ -205,13 +205,14 @@ class Main(star.Star): return for comp in event.message_obj.message: if isinstance(comp, File): - if comp.file.startswith("http"): + file_path = await comp.get_file() + if file_path.startswith("http"): name = comp.name if comp.name else uuid.uuid4().hex[:8] temp_dir = os.path.join(get_astrbot_data_path(), "temp") path = os.path.join(temp_dir, name) - await download_file(comp.file, path) + await download_file(file_path, path) else: - path = comp.file + path = file_path self.user_file_msg_buffer[event.get_session_id()].append(path) logger.debug(f"User {uid} uploaded file: {path}") yield event.plain_result(f"代码执行器: 文件已经上传: {path}")