mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
Irc: add "was_successful" data key to PYLINK_DISCONNECT
This stores whether the network was actually connected before this disconnect message fired (i.e. the disconnect wasn't caused by a configuration error, etc.)
This commit is contained in:
parent
cd3d795296
commit
b30d696e3a
@ -192,6 +192,7 @@ class Irc():
|
||||
ip = self.serverdata["ip"]
|
||||
port = self.serverdata["port"]
|
||||
checks_ok = True
|
||||
errored = False
|
||||
try:
|
||||
# Set the socket type (IPv6 or IPv4).
|
||||
stype = socket.AF_INET6 if self.serverdata.get("ipv6") else socket.AF_INET
|
||||
@ -317,11 +318,12 @@ class Irc():
|
||||
# exception, meaning we've disconnected!
|
||||
log.error('(%s) Disconnected from IRC: %s: %s',
|
||||
self.name, type(e).__name__, str(e))
|
||||
errored = True
|
||||
|
||||
self.disconnect()
|
||||
|
||||
# Internal hook signifying that a network has disconnected.
|
||||
self.callHooks([None, 'PYLINK_DISCONNECT', {}])
|
||||
self.callHooks([None, 'PYLINK_DISCONNECT', {'was_successful': checks_ok and not errored}])
|
||||
|
||||
# If autoconnect is enabled, loop back to the start. Otherwise,
|
||||
# return and stop.
|
||||
|
Loading…
Reference in New Issue
Block a user