feat(issues): added support for labels
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
parent
a8d873be33
commit
9b07892087
1 changed files with 24 additions and 2 deletions
|
@ -275,10 +275,16 @@ class IssueResponseModal(discord.ui.Modal, title="Sending response message..."):
|
|||
|
||||
if embed.author.name == "Bot Bug Report":
|
||||
issue_title = f"[BOT BUG] {_issue_title}"
|
||||
desired_labels = ["bot", "bug"]
|
||||
elif embed.author.name == "Bot Suggestion":
|
||||
issue_title = f"[BOT SUGGESTION] {_issue_title}"
|
||||
elif embed.author.name == "Cog Bug Report" or embed.author.name == "Cog Suggestion":
|
||||
desired_labels = ["bot", "enhancement"]
|
||||
elif embed.author.name == "Cog Bug Report":
|
||||
issue_title = f"[{field_values[0]}] {_issue_title}"
|
||||
desired_labels = ["cog", "bug"]
|
||||
elif embed.author.name == "Cog Suggestion":
|
||||
issue_title = f"[{field_values[0]}] {_issue_title}"
|
||||
desired_labels = ["cog", "enhancement"]
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {await self.config.gitea_token()}",
|
||||
|
@ -291,7 +297,23 @@ class IssueResponseModal(discord.ui.Modal, title="Sending response message..."):
|
|||
[f"{name}\n{value}" for name, value in zip(field_names, field_values)]
|
||||
)
|
||||
|
||||
async def fetch_labels():
|
||||
async with aiohttp.ClientSession(headers=headers) as session:
|
||||
async with session.post(url=f"{await self.config.gitea_root_url()}/api/v1/repos/{await self.config.gitea_repository_owner()}/{await self.config.gitea_repository()}/labels") as response:
|
||||
label_list = []
|
||||
for label in response.json():
|
||||
if label["name"] in desired_labels:
|
||||
label_list.append(label["id"])
|
||||
if label_list is None:
|
||||
print("Error! Labels are not properly configured on the target repository.")
|
||||
return await label_list, response.status
|
||||
|
||||
issue_labels = fetch_labels()
|
||||
|
||||
if issue_labels is None:
|
||||
issue_data = {"title": issue_title, "body": issue_body}
|
||||
else:
|
||||
issue_data = {"title": issue_title, "body": issue_body, "labels": issue_labels}
|
||||
|
||||
async def create_issue():
|
||||
async with aiohttp.ClientSession(headers=headers) as session:
|
||||
|
|
Loading…
Reference in a new issue