Browse Source

Merge #157: Fix bug in IRC nick collision handling

ec60bcd Fix bug in IRC nick collision handling. (Adam Gibson)
master
AdamISZ 8 years ago
parent
commit
bfc1045dc8
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 27
      jmdaemon/jmdaemon/irc.py

27
jmdaemon/jmdaemon/irc.py

@ -27,8 +27,12 @@ log = get_log()
def wlog(*x): def wlog(*x):
"""Simplifier to add lists to the debug log """Simplifier to add lists to the debug log
""" """
msg = " ".join([str(a) for a in x]) if x[0] == "WARNING":
log.debug(msg) msg = " ".join([str(a) for a in x[1:]])
log.warn(msg)
else:
msg = " ".join([str(a) for a in x])
log.debug(msg)
def get_irc_text(line): def get_irc_text(line):
return line[line[1:].find(':') + 2:] return line[line[1:].find(':') + 2:]
@ -310,15 +314,20 @@ class txIRC_Client(irc.IRCClient, object):
pass pass
#wlog('unhandled action: ', user, channel, msg) #wlog('unhandled action: ', user, channel, msg)
def alterCollidedNick(self, nickname): def irc_ERR_NICKNAMEINUSE(self, prefix, params):
""" """
Generate an altered version of a nickname that caused a collision in an Called when we try to register or change to a nickname that is already
effort to create an unused related name for subsequent registration. taken.
:param nickname: This is overriden from base class to insist on retrying with the same
nickname, after a hardcoded 10s timeout. The user is amply warned at
WARNING logging level, and can just restart if they are around to see it.
""" """
newnick = nickname + '_' wlog("WARNING", "Your nickname is in use. This usually happens "
wlog('nickname collision, changed to ', newnick) "as a result of a network failure. You are recommended to "
return newnick "restart, otherwise you should regain your nick after "
"some time. This is not a security risk, but you may lose "
"access to coinjoins during this period.")
reactor.callLater(10.0, self.setNick, self._attemptedNick)
def modeChanged(self, user, channel, _set, modes, args): def modeChanged(self, user, channel, _set, modes, args):
pass pass

Loading…
Cancel
Save