diff --git a/oscbot/__init__.py b/oscbot/__init__.py index f238651..8f2ba4e 100644 --- a/oscbot/__init__.py +++ b/oscbot/__init__.py @@ -205,13 +205,37 @@ class OSCBot(Plugin): await evt.reply(message, markdown=True) + @osc.subcommand( + "servicerun", + help="Trigger source services for a package") + @command.argument("project", "project name") + @command.argument("package", "package name") + async def servicerun(self, evt: MessageEvent, + project: str, + package: str) -> None: + + token = self.config["trigger_token"] + trigger_url = f"{self.config['api_url']}/trigger/runservice" + params = {"project": project, "package": package} + header = {"Authorization": f"Token {token}"} + + response = await self.http.post(trigger_url, params=params, + headers=header) + + status = objectify.fromstring(await response.text()) + if response.status == 200: + message = f"Service triggered: {status.summary.text}" + else: + message = f"Error running service: {status.summary.text}" + await evt.reply(message, markdown=True) + @osc.subcommand("status", aliases=("st",), help="Check status for package and repository") @command.argument("project", "project name") - @command.argument("package", "package name (optional)", required=False) - @command.argument("state", "build state (optional)", required=False) - @command.argument("repository", "repository (optional)", required=False) - @command.argument("arch", "architecture state (optional)", required=False) + @command.argument("package", "package name | all", required=False) + @command.argument("state", "build state | all", required=False) + @command.argument("repository", "repository | all)", required=False) + @command.argument("arch", "architecture state | all", required=False) async def status(self, evt: MessageEvent, project: str, package: Optional[str] = None,