mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
Irc.callbacks is always mutated, never replaced, helping the Relay module out.
This commit is contained in:
parent
37b9342178
commit
714de6bfae
@ -245,10 +245,10 @@ class Irc(object):
|
||||
self.prefix = ''
|
||||
self.user = user or nick # Default to nick if user isn't provided.
|
||||
self.ident = ident or nick # Ditto.
|
||||
self.callbacks = []
|
||||
if callbacks is not None:
|
||||
for callback in callbacks:
|
||||
self.addCallback(callback)
|
||||
if callbacks is None:
|
||||
self.callbacks = []
|
||||
else:
|
||||
self.callbacks = callbacks
|
||||
self._nickmods = copy.copy(conf.nickmods)
|
||||
self.state = IrcState()
|
||||
self.queue = IrcMsgQueue()
|
||||
@ -274,11 +274,15 @@ class Irc(object):
|
||||
|
||||
def removeCallback(self, name):
|
||||
ret = []
|
||||
toRemove = []
|
||||
for (i, cb) in enumerate(self.callbacks):
|
||||
if cb.name() == name:
|
||||
ret.append(self.callbacks[i])
|
||||
self.callbacks[i] = None
|
||||
self.callbacks = [cb for cb in self.callbacks if cb is not None]
|
||||
toRemove.append(i)
|
||||
if toRemove:
|
||||
for i in reviter(range(len(self.callbacks))):
|
||||
if toRemove[-1] == i:
|
||||
toRemove.pop()
|
||||
ret.append(self.callbacks.pop(i))
|
||||
return ret
|
||||
|
||||
def queueMsg(self, msg):
|
||||
|
Loading…
Reference in New Issue
Block a user