From 65ef27fd4b3428adb07dd0f9299f44d42bfb6ba0 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 20 Jul 2015 14:37:04 -0700 Subject: [PATCH] relay: initial nick collision handling via SAVE (Closes #61) --- plugins/relay.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/relay.py b/plugins/relay.py index 799791e..caebae2 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -803,6 +803,21 @@ def handle_disconnect(irc, numeric, command, args): 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 def linked(irc, source, args): """takes no arguments.