From 72b8c6274bde213479b306937cb9b2124ae4d34e Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 4 Jul 2024 16:00:43 +0300 Subject: [PATCH] Removed reading of incoming events bc why not --- async-bot.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/async-bot.py b/async-bot.py index 884897a..257a3c7 100644 --- a/async-bot.py +++ b/async-bot.py @@ -37,7 +37,6 @@ class AsyncBotManager: if a: self.difference[x + ox + (y + oy) * 1000] = l > 0 - async def listener(self): async with ClientSession() as http: async with http.get(f"{self.base}/api/initial-state") as req: @@ -75,16 +74,10 @@ class AsyncBotManager: async with AsyncSimpleClient(http_session=http) as sio: await sio.connect(f"{self.base}/socket.io") while not self._shutdown: - try: - event, data = await sio.receive(0.1) - if event not in ("full_state", "batched_bit_toggles"): - print(bot_index, "!!!", event, data) - except Exception: - pass - index, target = choice(list(self.difference.items())) + index, expected = choice(list(self.difference.items())) y, x = divmod(index, 1000) - curr = self.canvas.getpixel((x, y)) > 0 # type: ignore - if curr != target: + current = self.canvas.getpixel((x, y)) > 0 # type: ignore + if current != expected: print(bot_index, "swap", x, y) await sio.emit("toggle_bit", { "index": index