|
@@ -685,7 +685,7 @@ def chess_game_over(chess, id, e):
|
|
|
|
|
|
async def chess_from_handler(chess, id, moves):
|
|
async def chess_from_handler(chess, id, moves):
|
|
try:
|
|
try:
|
|
- await chess.begin(id, moves)
|
|
|
|
|
|
+ await chess.begin(id, moves, strict=not isinstance(id, str))
|
|
except GameOver as e:
|
|
except GameOver as e:
|
|
return chess_game_over(chess, id, e)
|
|
return chess_game_over(chess, id, e)
|
|
except IllegalMove as e:
|
|
except IllegalMove as e:
|
|
@@ -839,6 +839,7 @@ CHESS_COMMANDS = {
|
|
"moves": (chess_moves_handler, "Показать историю ходов и состояние игры", 0),
|
|
"moves": (chess_moves_handler, "Показать историю ходов и состояние игры", 0),
|
|
|
|
|
|
"create": (chess_start_handler, "Создать общую доску", 0),
|
|
"create": (chess_start_handler, "Создать общую доску", 0),
|
|
|
|
+ "createfrom": (chess_from_handler, "Создать общую доску в указанном состоянии", 1, True),
|
|
}
|
|
}
|
|
|
|
|
|
CHESS_ALIASES = {
|
|
CHESS_ALIASES = {
|
|
@@ -852,6 +853,7 @@ CHESS_ALIASES = {
|
|
"ms": "moves",
|
|
"ms": "moves",
|
|
"i": "moves",
|
|
"i": "moves",
|
|
"c": "create",
|
|
"c": "create",
|
|
|
|
+ "cf": "createfrom",
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -900,7 +902,7 @@ async def chess_handler(bot, event, command):
|
|
args = command.args[1:]
|
|
args = command.args[1:]
|
|
|
|
|
|
peer_id = str(get_peer_id(event.peer_id))
|
|
peer_id = str(get_peer_id(event.peer_id))
|
|
- result = await subcommand[0](bot.chess, peer_id if name == "create" or (peer_id in bot.chess.sessions and name not in ("start", "from")) else event.sender.id, *args)
|
|
|
|
|
|
+ result = await subcommand[0](bot.chess, peer_id if name in ("create", "createfrom") or (peer_id in bot.chess.sessions and name not in ("start", "from")) else event.sender.id, *args)
|
|
|
|
|
|
for reply in result:
|
|
for reply in result:
|
|
if isinstance(reply, bytes):
|
|
if isinstance(reply, bytes):
|