修复未成功, 添加调试
This commit is contained in:
@@ -37,6 +37,10 @@ class GomokuGame(BaseGame):
|
||||
_, args = CommandParser.extract_command_args(command)
|
||||
args = args.strip()
|
||||
|
||||
# 调试日志
|
||||
logger.info(f"五子棋指令解析 - command: {command}")
|
||||
logger.info(f"五子棋指令解析 - args: {args}")
|
||||
|
||||
# 没有参数,显示帮助
|
||||
if not args:
|
||||
return self.get_help()
|
||||
@@ -44,6 +48,7 @@ class GomokuGame(BaseGame):
|
||||
# 解析参数
|
||||
parts = args.split(maxsplit=1)
|
||||
action = parts[0].lower()
|
||||
logger.info(f"五子棋指令解析 - action: {action}")
|
||||
|
||||
# 帮助
|
||||
if action in ['help', '帮助']:
|
||||
@@ -72,11 +77,13 @@ class GomokuGame(BaseGame):
|
||||
|
||||
# 尝试解析为@对手(开始游戏)
|
||||
opponent_id = self._parse_opponent(args)
|
||||
logger.info(f"五子棋指令解析 - opponent_id: {opponent_id}")
|
||||
if opponent_id is not None:
|
||||
return self._start_game(chat_id, user_id, opponent_id)
|
||||
|
||||
# 未识别的指令
|
||||
return f"❌ 未识别的指令\n\n{self.get_help()}"
|
||||
logger.warning(f"五子棋未识别的指令 - args: {args}")
|
||||
return f"❌ 未识别的指令:{args}\n\n💡 提示:\n- 要开始游戏,请使用 `.gomoku` 然后@对手\n- 要落子,请使用 `.gomoku A1`(坐标格式)\n- 要查看帮助,请使用 `.gomoku help`"
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"处理五子棋指令错误: {e}", exc_info=True)
|
||||
@@ -91,13 +98,23 @@ class GomokuGame(BaseGame):
|
||||
Returns:
|
||||
用户ID或None
|
||||
"""
|
||||
# WPS格式:<at user_id="123456"></at>
|
||||
match = re.search(r'<at\s+user_id="(\d+)"\s*></at>', args)
|
||||
if match:
|
||||
try:
|
||||
return int(match.group(1))
|
||||
except ValueError:
|
||||
pass
|
||||
# WPS格式:<at user_id="123456"></at> 或其他变体
|
||||
# 尝试多种格式
|
||||
patterns = [
|
||||
r'<at\s+user_id="(\d+)"[^>]*>', # <at user_id="123456"> 或 <at user_id="123456"></at>
|
||||
r'<at\s+user_id=\'(\d+)\'[^>]*>', # <at user_id='123456'>
|
||||
r'user_id="(\d+)"', # 直接查找 user_id="xxx"
|
||||
r'user_id=\'(\d+)\'', # 直接查找 user_id='xxx'
|
||||
]
|
||||
|
||||
for pattern in patterns:
|
||||
match = re.search(pattern, args)
|
||||
if match:
|
||||
try:
|
||||
return int(match.group(1))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
def _get_game_pool(self, chat_id: int) -> Dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user