Changed AsyncoreDriver to accept an irc as an argument, hopefully fixing the looping bug.

This commit is contained in:
Jeremy Fincher 2003-04-09 15:07:23 +00:00
parent 60169accb2
commit 8c9811ea05
3 changed files with 6 additions and 8 deletions

View File

@ -132,8 +132,7 @@ class Relay(callbacks.Privmsg):
else:
port = 6667
newIrc = irclib.Irc(irc.nick, callbacks=irc.callbacks)
driver = asyncoreDrivers.AsyncoreDriver((server, port))
driver.irc = newIrc
driver = asyncoreDrivers.AsyncoreDriver((server, port), newIrc)
newIrc.driver = driver
self.ircs[abbreviation] = newIrc
self.abbreviations[newIrc] = abbreviation

View File

@ -58,12 +58,12 @@ class AsyncoreRunnerDriver(drivers.IrcDriver):
class AsyncoreDriver(asynchat.async_chat, object):
def __init__(self, (server, port), reconnect=True):
def __init__(self, (server, port), irc, reconnect=True):
#debug.methodNamePrintf(self, '__init__')
asynchat.async_chat.__init__(self)
self.server = (server, port)
self.reconnect = reconnect
self.irc = None # Satisfy PyChecker.
self.irc = irc
self.buffer = ''
self.set_terminator('\n')
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
@ -81,14 +81,13 @@ class AsyncoreDriver(asynchat.async_chat, object):
debug.msg('Scheduling reconnect at %s' % whenS, 'normal')
def makeNewDriver():
self.irc.reset()
driver = self.__class__(self.server, reconnect=self.reconnect)
driver.irc = self.irc
driver = self.__class__(self.server, self.irc, self.reconnect)
driver.irc.driver = driver
schedule.addEvent(makeNewDriver, when)
def writable(self):
#debug.methodNamePrintf(self, 'writable')
while self.connected:
while self.connected and self.irc:
m = self.irc.takeMsg()
if m:
self.push(str(m))

View File

@ -140,7 +140,7 @@ def processConfigFile(filename):
irc.reset()
world.startup = False
irc.addCallback(ConfigAfter376(after376))
driver = asyncoreDrivers.AsyncoreDriver(server)
driver = asyncoreDrivers.AsyncoreDriver(server, irc)
driver.irc = irc
except IOError, e:
reportConfigError(filename, e)