minor edit to plugin reloading (dir() -> vars())

This commit is contained in:
Ryan Hitchman 2009-03-30 17:40:43 -06:00
parent b965ec92ab
commit aead137ed7
1 changed files with 3 additions and 4 deletions

7
bot.py
View File

@ -42,10 +42,9 @@ def reload_plugins(mtime=[0]):
shortname = os.path.splitext(os.path.basename(filename))[0] shortname = os.path.splitext(os.path.basename(filename))[0]
try: try:
plugin = imp.load_source(shortname, filename) plugin = imp.load_source(shortname, filename)
for thing in dir(plugin): for obj in vars(plugin).itervalues():
thing = getattr(plugin, thing) if hasattr(obj, '_skybot_hook'): #check for magic
if hasattr(thing, '_skybot_hook'): for type, data in obj._skybot_hook:
for type, data in thing._skybot_hook:
bot.plugs[type] += [data] bot.plugs[type] += [data]
except Exception, e: except Exception, e:
print ' error:', e print ' error:', e