mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 11:39:25 +01:00
service_support: fix service respawn on KILL
(cherry picked from commit 7e51d3a7f5
)
This commit is contained in:
parent
bab6a71a2e
commit
5b73e0a691
@ -94,10 +94,18 @@ utils.add_hook(handle_endburst, 'ENDBURST')
|
|||||||
def handle_kill(irc, source, command, args):
|
def handle_kill(irc, source, command, args):
|
||||||
"""Handle KILLs to PyLink service bots, respawning them as needed."""
|
"""Handle KILLs to PyLink service bots, respawning them as needed."""
|
||||||
target = args['target']
|
target = args['target']
|
||||||
|
userdata = args.get('userdata')
|
||||||
sbot = irc.getServiceBot(target)
|
sbot = irc.getServiceBot(target)
|
||||||
if sbot:
|
servicename = None
|
||||||
spawn_service(irc, source, command, {'name': sbot.name})
|
|
||||||
return
|
if userdata and hasattr(userdata, 'service'): # Look for the target's service name attribute
|
||||||
|
servicename = userdata.service
|
||||||
|
elif sbot: # Or their service bot instance
|
||||||
|
servicename = sbot.name
|
||||||
|
if servicename:
|
||||||
|
log.debug('(%s) services_support: respawning service %s after KILL.', irc.name, servicename)
|
||||||
|
spawn_service(irc, source, command, {'name': servicename})
|
||||||
|
|
||||||
utils.add_hook(handle_kill, 'KILL')
|
utils.add_hook(handle_kill, 'KILL')
|
||||||
|
|
||||||
def handle_kick(irc, source, command, args):
|
def handle_kick(irc, source, command, args):
|
||||||
|
Loading…
Reference in New Issue
Block a user