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

coreplugin: use irc.isServiceBot() for kill, kick, & message handlers

This commit is contained in:
James Lu 2016-05-14 16:23:14 -07:00
parent 5d4765b30d
commit 1816de307d

View File

@ -40,9 +40,9 @@ signal.signal(signal.SIGTERM, sigterm_handler)
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']
for name, sbot in world.services.items(): sbot = irc.isServiceBot(target)
if target == sbot.uids.get(irc.name): if sbot:
spawn_service(irc, source, command, {'name': name}) spawn_service(irc, source, command, {'name': sbot.name})
return return
utils.add_hook(handle_kill, 'KILL') utils.add_hook(handle_kill, 'KILL')
@ -50,7 +50,7 @@ def handle_kick(irc, source, command, args):
"""Handle KICKs to the PyLink service bots, rejoining channels as needed.""" """Handle KICKs to the PyLink service bots, rejoining channels as needed."""
kicked = args['target'] kicked = args['target']
channel = args['channel'] channel = args['channel']
if kicked in [sbot.uids.get(irc.name) for sbot in world.services.values()]: if irc.isServiceBot(kicked):
irc.proto.join(kicked, channel) irc.proto.join(kicked, channel)
utils.add_hook(handle_kick, 'KICK') utils.add_hook(handle_kick, 'KICK')
@ -59,10 +59,9 @@ def handle_commands(irc, source, command, args):
target = args['target'] target = args['target']
text = args['text'] text = args['text']
for sbot in world.services.values(): sbot = irc.isServiceBot(target)
if target == sbot.uids.get(irc.name): if sbot:
sbot.call_cmd(irc, source, text) sbot.call_cmd(irc, source, text)
return
utils.add_hook(handle_commands, 'PRIVMSG') utils.add_hook(handle_commands, 'PRIVMSG')