Skip to content

Commit

Permalink
Refactor Bot PluginManager configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
unode committed Aug 19, 2022
1 parent c44e072 commit 226ad94
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions mmpy_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,15 @@ def __init__(
plugins: Optional[Union[List[Plugin], PluginManager]] = None,
enable_logging: bool = True,
):
if plugins is None:
self.plugin_manager = PluginManager(
[HelpPlugin(), ExamplePlugin(), WebHookExample()]
)
elif isinstance(plugins, PluginManager):
self.plugin_manager = plugins
else:
self.plugin_manager = PluginManager(plugins)
self._setup_plugin_manager(plugins)

# Use default settings if none were specified.
self.settings = settings or Settings()

self.console = None

if enable_logging:
self._register_logger()
else:
self.console = None

self.driver = Driver(
{
Expand All @@ -72,6 +65,16 @@ def __init__(

self.running = False

def _setup_plugin_manager(self, plugins):
if plugins is None:
self.plugin_manager = PluginManager(
[HelpPlugin(), ExamplePlugin(), WebHookExample()]
)
elif isinstance(plugins, PluginManager):
self.plugin_manager = plugins
else:
self.plugin_manager = PluginManager(plugins)

def _register_logger(self):
logging.basicConfig(
**{
Expand Down

0 comments on commit 226ad94

Please sign in to comment.