mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
Fixed to use supybot.databases.users.timeoutIdentification correctly.
This commit is contained in:
parent
ae97d0390a
commit
9dc2618232
78
src/ircdb.py
78
src/ircdb.py
@ -254,8 +254,13 @@ class IrcUser(object):
|
|||||||
authentication. If useAuth is False, only checks against the user's
|
authentication. If useAuth is False, only checks against the user's
|
||||||
hostmasks.
|
hostmasks.
|
||||||
"""
|
"""
|
||||||
if useAuth and self.auth and (hostmask == self.auth[1]):
|
if useAuth:
|
||||||
return True
|
if self.auth:
|
||||||
|
i = conf.supybot.databases.users.timeoutIdentification()
|
||||||
|
if i > 0 and self.auth[0] < time.time() - i:
|
||||||
|
self.unsetAuth()
|
||||||
|
elif hostmask == self.auth[1]:
|
||||||
|
return True
|
||||||
for pat in self.hostmasks:
|
for pat in self.hostmasks:
|
||||||
if ircutils.hostmaskPatternEqual(pat, hostmask):
|
if ircutils.hostmaskPatternEqual(pat, hostmask):
|
||||||
return pat
|
return pat
|
||||||
@ -282,6 +287,7 @@ class IrcUser(object):
|
|||||||
|
|
||||||
def unsetAuth(self):
|
def unsetAuth(self):
|
||||||
"""Unsets a use's authenticated hostmask."""
|
"""Unsets a use's authenticated hostmask."""
|
||||||
|
users.invalidateCache(hostmask=self.auth[1])
|
||||||
self.auth = None
|
self.auth = None
|
||||||
|
|
||||||
def preserve(self, fd, indent=''):
|
def preserve(self, fd, indent=''):
|
||||||
@ -305,13 +311,21 @@ class IrcChannel(object):
|
|||||||
"""This class holds the capabilities, bans, and ignores of a channel.
|
"""This class holds the capabilities, bans, and ignores of a channel.
|
||||||
"""
|
"""
|
||||||
defaultOff = ('op', 'halfop', 'voice', 'protected')
|
defaultOff = ('op', 'halfop', 'voice', 'protected')
|
||||||
def __init__(self, bans=None, ignores=None, capabilities=None,
|
def __init__(self, bans=None, silences=None, exceptions=None, ignores=None,
|
||||||
lobotomized=False, defaultAllow=True):
|
capabilities=None, lobotomized=False, defaultAllow=True):
|
||||||
self.defaultAllow = defaultAllow
|
self.defaultAllow = defaultAllow
|
||||||
if bans is None:
|
if bans is None:
|
||||||
self.bans = []
|
self.bans = []
|
||||||
else:
|
else:
|
||||||
self.bans = bans
|
self.bans = bans
|
||||||
|
if exceptions is None:
|
||||||
|
self.exceptions = []
|
||||||
|
else:
|
||||||
|
self.exceptions = exceptions
|
||||||
|
if silences is None:
|
||||||
|
self.silences = []
|
||||||
|
else:
|
||||||
|
self.silences = silences
|
||||||
if ignores is None:
|
if ignores is None:
|
||||||
self.ignores = []
|
self.ignores = []
|
||||||
else:
|
else:
|
||||||
@ -327,10 +341,11 @@ class IrcChannel(object):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%s(bans=%r, ignores=%r, capabilities=%r, ' \
|
return '%s(bans=%r, ignores=%r, capabilities=%r, ' \
|
||||||
'lobotomized=%r, defaultAllow=%s)\n' % \
|
'lobotomized=%r, defaultAllow=%s, ' \
|
||||||
|
'silences=%r, exceptions=%r)\n' % \
|
||||||
(self.__class__.__name__, self.bans, self.ignores,
|
(self.__class__.__name__, self.bans, self.ignores,
|
||||||
self.capabilities, self.lobotomized,
|
self.capabilities, self.lobotomized,
|
||||||
self.defaultAllow)
|
self.defaultAllow, self.silences, self.exceptions)
|
||||||
|
|
||||||
def addBan(self, hostmask):
|
def addBan(self, hostmask):
|
||||||
"""Adds a ban to the channel banlist."""
|
"""Adds a ban to the channel banlist."""
|
||||||
@ -396,12 +411,16 @@ class IrcChannel(object):
|
|||||||
fd.write(os.linesep)
|
fd.write(os.linesep)
|
||||||
write('lobotomized %s' % self.lobotomized)
|
write('lobotomized %s' % self.lobotomized)
|
||||||
write('defaultAllow %s' % self.defaultAllow)
|
write('defaultAllow %s' % self.defaultAllow)
|
||||||
for ban in self.bans:
|
|
||||||
write('ban %s' % ban)
|
|
||||||
for ignore in self.ignores:
|
|
||||||
write('ignore %s' % ignore)
|
|
||||||
for capability in self.capabilities:
|
for capability in self.capabilities:
|
||||||
write('capability %s' % capability)
|
write('capability ' + capability)
|
||||||
|
for ban in self.bans:
|
||||||
|
write('ban ' + ban)
|
||||||
|
for silence in self.silences:
|
||||||
|
write('silence ' + silence)
|
||||||
|
for exception in self.exceptions:
|
||||||
|
write('exception ' + exception)
|
||||||
|
for ignore in self.ignores:
|
||||||
|
write('ignore ' + ignore)
|
||||||
fd.write(os.linesep)
|
fd.write(os.linesep)
|
||||||
|
|
||||||
|
|
||||||
@ -497,6 +516,16 @@ class IrcChannelCreator(Creator):
|
|||||||
raise ValueError, 'Unexpected channel description without channel.'
|
raise ValueError, 'Unexpected channel description without channel.'
|
||||||
self.c.ignores.append(rest)
|
self.c.ignores.append(rest)
|
||||||
|
|
||||||
|
def silence(self, rest, lineno):
|
||||||
|
if self.name is None:
|
||||||
|
raise ValueError, 'Unexpected channel description without channel.'
|
||||||
|
self.c.silences.append(rest)
|
||||||
|
|
||||||
|
def exception(self, rest, lineno):
|
||||||
|
if self.name is None:
|
||||||
|
raise ValueError, 'Unexpected channel description without channel.'
|
||||||
|
self.c.exceptions.append(rest)
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
if self.hadChannel:
|
if self.hadChannel:
|
||||||
self.channels.setChannel(self.name, self.c)
|
self.channels.setChannel(self.name, self.c)
|
||||||
@ -618,6 +647,25 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
def numUsers(self):
|
def numUsers(self):
|
||||||
return len(self.users)
|
return len(self.users)
|
||||||
|
|
||||||
|
def invalidateCache(self, id=None, hostmask=None, name=None):
|
||||||
|
if hostmask is not None:
|
||||||
|
if hostmask in self._hostmaskCache:
|
||||||
|
id = self._hostmaskCache.pop(hostmask)
|
||||||
|
self._hostmaskCache[id].remove(hostmask)
|
||||||
|
if not self._hostmaskCache[id]:
|
||||||
|
del self._hostmaskCache[id]
|
||||||
|
if name is not None:
|
||||||
|
del self._nameCache[self._nameCache[id]]
|
||||||
|
del self._nameCache[id]
|
||||||
|
if id is not None:
|
||||||
|
if id in self._nameCache:
|
||||||
|
del self._nameCache[self._nameCache[id]]
|
||||||
|
del self._nameCache[id]
|
||||||
|
if id in self._hostmaskCache:
|
||||||
|
for hostmask in self._hostmaskCache[id]:
|
||||||
|
del self._hostmaskCache[hostmask]
|
||||||
|
del self._hostmaskCache[id]
|
||||||
|
|
||||||
def setUser(self, id, user):
|
def setUser(self, id, user):
|
||||||
"""Sets a user (given its id) to the IrcUser given it."""
|
"""Sets a user (given its id) to the IrcUser given it."""
|
||||||
assert isinstance(id, int), 'setUser takes an integer userId.'
|
assert isinstance(id, int), 'setUser takes an integer userId.'
|
||||||
@ -639,13 +687,7 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
if ircutils.hostmaskPatternEqual(hostmask, otherHostmask):
|
if ircutils.hostmaskPatternEqual(hostmask, otherHostmask):
|
||||||
s = '%s is someone else\'s hostmask.' % hostmask
|
s = '%s is someone else\'s hostmask.' % hostmask
|
||||||
raise ValueError, s
|
raise ValueError, s
|
||||||
if id in self._nameCache:
|
self.invalidateCache(id)
|
||||||
del self._nameCache[self._nameCache[id]]
|
|
||||||
del self._nameCache[id]
|
|
||||||
if id in self._hostmaskCache:
|
|
||||||
for hostmask in self._hostmaskCache[id]:
|
|
||||||
del self._hostmaskCache[hostmask]
|
|
||||||
del self._hostmaskCache[id]
|
|
||||||
self.users[id] = user
|
self.users[id] = user
|
||||||
self.flush()
|
self.flush()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user