From 86dd3902f78f470d4e571213fb126119c079b1c6 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Fri, 9 Sep 2022 13:51:52 +0200 Subject: add command framework, correct access token and secret passing --- labbot/bot.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'labbot/bot.py') diff --git a/labbot/bot.py b/labbot/bot.py index 72d01ca..f5371f6 100644 --- a/labbot/bot.py +++ b/labbot/bot.py @@ -6,6 +6,7 @@ import logging import labbot import labbot.config +import labbot.commands log = logging.getLogger(__name__) @@ -26,7 +27,7 @@ class Bot: if "addon_path" in self.config: self.addon_paths.append(self.config.get("addon_path")) - self.instance = GitLabBot(self.name, **kwargs) + self.instance = GitLabBot(self.name, access_token=self.access_token, secret=self.secret, **kwargs) for path in self.addon_paths: sys.path.insert(0, path) @@ -37,9 +38,12 @@ class Bot: for path in self.addon_paths: sys.path.remove(path) + labbot.commands.commands.setup_hook(self) + def load_addon(self, addon: str) -> None: try: + module = import_module(f"{addon}") import_module(f"{addon}").setup(self) log.info(f"Loaded {addon}") self.addons.append(addon) @@ -58,6 +62,9 @@ class Bot: def register_issue_hook(self, func, *args, **kwargs) -> None: self.register(func, "Issue Hook", *args, **kwargs) + def register_comment_hook(self, func, *args, **kwargs) -> None: + self.register(func, "Issue Hook", *args, **kwargs) + def register_note_hook(self, func, *args, **kwargs) -> None: self.register(func, "Note Hook", *args, **kwargs) -- cgit v1.2.3