load modules at startup based on config file, remove that item from TODO

This commit is contained in:
Brian S. Stephan 2010-07-29 23:13:15 -05:00
parent 6cc9577570
commit 9191f25052
2 changed files with 12 additions and 7 deletions

1
TODO
View File

@ -6,7 +6,6 @@ dr.botzo --- TODO
* weather module
* 8ball style module
* modularizing
* select modules to load from config file
* karma v2
* some sort of cron interface (periodic events)
* named pipe to send commands to the bot outside of IRC

View File

@ -65,12 +65,18 @@ irclib.DEBUG = config.getboolean('IRC', 'debug')
irc = DrBotIRC()
server = irc.server().connect(botserver, botport, botnick, botircname)
count = Countdown.Countdown(config, server, modlist)
dice = Dice.Dice(config, server, modlist)
fact = FactFile.FactFile(config, server, modlist)
admin = IrcAdmin.IrcAdmin(config, server, modlist)
gt = GoogleTranslate.GoogleTranslate(config, server, modlist)
seen = Seen.Seen(config, server, modlist)
# load features
try:
cfgmodlist = config.get('modules', 'modlist')
mods = cfgmodlist.split(',')
for mod in mods:
# try to load each module
eval(mod + '.' + mod + '(config, server, modlist)')
except NoSectionError as e:
print("You seem to be missing a modules config section, which you probably wanted.")
except NoOptionError as e:
print("You seem to be missing a modlist config option, which you probably wanted.")
# loop forever
irc.process_forever()