From 95f9109de6d68add9eea72c691fc16b4987836ae Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 6 Mar 2014 20:21:09 -0800 Subject: [PATCH] irkerd: Replace 'fallback' global with local 'nick_needs_number' Using the new kwargs handling to pass the data through Irker() down to Connection(). --- irkerd | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/irkerd b/irkerd index 824dae6..6d068ad 100755 --- a/irkerd +++ b/irkerd @@ -380,9 +380,10 @@ def is_channel(string): return string and string[0] in "#&+!" class Connection: - def __init__(self, irker, target, **kwargs): + def __init__(self, irker, target, nick_needs_number=False, **kwargs): self.irker = irker self.target = target + self.nick_needs_number = nick_needs_number self.kwargs = kwargs self.nick_trial = None self.connection = None @@ -398,7 +399,7 @@ class Connection: "Return a name for the nth server connection." if n is None: n = self.nick_trial - if fallback: + if self.nick_needs_number: return (namestyle % n) else: return namestyle @@ -414,7 +415,7 @@ class Connection: def handle_badnick(self): "The server says our nick is ill-formed or has a conflict." LOG.info("nick %s rejected" % self.nickname()) - if fallback: + if self.nick_needs_number: # Randomness prevents a malicious user or bot from # anticipating the next trial name in order to block us # from completing the handshake. @@ -925,8 +926,9 @@ if __name__ == '__main__': if log_level: LOG.setLevel(log_level) - fallback = re.search("%.*d", namestyle) - irker = Irker() + irker = Irker( + nick_needs_number=re.search("%.*d", namestyle), + ) LOG.info("irkerd version %s" % version) if immediate: irker.irc.add_event_handler("quit", lambda _c, _e: sys.exit(0)) -- 2.26.2