aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjason2016-08-18 19:30:35 -0600
committerjason2016-08-18 19:30:35 -0600
commit4518daba36678f52330513ec1fec82a44340fa81 (patch)
treef5a95fa686516f1898c7ec66b44ad2ad583bbc95 /bin
parenta427cd070d2246264e555b3d4779ebde8acd2e08 (diff)
downloadwarmachine-ng-4518daba36678f52330513ec1fec82a44340fa81.tar.gz
warmachine-ng-4518daba36678f52330513ec1fec82a44340fa81.zip
Remove the hard-coded config file path
- added a dynamic config file path
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dbolla14
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/dbolla b/bin/dbolla
index e00143b..5bef051 100755
--- a/bin/dbolla
+++ b/bin/dbolla
@@ -43,6 +43,13 @@ log_config = {
43class Bot(object): 43class Bot(object):
44 def __init__(self, settings): 44 def __init__(self, settings):
45 self.log = logging.getLogger(self.__class__.__name__) 45 self.log = logging.getLogger(self.__class__.__name__)
46
47 self.config_dir = os.path.expanduser('~/.warmachine')
48 if not os.path.exists(self.config_dir):
49 self.log.info('Creating config directory: {}'.format(
50 self.config_dir))
51 os.makedirs(self.config_dir)
52
46 self._loop = asyncio.get_event_loop() 53 self._loop = asyncio.get_event_loop()
47 54
48 self.settings = settings 55 self.settings = settings
@@ -55,8 +62,6 @@ class Bot(object):
55 self.load_plugin('warmachine.addons.giphy.GiphySearch') 62 self.load_plugin('warmachine.addons.giphy.GiphySearch')
56 self.load_plugin('warmachine.addons.standup.StandUpPlugin') 63 self.load_plugin('warmachine.addons.standup.StandUpPlugin')
57 64
58 # TODO: Ensure the config directory has been created
59
60 def start(self): 65 def start(self):
61 for connection in self.connections: 66 for connection in self.connections:
62 t = asyncio.ensure_future(connection.connect()) 67 t = asyncio.ensure_future(connection.connect())
@@ -65,6 +70,7 @@ class Bot(object):
65 self._loop.run_forever() 70 self._loop.run_forever()
66 71
67 def add_connection(self, connection): 72 def add_connection(self, connection):
73 connection.config_dir = self.config_dir
68 self.connections[connection] = {} 74 self.connections[connection] = {}
69 75
70 def on_connect(self, connection, task): 76 def on_connect(self, connection, task):
@@ -104,9 +110,9 @@ class Bot(object):
104 mod = import_module(mod_path) 110 mod = import_module(mod_path)
105 111
106 if hasattr(mod, cls_name): 112 if hasattr(mod, cls_name):
107 cls = getattr(mod, cls_name)() 113 obj = getattr(mod, cls_name)(config_dir=self.config_dir)
108 114
109 self.loaded_plugins.append(cls) 115 self.loaded_plugins.append(obj)
110 116
111 def reload_plugin(self, path): 117 def reload_plugin(self, path):
112 """ 118 """