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
dist
build
pyircbot.egg-info
pyircbot.egg-info
dev

View File

@ -14,27 +14,21 @@ if __name__ == "__main__":
" parse command line args "
parser = OptionParser()
parser.add_option("-c", "--config", action="store", type="string", dest="config", help="Path to core config file")
parser.add_option("-b", "--bot", action="store", type="string", dest="bot", help="Path to bot config file")
parser.add_option("-c", "--config", action="store", type="string", dest="config", help="Path to config file")
(options, args) = parser.parse_args()
log.debug(options)
if not options.config:
log.critical("No core config file specified (-c). Exiting.")
sys.exit(0)
if not options.bot:
log.critical("No bot config file specified (-b). Exiting.")
log.critical("No bot config file specified (-c). Exiting.")
sys.exit(0)
coreconfig = yaml.load(open(options.config, 'r'))
botconfig = yaml.load(open(options.bot, 'r'))
botconfig = yaml.load(open(options.config, 'r'))
log.debug(coreconfig)
log.debug(botconfig)
bot = PyIRCBot(coreconfig, botconfig)
bot = PyIRCBot(botconfig)
try:
bot.loop()
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:
nick:
- dave
- dave_
- dave__
- dave___
- pyircbot3
- pyircbot3_
- pyircbot3__
password: nickservpassword
username: pyircbot3
hostname: pyircbot3.domain.com
@ -16,9 +15,9 @@ ident:
ghost_to: nickserv
ghost_cmd: ghost %(nick)s %(password)s
channels:
- "#dave2"
- "#xmopx"
privatechannels:
to: chanserv
command: invite %(channel)s
list:
- "#aprivatechannel"
- "#aprivatechannel"

View File

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