mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
Fixed a platform-dependence bug and rewrote some config file parsing to be cleaner.
This commit is contained in:
parent
fa261c0e80
commit
5651ae2190
21
src/bot.py
21
src/bot.py
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user