3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 20:22:45 +01:00

relay: initial nick collision handling via SAVE (Closes #61)

This commit is contained in:
James Lu 2015-07-20 14:37:04 -07:00
parent ad34f6c4f9
commit 65ef27fd4b

View File

@ -803,6 +803,21 @@ def handle_disconnect(irc, numeric, command, args):
utils.add_hook(handle_disconnect, "PYLINK_DISCONNECT") utils.add_hook(handle_disconnect, "PYLINK_DISCONNECT")
def handle_save(irc, numeric, command, args):
# Nick collision! Try to change our nick to the next available normalized
# nick.
target = args['target']
if utils.isInternalClient(irc, target):
realuser = getLocalUser(irc, target)
if realuser is None:
return
remotenet, remoteuser = realuser
remoteirc = utils.networkobjects[remotenet]
nick = remoteirc.users[remoteuser].nick
newnick = normalizeNick(irc, remotenet, nick)
irc.proto.nickClient(irc, target, newnick)
utils.add_hook(handle_save, "SAVE")
@utils.add_cmd @utils.add_cmd
def linked(irc, source, args): def linked(irc, source, args):
"""takes no arguments. """takes no arguments.