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 <vega.james@gmail.com>
This commit is contained in:
James McCoy 2015-03-26 01:33:04 -04:00
parent c3695c9419
commit cffbd959e8
No known key found for this signature in database
GPG Key ID: DFE691AE331BA3DB
2 changed files with 15 additions and 2 deletions

View File

@ -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:

View File

@ -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):