Allow json for native module configs

dpedu 8 years ago
parent a6afeab07d
commit f66f0b03a5

@ -2,7 +2,6 @@
import os
import sys
import logging
import yaml
from optparse import OptionParser
from pyircbot import PyIRCBot

@ -8,7 +8,7 @@
import logging
import os
import yaml
from .pyircbot import PyIRCBot
class ModuleBase:
"""All modules will extend this class
@ -47,8 +47,8 @@ class ModuleBase:
def loadConfig(self):
"""Loads this module's config into self.config"""
configPath =
if os.path.exists( configPath ):
self.config = yaml.load(open(configPath, 'r'))
if not configPath == None:
self.config = PyIRCBot.load(configPath)
def ondisable(self):
"""Called when the module should be disabled. Your module should do any sort

@ -11,7 +11,6 @@ import time
import sys
from pyircbot.rpc import BotRPC
from pyircbot.irccore import IRCCore
from pyircbot import modulebase
import os.path
class PyIRCBot:
@ -291,7 +290,14 @@ class PyIRCBot:
:param moduleName: the module who's config file we want
:type moduleName: str"""
return "%s/config/%s.yml" % (self.botconfig["bot"]["datadir"], moduleName)
basepath = "%s/config/%s" % (self.botconfig["bot"]["datadir"], moduleName)
if os.path.exists("%s.yml"%basepath):
return "%s.yml"%basepath
elif os.path.exists("%s.json"%basepath):
return "%s.json"%basepath
return None
" Utility methods "