From 59e5001e47d220164ae6ead9e28fee1bd7cdc374 Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 27 Nov 2025 17:16:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=A0=E9=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/xiuxian/main.py | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/plugins/xiuxian/main.py b/plugins/xiuxian/main.py index bfd9c4f..fa74ce6 100644 --- a/plugins/xiuxian/main.py +++ b/plugins/xiuxian/main.py @@ -1740,7 +1740,45 @@ class XiuxianPlugin(MessagePluginInterface): return False, "劫掠失败" - async def _cmd_give_stone(self, bot: WechatAPIClient, sender: str, roomid: str, content: str) -> Tuple[bool, str]: + async def _cmd_give_stone(self, bot: WechatAPIClient, sender: str, roomid: str, content: str, message: Dict[str, Any]) -> Tuple[bool, str]: + msg = message.get("full_wx_msg") + xml = getattr(msg, "msg_source", None) if msg else None + target_wxid = None + if roomid and xml: + try: + import xml.etree.ElementTree as ET + import re + root = ET.fromstring(xml) + at_el = root.find('.//atuserlist') + text = (at_el.text if at_el is not None else '').strip() + text = text.strip(',') + text = re.sub(r'[\\s\\u3000]+', '', text) + at_set = set(text.split(',')) + at_set.discard('') + if len(at_set) != 1: + await self._send_text_with_status(bot, sender, roomid, "请@一个明确的目标进行赠与", 90) + return False, "目标无效" + target_wxid = next(iter(at_set)) + tokens = [t for t in content.strip().split() if not t.startswith('@')] + if len(tokens) < 1: + return False, "道友施法有误,指令格式不对" + try: + qty = int(tokens[0]) + except Exception: + return False, "道友施法有误,指令格式不对" + except Exception: + pass + if not target_wxid: + parts = content.strip().split() + if len(parts) < 2: + await self._send_text_with_status(bot, sender, roomid, "格式:赠与 目标 数量", 90) + return False, "命令格式错误" + target_wxid = parts[0].lstrip("@") + try: + qty = int(parts[1]) + except Exception: + await self._send_text_with_status(bot, sender, roomid, "格式:赠与 目标 数量", 90) + return False, "命令格式错误" parts = content.strip().split() if len(parts) < 2: await self._send_text_with_status(bot, sender, roomid, "格式:赠与 目标 数量", 90)