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

utils: add unregisterService

This commit is contained in:
James Lu 2016-05-14 14:52:12 -07:00
parent 8f14e02f10
commit 5122aa8f9a

View File

@ -280,6 +280,7 @@ class ServiceBot():
self.reply(irc, 'To see help on a specific command, type \x02help <command>\x02.')
def registerService(name, *args, **kwargs):
"""Registers a service bot."""
name = name.lower()
if name in world.services:
raise ValueError("Service name %s is already bound!" % name)
@ -287,3 +288,12 @@ def registerService(name, *args, **kwargs):
world.services[name] = sbot = ServiceBot(name, *args, **kwargs)
sbot.spawn()
return sbot
def unregisterService(name):
"""Unregisters an existing service bot."""
assert name in world.services, "Unknown service %s" % name
sbot = world.services[name]
for ircnet, uid in sbot.uids.items():
world.networkobjects[ircnet].proto.quit(uid, "Service unloaded.")
del world.services[name]