IrcClient.py:IrcClient.{queue,unqueue}(): always CR NL-terminate messages & encode() before queuing.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-01-03 15:18:28 +01:00
parent 9c34fe3220
commit b71ca6af89

View File

@ -95,13 +95,12 @@ class IrcClient:
msg += ":" + args[argNum] msg += ":" + args[argNum]
else: else:
msg += args[argNum] + " " msg += args[argNum] + " "
self.clientQueue.append(msg) self.clientQueue.append((msg + "\r\n").encode())
# }}} # }}}
# {{{ unqueue(): Send all queued lines to server, honouring timers # {{{ unqueue(): Send all queued lines to server, honouring timers
def unqueue(self): def unqueue(self):
while self.clientQueue: while self.clientQueue:
msg = self.clientQueue[0] msg = self.clientQueue[0]; msgLen = len(msg); msgBytesSent = 0;
msg = (msg + "\r\n").encode(); msgLen = len(msg); msgBytesSent = 0;
while msgBytesSent < msgLen: while msgBytesSent < msgLen:
if self.clientNextTimeout: if self.clientNextTimeout:
timeNow = time.time() timeNow = time.time()