From ecb9d7cb3f4435457560e03201bbed57a469d548 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 24 Sep 2018 15:13:27 +0100 Subject: Move most code in root directory to src/ --- src/Config.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/Config.py (limited to 'src/Config.py') diff --git a/src/Config.py b/src/Config.py new file mode 100644 index 00000000..71e01871 --- /dev/null +++ b/src/Config.py @@ -0,0 +1,16 @@ +import configparser, os + +class Config(object): + def __init__(self, bot, directory, filename="bot.conf"): + self.bot = bot + self.filename = filename + self.full_location = os.path.join(directory, filename) + self.bot.config = {} + self.load_config() + + def load_config(self): + if os.path.isfile(self.full_location): + with open(self.full_location) as config_file: + parser = configparser.ConfigParser() + parser.read_string(config_file.read()) + return dict(parser["bot"].items()) -- cgit v1.3.1-10-gc9f91