Remove core config

This commit is contained in:
dpedu 2015-06-18 19:57:45 -07:00
parent 4812e07e2e
commit 5fc4504b30
6 changed files with 15 additions and 34 deletions

3
.gitignore vendored
View File

@ -5,4 +5,5 @@ docs/_build
botenv botenv
dist dist
build build
pyircbot.egg-info pyircbot.egg-info
dev

View File

@ -14,27 +14,21 @@ if __name__ == "__main__":
" parse command line args " " parse command line args "
parser = OptionParser() parser = OptionParser()
parser.add_option("-c", "--config", action="store", type="string", dest="config", help="Path to core config file") parser.add_option("-c", "--config", action="store", type="string", dest="config", help="Path to config file")
parser.add_option("-b", "--bot", action="store", type="string", dest="bot", help="Path to bot config file")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
log.debug(options) log.debug(options)
if not options.config: if not options.config:
log.critical("No core config file specified (-c). Exiting.") log.critical("No bot config file specified (-c). Exiting.")
sys.exit(0)
if not options.bot:
log.critical("No bot config file specified (-b). Exiting.")
sys.exit(0) sys.exit(0)
coreconfig = yaml.load(open(options.config, 'r')) botconfig = yaml.load(open(options.config, 'r'))
botconfig = yaml.load(open(options.bot, 'r'))
log.debug(coreconfig)
log.debug(botconfig) log.debug(botconfig)
bot = PyIRCBot(coreconfig, botconfig) bot = PyIRCBot(botconfig)
try: try:
bot.loop() bot.loop()
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@ -1,2 +0,0 @@
botdir: /home/example/bot/pyircbot/
moduledir: /home/example/bot/pyircbot/modules/

View File

@ -1,9 +1,8 @@
user: user:
nick: nick:
- dave - pyircbot3
- dave_ - pyircbot3_
- dave__ - pyircbot3__
- dave___
password: nickservpassword password: nickservpassword
username: pyircbot3 username: pyircbot3
hostname: pyircbot3.domain.com hostname: pyircbot3.domain.com
@ -16,9 +15,9 @@ ident:
ghost_to: nickserv ghost_to: nickserv
ghost_cmd: ghost %(nick)s %(password)s ghost_cmd: ghost %(nick)s %(password)s
channels: channels:
- "#dave2" - "#xmopx"
privatechannels: privatechannels:
to: chanserv to: chanserv
command: invite %(channel)s command: invite %(channel)s
list: list:
- "#aprivatechannel" - "#aprivatechannel"

View File

@ -1,2 +1,2 @@
#!/bin/sh #!/bin/sh
../bin/pyircbot -c config.main.yml -b config.instance.yml ../bin/pyircbot --config config.instance.yml

View File

@ -15,22 +15,14 @@ from pyircbot import modulebase
import os.path import os.path
class PyIRCBot: class PyIRCBot:
""":param coreconfig: The core configuration of the bot. Passed by main.py. """:param botconfig: The configuration of this instance of the bot. Passed by main.py.
:type coreconfig: dict
:param botconfig: The configuration of this instance of the bot. Passed by main.py.
:type botconfig: dict :type botconfig: dict
""" """
version = "1.0a1-git" def __init__(self, botconfig):
""" PyIRCBot version """
def __init__(self, coreconfig, botconfig):
self.log = logging.getLogger('PyIRCBot') self.log = logging.getLogger('PyIRCBot')
"""Reference to logger object""" """Reference to logger object"""
self.coreconfig = coreconfig
"""saved copy of the core config"""
self.botconfig = botconfig self.botconfig = botconfig
"""saved copy of the instance config""" """saved copy of the instance config"""
@ -96,10 +88,7 @@ class PyIRCBot:
" instances of modules " " instances of modules "
self.moduleInstances = {} self.moduleInstances = {}
" append module location to path " " append module location to path "
sys.path.append(self.coreconfig["moduledir"]) sys.path.append(os.path.dirname(__file__)+"/modules/")
" append bot directory to path "
sys.path.append(self.coreconfig["botdir"]+"core/")
for modulename in self.botconfig["modules"]: for modulename in self.botconfig["modules"]:
self.loadmodule(modulename) self.loadmodule(modulename)