From ecbc21f907e4588309758effdbae91b7a6fb00f8 Mon Sep 17 00:00:00 2001 From: Firepup Sixfifty Date: Sun, 5 Nov 2023 16:26:50 -0600 Subject: [PATCH] Implement send and recv on bot class --- bot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index fbc33a2..ed19153 100644 --- a/bot.py +++ b/bot.py @@ -30,10 +30,16 @@ class bot: log(f"Start init for {server}", self.server) def send(self, command: str) -> int: - pass + return ircsock.send(bytes(command)) def recv(self) -> bytes: - pass + if self.queue: + return bytes(self.queue.pop(0)) + data = bytes(self.socket.recv(2048).strip(b"\r\n")) + if b"\r\n" in data: + self.queue.extend(data.split(b"\r\n")) + return bytes(self.queue.pop(0)) + return data def log(self, message: object) -> None: log(message, self.server)