3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-22 16:30:42 +01:00

proto.py: add kill handler & autorejoin on kick/kill

Closes #19.
This commit is contained in:
James Lu 2015-06-07 18:08:25 -07:00
parent 38df372471
commit 46095574be

View File

@ -37,7 +37,7 @@ def joinClient(irc, client, channel):
def removeClient(irc, numeric): def removeClient(irc, numeric):
"""<irc object> <client numeric> """<irc object> <client numeric>
Removes a client from our internal databases, regardless Removes a client from our internal databases, regardless
of whether it's one of our pseudoclients or not.""" of whether it's one of our pseudoclients or not."""
for k, v in copy(irc.channels).items(): for k, v in copy(irc.channels).items():
@ -100,11 +100,20 @@ def handle_privmsg(irc, source, command, args):
msg(irc, source, 'Uncaught exception in command %r: %s: %s' % (cmd, type(e).__name__, str(e))) msg(irc, source, 'Uncaught exception in command %r: %s: %s' % (cmd, type(e).__name__, str(e)))
return return
def handle_kill(irc, source, command, args):
killed = args[0]
removeClient(irc, killed)
if killed == irc.pseudoclient.uid:
irc.pseudoclient = spawnClient(irc, 'PyLink', 'pylink', irc.serverdata["hostname"])
joinClient(irc, irc.pseudoclient, ','.join(irc.serverdata['channels']))
def handle_kick(irc, source, command, args): def handle_kick(irc, source, command, args):
# :70MAAAAAA KICK #endlessvoid 70MAAAAAA :some reason # :70MAAAAAA KICK #endlessvoid 70MAAAAAA :some reason
channel = args[0] channel = args[0]
kicked = args[1] kicked = args[1]
irc.channels[channel].users.discard(kicked) irc.channels[channel].users.discard(kicked)
if kicked == irc.pseudoclient.uid:
joinClient(irc, irc.pseudoclient, channel)
def handle_part(irc, source, command, args): def handle_part(irc, source, command, args):
channel = args[0] channel = args[0]