better method of loading modules --- don't import *, import each individually
This commit is contained in:
parent
5a81f4d1fc
commit
da9e4b3142
@ -26,8 +26,6 @@ import sqlite3
|
|||||||
|
|
||||||
from extlib import irclib
|
from extlib import irclib
|
||||||
|
|
||||||
from modules import *
|
|
||||||
|
|
||||||
modlist = []
|
modlist = []
|
||||||
moduleList = [ "Countdown", "Dice", "IrcAdmin", "GoogleTranslate", "Seen", "FactFile" ]
|
moduleList = [ "Countdown", "Dice", "IrcAdmin", "GoogleTranslate", "Seen", "FactFile" ]
|
||||||
modObjs = []
|
modObjs = []
|
||||||
@ -146,8 +144,11 @@ try:
|
|||||||
mods = cfgmodlist.split(',')
|
mods = cfgmodlist.split(',')
|
||||||
for mod in mods:
|
for mod in mods:
|
||||||
# try to load each module
|
# try to load each module
|
||||||
module = eval(mod + '.' + mod + '(config, server, modlist)')
|
modstr = 'modules.'+mod
|
||||||
module.attach_to_server(server)
|
__import__(modstr)
|
||||||
|
module = sys.modules[modstr]
|
||||||
|
botmod = eval('module.' + mod + '(config, server, modlist)')
|
||||||
|
botmod.attach_to_server(server)
|
||||||
except NoSectionError as e:
|
except NoSectionError as e:
|
||||||
print("You seem to be missing a modules config section, which you probably wanted.")
|
print("You seem to be missing a modules config section, which you probably wanted.")
|
||||||
except NoOptionError as e:
|
except NoOptionError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user