From 5122aa8f9ac928473e58815e370b20fef7f01635 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 14 May 2016 14:52:12 -0700 Subject: [PATCH] utils: add unregisterService --- utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils.py b/utils.py index ebed292..c53cea1 100644 --- a/utils.py +++ b/utils.py @@ -280,6 +280,7 @@ class ServiceBot(): self.reply(irc, 'To see help on a specific command, type \x02help \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]