From e04b6230c6aaf0b0dabcb53f1eaf5a10678b1b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Wed, 21 Jan 2026 17:06:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=80=E5=90=8E=E4=B8=80=E6=9D=A1=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/code1.py | 3 +-- xiaomusic/command_handler.py | 3 ++- xiaomusic/xiaomusic.py | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/code1.py b/plugins/code1.py index be4fc6c..eb2be3f 100644 --- a/plugins/code1.py +++ b/plugins/code1.py @@ -4,6 +4,5 @@ async def code1(arg1): did = xiaomusic.get_cur_did() await xiaomusic.do_tts(did, "你好,我是自定义的测试口令") - last_record = xiaomusic.conversation_poller.last_record - query = last_record.get("query", "").strip() + query = xiaomusic.command_handler.last_cmd.strip() await xiaomusic.do_tts(did, f"你说的是: {query}") diff --git a/xiaomusic/command_handler.py b/xiaomusic/command_handler.py index 66e88bc..ce9afe2 100644 --- a/xiaomusic/command_handler.py +++ b/xiaomusic/command_handler.py @@ -31,6 +31,7 @@ class CommandHandler: self.log = log self.xiaomusic = xiaomusic_instance self.active_cmd = config.active_cmd.split(",") if config.active_cmd else [] + self.last_cmd = "" async def do_check_cmd(self, did="", query="", ctrl_panel=True, **kwargs): """检查并执行命令 @@ -50,7 +51,7 @@ class CommandHandler: self.log.info(f"收到消息:{query} 控制面板:{ctrl_panel} did:{did}") # 记录最后一条命令 - self.xiaomusic.last_cmd = query + self.last_cmd = query try: # 匹配命令 diff --git a/xiaomusic/xiaomusic.py b/xiaomusic/xiaomusic.py index f307159..c3e99de 100644 --- a/xiaomusic/xiaomusic.py +++ b/xiaomusic/xiaomusic.py @@ -35,8 +35,6 @@ class XiaoMusic: def __init__(self, config: Config): self.config = config - self.last_cmd = "" # <--- 【新增这行】初始化变量 - # 初始化事件总线 self.event_bus = EventBus()