diff options
Diffstat (limited to 'bin/dbolla')
| -rwxr-xr-x | bin/dbolla | 14 |
1 files changed, 10 insertions, 4 deletions
| @@ -43,6 +43,13 @@ log_config = { | |||
| 43 | class Bot(object): | 43 | class 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 | """ |