irccex- fantasy cryptocurrency exchange for irc |
git clone git://git.acid.vegas/irccex.git |
Log | Files | Refs | Archive | README | LICENSE |
commit f2a6c8f217d01f6b1a206bdaec4d8ac6db895ccc
parent 98b10c89addb59797269ed54f174e202e29f571a Author: acidvegas <acid.vegas@acid.vegas> Date: Mon, 22 May 2023 17:33:41 -0400 Updated sock.recv & timeouts Diffstat:
|
1 file changed, 12 insertions(+), 2 deletions(-) |
diff --git a/irccex/core/irc.py b/irccex/core/irc.py @@ -77,10 +77,20 @@ class IRC(object): self.sock = ctx.wrap_socket(self.sock) def listen(self): + buffer = str() + last = time.time() while True: try: - data = self.sock.recv(2048).decode('utf-8') - for line in (line for line in data.split('\r\n') if line): + data = self.sock.recv(1024).decode('utf-8') + buffer += data + if data: + last = time.time() + else: + if time.time() - last > 120: + break + while '\r\n' in buffer: + line = buffer.split('\r\n')[0] + buffer = buffer.split('\r\n', 1)[1] print('[~] - ' + line) if len(line.split()) >= 2: Events.handle(line) |