Change user.hostmasks to an IrcSet

This commit is contained in:
James Vega 2004-10-26 17:37:44 +00:00
parent 7c8882e30e
commit ca0c0fad49
2 changed files with 7 additions and 7 deletions

View File

@ -240,11 +240,11 @@ class User(callbacks.Privmsg):
try: try:
s = '' s = ''
if hostmask == 'all': if hostmask == 'all':
user.hostmasks[:] = [] user.hostmasks.clear()
s = 'All hostmasks removed.' s = 'All hostmasks removed.'
else: else:
user.removeHostmask(hostmask) user.removeHostmask(hostmask)
except ValueError: except KeyError:
irc.error('There was no such hostmask.') irc.error('There was no such hostmask.')
return return
ircdb.users.setUser(user) ircdb.users.setUser(user)

View File

@ -220,7 +220,7 @@ class IrcUser(object):
for capability in capabilities: for capability in capabilities:
self.capabilities.add(capability) self.capabilities.add(capability)
if hostmasks is None: if hostmasks is None:
self.hostmasks = [] # A list of hostmasks used for recognition self.hostmasks = ircutils.IrcSet() # hostmasks used for recognition
else: else:
self.hostmasks = hostmasks self.hostmasks = hostmasks
@ -296,11 +296,11 @@ class IrcUser(object):
if len(unWildcardHostmask(hostmask)) < 8: if len(unWildcardHostmask(hostmask)) < 8:
raise ValueError, \ raise ValueError, \
'Hostmask must contain at least 8 non-wildcard characters.' 'Hostmask must contain at least 8 non-wildcard characters.'
self.hostmasks.append(hostmask) self.hostmasks.add(hostmask)
def removeHostmask(self, hostmask): def removeHostmask(self, hostmask):
"""Removes a hostmask from the user's hostmasks.""" """Removes a hostmask from the user's hostmasks."""
self.hostmasks = [s for s in self.hostmasks if s != hostmask] self.hostmasks.remove(hostmask)
def addAuth(self, hostmask): def addAuth(self, hostmask):
"""Sets a user's authenticated hostmask. This times out in 1 hour.""" """Sets a user's authenticated hostmask. This times out in 1 hour."""
@ -496,7 +496,7 @@ class IrcUserCreator(Creator):
def hostmask(self, rest, lineno): def hostmask(self, rest, lineno):
self._checkId() self._checkId()
self.u.hostmasks.append(rest) self.u.hostmasks.add(rest)
def capability(self, rest, lineno): def capability(self, rest, lineno):
self._checkId() self._checkId()
@ -512,7 +512,7 @@ class IrcUserCreator(Creator):
# Some might argue that this is arbitrary, and perhaps it is. # Some might argue that this is arbitrary, and perhaps it is.
# But we've got to do *something*, so we'll show some deference # But we've got to do *something*, so we'll show some deference
# to our lower-numbered users. # to our lower-numbered users.
self.u.hostmasks[:] = [] self.u.hostmasks.clear()
self.users.setUser(self.u) self.users.setUser(self.u)
IrcUserCreator.u = None IrcUserCreator.u = None