mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
TS6SIDGenerator: take an IRC object, and skip any SIDs that are currently in use
This commit is contained in:
parent
7e12ec9e5e
commit
e92f35018f
@ -24,7 +24,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
||||
self.hook_map = {'FJOIN': 'JOIN', 'RSQUIT': 'SQUIT', 'FMODE': 'MODE',
|
||||
'FTOPIC': 'TOPIC', 'OPERTYPE': 'MODE', 'FHOST': 'CHGHOST',
|
||||
'FIDENT': 'CHGIDENT', 'FNAME': 'CHGNAME'}
|
||||
self.sidgen = utils.TS6SIDGenerator(self.irc.serverdata["sidrange"])
|
||||
self.sidgen = utils.TS6SIDGenerator(self.irc)
|
||||
self.uidgen = {}
|
||||
|
||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
||||
|
@ -17,7 +17,7 @@ class TS6Protocol(TS6BaseProtocol):
|
||||
super(TS6Protocol, self).__init__(irc)
|
||||
self.casemapping = 'rfc1459'
|
||||
self.hook_map = {'SJOIN': 'JOIN', 'TB': 'TOPIC', 'TMODE': 'MODE', 'BMASK': 'MODE'}
|
||||
self.sidgen = utils.TS6SIDGenerator(self.irc.serverdata["sidrange"])
|
||||
self.sidgen = utils.TS6SIDGenerator(self.irc)
|
||||
self.uidgen = {}
|
||||
|
||||
def spawnClient(self, nick, ident='null', host='null', realhost=None, modes=set(),
|
||||
|
11
utils.py
11
utils.py
@ -56,8 +56,12 @@ class TS6SIDGenerator():
|
||||
"6##" would give: 600, 601, 602, ... 60Y, 60Z, 610, 611, ... 6ZZ (1296 total results)
|
||||
"""
|
||||
|
||||
def __init__(self, query):
|
||||
self.query = list(query)
|
||||
def __init__(self, irc):
|
||||
self.irc = irc
|
||||
try:
|
||||
self.query = query = list(irc.serverdata["sidrange"])
|
||||
except KeyError:
|
||||
raise RuntimeError('(%s) "sidrange" is missing from your server configuration block!' % irc.name)
|
||||
self.iters = self.query.copy()
|
||||
self.output = self.query.copy()
|
||||
self.allowedchars = {}
|
||||
@ -93,8 +97,9 @@ class TS6SIDGenerator():
|
||||
self.increment(pos-1)
|
||||
|
||||
def next_sid(self):
|
||||
while ''.join(self.output) in self.irc.servers:
|
||||
self.increment()
|
||||
sid = ''.join(self.output)
|
||||
self.increment()
|
||||
return sid
|
||||
|
||||
def add_cmd(func, name=None):
|
||||
|
Loading…
Reference in New Issue
Block a user