3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

unreal: refactor to use utils.PUIDGenerator

Closes #238.
This commit is contained in:
James Lu 2016-07-28 21:59:56 -07:00
parent 852bd74c3b
commit 87c558537f
2 changed files with 5 additions and 6 deletions

View File

@ -296,8 +296,8 @@ class UnrealProtocol(TS6BaseProtocol):
ts = self.irc.start_ts ts = self.irc.start_ts
self.irc.prefixmodes = {'q': '~', 'a': '&', 'o': '@', 'h': '%', 'v': '+'} self.irc.prefixmodes = {'q': '~', 'a': '&', 'o': '@', 'h': '%', 'v': '+'}
# Track usages of legacy nicks. # Track usages of legacy (Unreal 3.2) nicks.
self.legacy_nickcount = 1 self.legacy_uidgen = utils.PUIDGenerator('U32user')
self.irc.umodes.update({'deaf': 'd', 'invisible': 'i', 'hidechans': 'p', self.irc.umodes.update({'deaf': 'd', 'invisible': 'i', 'hidechans': 'p',
'protected': 'q', 'registered': 'r', 'protected': 'q', 'registered': 'r',
@ -605,8 +605,7 @@ class UnrealProtocol(TS6BaseProtocol):
servername = new_args[5].lower() # Get the name of the users' server. servername = new_args[5].lower() # Get the name of the users' server.
# Fake a UID and put it where it belongs in the new-style UID command. # Fake a UID and put it where it belongs in the new-style UID command.
fake_uid = '%s@%s' % (args[0], self.legacy_nickcount) fake_uid = self.legacy_uidgen.next_uid(prefix=args[0])
self.legacy_nickcount += 1
new_args[5] = fake_uid new_args[5] = fake_uid
# Insert a fake cloaked host (just make it equal the real host, I don't care) # Insert a fake cloaked host (just make it equal the real host, I don't care)

View File

@ -73,11 +73,11 @@ class PUIDGenerator():
self.prefix = prefix self.prefix = prefix
self.counter = 0 self.counter = 0
def next_uid(self): def next_uid(self, prefix=''):
""" """
Generates the next PUID. Generates the next PUID.
""" """
uid = '%s@%s' % (self.prefix, self.counter) uid = '%s@%s' % (prefix or self.prefix, self.counter)
self.counter += 1 self.counter += 1
return uid return uid
next_sid = next_uid next_sid = next_uid