txlyre 15 hours ago
parent
commit
cd4ed5ac24
1 changed files with 6 additions and 2 deletions
  1. 6 2
      commands.py

+ 6 - 2
commands.py

@@ -863,7 +863,7 @@ async def chess_anim_handler(chess, id, count):
     frames[0].save(fp=buffer, format="GIF", append_images=frames[1:], save_all=True, duration=500, loop=0)
     buffer.seek(0)
 
-    return [buffer.read()]
+    return [buffer]
 
 CHESS_COMMANDS = {
     "start": (chess_start_handler, "Начать новую игру", 0),
@@ -946,7 +946,11 @@ async def chess_handler(bot, event, command):
     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:
-        if isinstance(reply, bytes):
+        if isinstance(reply, BytesIO):
+            await bot.send_file(
+                event.peer_id, file=reply, reply_to=event, force_document=True
+            )
+        elif isinstance(reply, bytes):
             buffer = BytesIO()
             buffer.name = "board.png"
             buffer.write(reply)