From cffbd959e8e3db90d353d28c85720d6d61ae4d44 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 26 Mar 2015 01:33:04 -0400 Subject: [PATCH] Add handling of 437 (nick temporarily unavailable) errors Servers bind a nick to a connection for a short window after it disappears to try and avoid contention over nicks. This may cause a 437 during connection to a server (c.f. ProgVal/Limnoria#1033) or even during normal nick changes, if the timing is lucky. Add handling for this error to the startup code and the Admin plugin. Signed-off-by: James McCoy --- plugins/Admin/plugin.py | 12 +++++++++++- src/irclib.py | 5 ++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/Admin/plugin.py b/plugins/Admin/plugin.py index 4f5abb728..71775a7ad 100644 --- a/plugins/Admin/plugin.py +++ b/plugins/Admin/plugin.py @@ -49,8 +49,8 @@ class Admin(callbacks.Plugin): def do437(self, irc, msg): """Nick/channel temporarily unavailable.""" target = msg.args[0] + t = time.time() + 30 if irc.isChannel(target): # We don't care about nicks. - t = time.time() + 30 # Let's schedule a rejoin. networkGroup = conf.supybot.networks.get(irc.network) def rejoin(): @@ -60,6 +60,16 @@ class Admin(callbacks.Plugin): schedule.addEvent(rejoin, t) self.log.info('Scheduling a rejoin to %s at %s; ' 'Channel temporarily unavailable.', target, t) + else: + irc = self.pendingNickChanges.get(irc, None) + if irc is not None: + def nick(): + irc.queueMsg(ircmsgs.nick(target)) + schedule.addEvent(nick, t) + self.log.info('Scheduling a nick change to %s at %s; ' + 'Nick temporarily unavailable.', target, t) + else: + self.log.debug('Got 437 without Admin.nick being called.') def do471(self, irc, msg): try: diff --git a/src/irclib.py b/src/irclib.py index 27c373c1a..41a141136 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -939,8 +939,11 @@ class Irc(IrcCommandDispatcher): if not self.afterConnect: newNick = self._getNextNick() assert newNick != self.nick - log.info('Got 433: %s %s. Trying %s.',self.nick, problem, newNick) + log.info('Got %s: %s %s. Trying %s.', + msg.command, self.nick, problem, newNick) self.sendMsg(ircmsgs.nick(newNick)) + def do437(self, msg): + self.do43x(msg, 'is temporarily unavailable') def do433(self, msg): self.do43x(msg, 'is in use') def do432(self, msg):