mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-03 08:04:07 +01:00
parent
73c625a429
commit
f1ef6f9e15
17
main.py
17
main.py
@ -75,7 +75,7 @@ class Irc():
|
|||||||
self.socket.close()
|
self.socket.close()
|
||||||
autoconnect = self.serverdata.get('autoconnect')
|
autoconnect = self.serverdata.get('autoconnect')
|
||||||
if autoconnect is not None and autoconnect >= 0:
|
if autoconnect is not None and autoconnect >= 0:
|
||||||
log.warning('(%s) Going to auto-reconnect in %s seconds.', self.name, autoconnect)
|
log.info('(%s) Going to auto-reconnect in %s seconds.', self.name, autoconnect)
|
||||||
time.sleep(autoconnect)
|
time.sleep(autoconnect)
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
@ -92,11 +92,11 @@ class Irc():
|
|||||||
line, buf = buf.split('\n', 1)
|
line, buf = buf.split('\n', 1)
|
||||||
log.debug("(%s) <- %s", self.name, line)
|
log.debug("(%s) <- %s", self.name, line)
|
||||||
proto.handle_events(self, line)
|
proto.handle_events(self, line)
|
||||||
except (socket.error, classes.ProtocolError) as e:
|
except (socket.error, classes.ProtocolError, ConnectionError) as e:
|
||||||
log.error('(%s) Disconnected from IRC: %s: %s',
|
log.warning('(%s) Disconnected from IRC: %s: %s',
|
||||||
self.name, type(e).__name__, str(e))
|
self.name, type(e).__name__, str(e))
|
||||||
self.disconnect()
|
|
||||||
break
|
break
|
||||||
|
self.disconnect()
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
# Safeguard against newlines in input!! Otherwise, each line gets
|
# Safeguard against newlines in input!! Otherwise, each line gets
|
||||||
@ -104,7 +104,12 @@ class Irc():
|
|||||||
data = data.replace('\n', ' ')
|
data = data.replace('\n', ' ')
|
||||||
data = data.encode("utf-8") + b"\n"
|
data = data.encode("utf-8") + b"\n"
|
||||||
log.debug("(%s) -> %s", self.name, data.decode("utf-8").strip("\n"))
|
log.debug("(%s) -> %s", self.name, data.decode("utf-8").strip("\n"))
|
||||||
self.socket.send(data)
|
try:
|
||||||
|
self.socket.send(data)
|
||||||
|
except (socket.error, classes.ProtocolError, ConnectionError) as e:
|
||||||
|
log.warning('(%s) Disconnected from IRC: %s: %s',
|
||||||
|
self.name, type(e).__name__, str(e))
|
||||||
|
self.disconnect()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
log.info('PyLink starting...')
|
log.info('PyLink starting...')
|
||||||
|
Loading…
Reference in New Issue
Block a user