From 5fc4504b301358f2f1bc71d67606cc2d3ad67576 Mon Sep 17 00:00:00 2001 From: dpedu Date: Thu, 18 Jun 2015 19:57:45 -0700 Subject: [PATCH] Remove core config --- .gitignore | 3 ++- bin/pyircbot | 14 ++++---------- examples/config.main.yml | 2 -- examples/data/config/Services.yml | 11 +++++------ examples/run-example.sh | 2 +- pyircbot/pyircbot.py | 17 +++-------------- 6 files changed, 15 insertions(+), 34 deletions(-) delete mode 100644 examples/config.main.yml diff --git a/.gitignore b/.gitignore index ddcee96..d504604 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ docs/_build botenv dist build -pyircbot.egg-info \ No newline at end of file +pyircbot.egg-info +dev \ No newline at end of file diff --git a/bin/pyircbot b/bin/pyircbot index 5898aa3..633e3d1 100755 --- a/bin/pyircbot +++ b/bin/pyircbot @@ -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: diff --git a/examples/config.main.yml b/examples/config.main.yml deleted file mode 100644 index 19d4007..0000000 --- a/examples/config.main.yml +++ /dev/null @@ -1,2 +0,0 @@ -botdir: /home/example/bot/pyircbot/ -moduledir: /home/example/bot/pyircbot/modules/ diff --git a/examples/data/config/Services.yml b/examples/data/config/Services.yml index 0866e5c..b745a68 100644 --- a/examples/data/config/Services.yml +++ b/examples/data/config/Services.yml @@ -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" \ No newline at end of file diff --git a/examples/run-example.sh b/examples/run-example.sh index d45b74b..0dfd259 100755 --- a/examples/run-example.sh +++ b/examples/run-example.sh @@ -1,2 +1,2 @@ #!/bin/sh -../bin/pyircbot -c config.main.yml -b config.instance.yml +../bin/pyircbot --config config.instance.yml diff --git a/pyircbot/pyircbot.py b/pyircbot/pyircbot.py index 759a3d1..91411f2 100644 --- a/pyircbot/pyircbot.py +++ b/pyircbot/pyircbot.py @@ -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)