From f37af68e3f0fdd66e737ced63cd876020082641f Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 21 Jun 2015 18:11:17 -0700 Subject: [PATCH] utils: tweak TS6UIDGenerator again Only increment the UID table after we fetch the UID, so that the initial value (AAAAAA) gets used too. --- utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils.py b/utils.py index 01029ab..0a0031d 100644 --- a/utils.py +++ b/utils.py @@ -12,10 +12,10 @@ class TS6UIDGenerator(): def __init__(self): # TS6 UIDs are 6 characters in length (9 including the SID). - # They wrap from ABCDEFGHIJKLMNOPQRSTUVWXYZ -> 1234567890 -> wrap around: - # (e.g. AAAAAA, AAAAAB ..., AAAAA8, AAAAA9, AAAAB0) + # They wrap from ABCDEFGHIJKLMNOPQRSTUVWXYZ -> 0123456789 -> wrap around: + # (e.g. AAAAAA, AAAAAB ..., AAAAA8, AAAAA9, AAAABA) self.allowedchars = string.ascii_uppercase + string.digits - self.uidchars = [self.allowedchars[-1]]*6 + self.uidchars = [self.allowedchars[0]]*6 def increment(self, pos=5): # If we're at the last character in the list of allowed ones, reset @@ -30,8 +30,9 @@ class TS6UIDGenerator(): self.uidchars[pos] = self.allowedchars[idx+1] def next_uid(self, sid): + uid = sid + ''.join(self.uidchars) self.increment() - return sid + ''.join(self.uidchars) + return uid def msg(irc, target, text, notice=False): command = 'NOTICE' if notice else 'PRIVMSG'