3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

control/utils: unload the PyLink service bot on shutdown

This commit is contained in:
James Lu 2016-07-26 16:26:01 -07:00
parent a4dbd8d09f
commit 0d563eaa57
2 changed files with 10 additions and 1 deletions

View File

@ -25,6 +25,9 @@ def _shutdown(irc=None):
except: # But don't allow it to crash the server.
log.exception('coremods.control: Error occurred in die() of plugin %s, skipping...', name)
# Remove our main PyLink bot as well.
utils.unregisterService('pylink')
for ircobj in world.networkobjects.copy().values():
# Disconnect all our networks.
remove_network(ircobj)

View File

@ -383,6 +383,12 @@ def unregisterService(name):
name = name.lower()
sbot = world.services[name]
for ircnet, uid in sbot.uids.items():
world.networkobjects[ircnet].proto.quit(uid, "Service unloaded.")
ircobj = world.networkobjects[ircnet]
# Special case for the main PyLink client. If we're unregistering that,
# clear the irc.pseudoclient entry.
if name == 'pylink':
ircobj.pseudoclient = None
ircobj.proto.quit(uid, "Service unloaded.")
del world.services[name]