txlyre 16 hours ago
parent
commit
17aaf6e9d5
1 changed files with 15 additions and 0 deletions
  1. 15 0
      openkriemy.py

+ 15 - 0
openkriemy.py

@@ -1,3 +1,4 @@
+import re
 from random import random, randint
 from random import random, randint
 from asyncio import sleep
 from asyncio import sleep
 from datetime import datetime, timedelta, date, time
 from datetime import datetime, timedelta, date, time
@@ -77,6 +78,20 @@ async def on_message(event):
     try:
     try:
         command = parse_command(text)
         command = parse_command(text)
     except ValueError:
     except ValueError:
+        if chess and event.sender.id in chess.sessions:
+            reply = await event.get_reply_message()
+            if reply and get_peer_id(reply.from_id) == await bot.get_peer_id("me") and reply.media:
+                text = text.strip().lower()
+
+                if re.match(r"^[a-h][1-8][a-h][1-8]$", text):
+                    text = f"/chess m {text}"
+                else:
+                    text = f"/chess {text}"
+
+                await COMMANDS["chess"](bot, event, parse_command(text))
+
+                return
+
         if await is_markov_enabled(peer_id):
         if await is_markov_enabled(peer_id):
             markov.extend_corpus(text)
             markov.extend_corpus(text)