Fixed a platform-dependence bug and rewrote some config file parsing to be cleaner.

This commit is contained in:
Jeremy Fincher 2003-03-25 19:20:30 +00:00
parent fa261c0e80
commit 5651ae2190

View File

@ -35,6 +35,7 @@ Main program file for running the bot.
from fix import * from fix import *
import os
import sys import sys
import email import email
@ -76,6 +77,7 @@ class ConfigAfter376(irclib.IrcCallback):
self.msgs = msgs self.msgs = msgs
def do376(self, irc, msg): def do376(self, irc, msg):
#debug.printf('Firing ConfigAfter376 messages')
for msg in self.msgs: for msg in self.msgs:
irc.queueMsg(msg) irc.queueMsg(msg)
@ -109,21 +111,20 @@ def processConfigFile(filename):
user = d['user'] or nick user = d['user'] or nick
ident = d['ident'] or nick ident = d['ident'] or nick
irc = irclib.Irc(nick, user, ident) irc = irclib.Irc(nick, user, ident)
for cls in privmsgs.standardPrivmsgModules: for Class in privmsgs.standardPrivmsgModules:
irc.addCallback(cls()) irc.addCallback(Class())
ircdb.startup = True ircdb.startup = True
lines = m.get_payload() lines = m.get_payload().splitlines()
if lines.find('\n\n') != -1: (startup, after376) = tuple(itersplit(lines, lambda s: not s))
(startup, after376) = lines.split('\n\n') debug.printf('startup: %r' % startup)
else: debug.printf('after376: %r' % after376)
(startup, after376) = (lines, '') for line in filter(None, startup):
for line in filter(None, startup.splitlines()):
if not line.startswith('#'): if not line.startswith('#'):
irc.feedMsg(ircmsgs.privmsg(irc.nick, line)) irc.feedMsg(ircmsgs.privmsg(irc.nick, line))
irc.reset() irc.reset()
ircdb.startup = False ircdb.startup = False
msgs = [ircmsgs.privmsg(irc.nick, s) for s in after376.splitlines()] msgs = [ircmsgs.privmsg(irc.nick, line) for line in after376]
irc.addCallback(ConfigAfter376(filter(None, msgs))) irc.addCallback(ConfigAfter376(msgs))
driver = asyncoreDrivers.AsyncoreDriver(server) driver = asyncoreDrivers.AsyncoreDriver(server)
driver.irc = irc driver.irc = irc
except IOError, e: except IOError, e: