From 8c2e9ccb391fc6e24a8ca762c341a3793275355c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 6 Mar 2014 20:21:10 -0800 Subject: [PATCH] irkerd: Replace 'namestyle' global with local 'nick_template' Using the new kwargs handling to pass the data through Irker() down to Connection(). I think 'nick_template' more clearly reflects the contents of this variable. --- irkerd | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/irkerd b/irkerd index 6d068ad..f3ee58d 100755 --- a/irkerd +++ b/irkerd @@ -380,9 +380,11 @@ def is_channel(string): return string and string[0] in "#&+!" class Connection: - def __init__(self, irker, target, nick_needs_number=False, **kwargs): + def __init__(self, irker, target, nick_template, nick_needs_number=False, + **kwargs): self.irker = irker self.target = target + self.nick_template = nick_template self.nick_needs_number = nick_needs_number self.kwargs = kwargs self.nick_trial = None @@ -400,9 +402,9 @@ class Connection: if n is None: n = self.nick_trial if self.nick_needs_number: - return (namestyle % n) + return (self.nick_template % n) else: - return namestyle + return self.nick_template def handle_ping(self): "Register the fact that the server has pinged this connection." self.last_ping = time.time() @@ -890,7 +892,7 @@ Options if __name__ == '__main__': log_level = None immediate = None - namestyle = "irker%03d" + nick_template = "irker%03d" password = None logfile = None try: @@ -911,7 +913,7 @@ if __name__ == '__main__': elif opt == '-l': # Logfile mode - report traffic read in logfile = val elif opt == '-n': # Force the nick - namestyle = val + nick_template = val elif opt == '-p': # Set a nickserv password password = val elif opt == '-V': # Emit version and exit @@ -927,7 +929,8 @@ if __name__ == '__main__': LOG.setLevel(log_level) irker = Irker( - nick_needs_number=re.search("%.*d", namestyle), + nick_template=nick_template, + nick_needs_number=re.search("%.*d", nick_template), ) LOG.info("irkerd version %s" % version) if immediate: -- 2.26.2