My available commands:
-
-
-| Command | Description | Arg Types | Example |
-|---------|-------------|--------|--------|
-| /add_label | Adds one label | string | /add_label bug |
-| /add_labels | Adds multiple labels | list[string] | /add_label bug enhancement |
-| /remove_label | Removes one label | string | /remove_label bug |
-| /remove_labels | Removes multiple labels | list[string] | /remove_labels bug enhancement |
-
-
-"""
- )
+ repo = g.get_repo(event.get("repository", {}).get("full_name")) if REPOSITORY else {}
+
+ if ISSUE or PR:
+ selected_json: dict = ISSUE or PR
+
+ selected_obj = repo.get_issue(number=ISSUE["id"]) if repo and ISSUE else repo.get_pull(number=PR["id"]) if repo and PR else {}
+
+ LABELS = selected_json.get("labels")
+ label_names = {label["name"] for label in LABELS}
+
+ if "awaiting-response" in label_names and is_owner(selected_json, SENDER) and COMMENT:
+ selected_obj.remove_from_labels("awaiting-response")
+
+ if COMMENT and (is_trey(SENDER) or is_owner(selected_json, SENDER)):
+ if ACTION == "created": # sent comment
+ msg = COMMENT.get("body", "")
+ msg_stripped = msg.strip().split(" ")
+ msg_len = len(msg_stripped)
+
+ match msg_stripped[0]:
+ case "/add_label":
+ if not msg_len == 2:
+ send_error(
+ selected_obj,
+ sender=SENDER["login"],
+ body=COMMENT["body"],
+ msg_len=msg_len,
+ required=2,
+ example_cmd="add_label bug",
+ )
+
+ return g.close()
+
+ selected_obj.add_to_labels(msg_stripped[1])
+ selected_obj.create_comment(f"Okay @{SENDER['login']}, I have added the label '{msg_stripped[1]}'")
+ case "/add_labels":
+ selected_obj.add_to_labels(*msg_stripped[1:])
+ selected_obj.create_comment(f"Okay @{SENDER['login']}, I have added the labels \"{', '.join(msg_stripped[1:])}\"")
+ case "/remove_label":
+ if not msg_len == 2:
+ send_error(
+ selected_obj,
+ sender=SENDER["login"],
+ body=COMMENT["body"],
+ msg_len=msg_len,
+ required=2,
+ example_cmd="remove_label bug",
+ )
+
+ return g.close()
+
+ selected_obj.remove_from_labels(msg_stripped[1])
+ selected_obj.create_comment(f"Okay @{SENDER['login']}, I have removed the label \"{msg_stripped[1]}\"")
+ case "/remove_labels":
+ selected_obj.remove_from_labels(*msg_stripped[1:])
+ selected_obj.create_comment(f"Okay @{SENDER['login']}, I have removed the labels \"{', '.join(msg_stripped[1:])}\"")
+ case "/help":
+ selected_obj.create_comment(
+ f"""
+ Hi @{SENDER["login"]},
+
+