mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
utils: add unregisterService
This commit is contained in:
parent
8f14e02f10
commit
5122aa8f9a
10
utils.py
10
utils.py
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user