better method of loading modules --- don't import *, import each individually

This commit is contained in:
Brian S. Stephan 2010-12-10 23:25:56 -06:00
parent 5a81f4d1fc
commit da9e4b3142
1 changed files with 5 additions and 4 deletions

View File

@ -26,8 +26,6 @@ import sqlite3
from extlib import irclib
from modules import *
modlist = []
moduleList = [ "Countdown", "Dice", "IrcAdmin", "GoogleTranslate", "Seen", "FactFile" ]
modObjs = []
@ -146,8 +144,11 @@ try:
mods = cfgmodlist.split(',')
for mod in mods:
# try to load each module
module = eval(mod + '.' + mod + '(config, server, modlist)')
module.attach_to_server(server)
modstr = 'modules.'+mod
__import__(modstr)
module = sys.modules[modstr]
botmod = eval('module.' + mod + '(config, server, modlist)')
botmod.attach_to_server(server)
except NoSectionError as e:
print("You seem to be missing a modules config section, which you probably wanted.")
except NoOptionError as e: