3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 12:12:53 +01:00

Irc: catch AttributeError when self.socket doesn't exist (failed to establish initial connection)

This commit is contained in:
James Lu 2015-07-18 20:10:33 -07:00
parent 024ac165a8
commit b6275130e1

View File

@ -160,8 +160,12 @@ class Irc():
# treated as a separate command, which is particularly nasty.
data = data.replace('\n', ' ')
data = data.encode("utf-8") + b"\n"
log.debug("(%s) -> %s", self.name, data.decode("utf-8").strip("\n"))
stripped_data = data.decode("utf-8").strip("\n")
log.debug("(%s) -> %s", self.name, stripped_data)
try:
self.socket.send(data)
except AttributeError:
log.debug("(%s) Dropping message %r; network isn't connected!", self.name, stripped_data)
def schedulePing(self):
self.proto.pingServer(self)