mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +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"]
|
ip = self.serverdata["ip"]
|
||||||
port = self.serverdata["port"]
|
port = self.serverdata["port"]
|
||||||
checks_ok = True
|
checks_ok = True
|
||||||
|
errored = False
|
||||||
try:
|
try:
|
||||||
# Set the socket type (IPv6 or IPv4).
|
# Set the socket type (IPv6 or IPv4).
|
||||||
stype = socket.AF_INET6 if self.serverdata.get("ipv6") else socket.AF_INET
|
stype = socket.AF_INET6 if self.serverdata.get("ipv6") else socket.AF_INET
|
||||||
@ -317,11 +318,12 @@ class Irc():
|
|||||||
# exception, meaning we've disconnected!
|
# exception, meaning we've disconnected!
|
||||||
log.error('(%s) Disconnected from IRC: %s: %s',
|
log.error('(%s) Disconnected from IRC: %s: %s',
|
||||||
self.name, type(e).__name__, str(e))
|
self.name, type(e).__name__, str(e))
|
||||||
|
errored = True
|
||||||
|
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
|
||||||
# Internal hook signifying that a network has disconnected.
|
# 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,
|
# If autoconnect is enabled, loop back to the start. Otherwise,
|
||||||
# return and stop.
|
# return and stop.
|
||||||
|
Loading…
Reference in New Issue
Block a user