feat(issues): fixed configuration prompt
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
1f26e32852
commit
d4203cad9c
1 changed files with 29 additions and 7 deletions
|
@ -14,7 +14,9 @@ class Issues(commands.Cog):
|
||||||
self.config = Config.get_conf(self, identifier=4285273314713, force_registration=True)
|
self.config = Config.get_conf(self, identifier=4285273314713, force_registration=True)
|
||||||
self.config.register_global(
|
self.config.register_global(
|
||||||
request_channel = None,
|
request_channel = None,
|
||||||
gitea_repository_url = None,
|
gitea_root_url = None,
|
||||||
|
gitea_repository_owner = None,
|
||||||
|
gitea_repository = None,
|
||||||
gitea_token = None
|
gitea_token = None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -151,24 +153,44 @@ class Issues(commands.Cog):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
|
|
||||||
gitea_repository_url = discord.ui.TextInput(
|
gitea_root_url = discord.ui.TextInput(
|
||||||
label="Gitea Repository URL",
|
label="Gitea Root URL",
|
||||||
placeholder="https://try.gitea.io/owner/repository",
|
placeholder="https://try.gitea.io",
|
||||||
style=discord.TextStyle.short,
|
style=discord.TextStyle.short,
|
||||||
|
required=False,
|
||||||
|
max_length=200
|
||||||
|
)
|
||||||
|
gitea_repository_owner = discord.ui.TextInput(
|
||||||
|
label="Gitea Repository Owner",
|
||||||
|
placeholder="foo",
|
||||||
|
style=discord.TextStyle.short,
|
||||||
|
required=False,
|
||||||
|
max_length=200
|
||||||
|
)
|
||||||
|
gitea_repository = discord.ui.TextInput(
|
||||||
|
label="Gitea Repository Name",
|
||||||
|
placeholder="bar",
|
||||||
|
style=discord.TextStyle.short,
|
||||||
|
required=False,
|
||||||
max_length=200
|
max_length=200
|
||||||
)
|
)
|
||||||
gitea_token = discord.ui.TextInput(
|
gitea_token = discord.ui.TextInput(
|
||||||
label="Gitea User Access Token",
|
label="Gitea User Access Token",
|
||||||
placeholder="Generate one from your user settings page.",
|
placeholder="Generate one from your user settings page.",
|
||||||
style=discord.TextStyle.short,
|
style=discord.TextStyle.short,
|
||||||
|
required=False,
|
||||||
max_length=200
|
max_length=200
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_submit(self, interaction: discord.Interaction):
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
if self.gitea_token.value is not None:
|
if self.gitea_token.value is not None:
|
||||||
await self.config.gitea_token.set(self.gitea_token.value)
|
await self.config.gitea_token.set(self.gitea_token.value)
|
||||||
if self.gitea_repository_url.value is not None:
|
if self.gitea_root_url.value is not None:
|
||||||
await self.config.gitea_repository_url.set(self.gitea_repository_url.value)
|
await self.config.gitea_root_url.set(self.gitea_root_url.value)
|
||||||
|
if self.gitea_repository_owner.value is not None:
|
||||||
|
await self.config.gitea_repository_owner.set(self.gitea_repository_owner.value)
|
||||||
|
if self.gitea_repository.value is not None:
|
||||||
|
await self.config.gitea_repository.set(self.gitea_repository.value)
|
||||||
await interaction.response.send_message(content="Configuration changed!")
|
await interaction.response.send_message(content="Configuration changed!")
|
||||||
|
|
||||||
class IssueResponseButtons(discord.ui.View):
|
class IssueResponseButtons(discord.ui.View):
|
||||||
|
@ -233,7 +255,7 @@ class Issues(commands.Cog):
|
||||||
"Authorization": f"Bearer {await self.config.gitea_token()}",
|
"Authorization": f"Bearer {await self.config.gitea_token()}",
|
||||||
"Accept": "application/json"
|
"Accept": "application/json"
|
||||||
}
|
}
|
||||||
url = await self.config.gitea_repository_url()
|
url = f"{await self.config.gitea_root_url()}/api/v1/repos/{await self.config.gitea_repository_owner()}/{await self.config.gitea_repository()}/issues"
|
||||||
issue_body = "\n".join([f"{name}\n{value}" for name, value in zip(field_names, field_values)])
|
issue_body = "\n".join([f"{name}\n{value}" for name, value in zip(field_names, field_values)])
|
||||||
issue_data = {
|
issue_data = {
|
||||||
"title": issue_title,
|
"title": issue_title,
|
||||||
|
|
Loading…
Reference in a new issue