mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
utils: tweak TS6UIDGenerator again
Only increment the UID table after we fetch the UID, so that the initial value (AAAAAA) gets used too.
This commit is contained in:
parent
6a69ed0459
commit
f37af68e3f
9
utils.py
9
utils.py
@ -12,10 +12,10 @@ class TS6UIDGenerator():
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# TS6 UIDs are 6 characters in length (9 including the SID).
|
# TS6 UIDs are 6 characters in length (9 including the SID).
|
||||||
# They wrap from ABCDEFGHIJKLMNOPQRSTUVWXYZ -> 1234567890 -> wrap around:
|
# They wrap from ABCDEFGHIJKLMNOPQRSTUVWXYZ -> 0123456789 -> wrap around:
|
||||||
# (e.g. AAAAAA, AAAAAB ..., AAAAA8, AAAAA9, AAAAB0)
|
# (e.g. AAAAAA, AAAAAB ..., AAAAA8, AAAAA9, AAAABA)
|
||||||
self.allowedchars = string.ascii_uppercase + string.digits
|
self.allowedchars = string.ascii_uppercase + string.digits
|
||||||
self.uidchars = [self.allowedchars[-1]]*6
|
self.uidchars = [self.allowedchars[0]]*6
|
||||||
|
|
||||||
def increment(self, pos=5):
|
def increment(self, pos=5):
|
||||||
# If we're at the last character in the list of allowed ones, reset
|
# 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]
|
self.uidchars[pos] = self.allowedchars[idx+1]
|
||||||
|
|
||||||
def next_uid(self, sid):
|
def next_uid(self, sid):
|
||||||
|
uid = sid + ''.join(self.uidchars)
|
||||||
self.increment()
|
self.increment()
|
||||||
return sid + ''.join(self.uidchars)
|
return uid
|
||||||
|
|
||||||
def msg(irc, target, text, notice=False):
|
def msg(irc, target, text, notice=False):
|
||||||
command = 'NOTICE' if notice else 'PRIVMSG'
|
command = 'NOTICE' if notice else 'PRIVMSG'
|
||||||
|
Loading…
Reference in New Issue
Block a user