From 2b5331e488ece2e63eacafe7be4ad3ca7b990a5b Mon Sep 17 00:00:00 2001 From: nova Date: Tue, 12 Nov 2024 13:22:58 +0000 Subject: [PATCH 1/7] Update requirements --- Dockerfile | 4 ++-- requirements.txt | 8 ++++---- requirements_dev.txt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 10415ec..209bd8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM python:3.10.13-alpine3.18 +FROM python:3.12.7-alpine3.20 WORKDIR /app -COPY requirements.txt ./ +COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt diff --git a/requirements.txt b/requirements.txt index 35a4d0b..22bdb85 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ +fortune-python==1.1.1 hikari==2.1.0 -hikari-arc==1.3.4 -hikari-miru==4.1.1 -python-dotenv==1.0.1 +hikari-arc==1.4.0 +hikari-miru==4.2.0 pyfiglet==1.0.2 -fortune-python==1.1.1 +python-dotenv==1.0.1 diff --git a/requirements_dev.txt b/requirements_dev.txt index 0d45ea9..28ccc66 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,2 +1,2 @@ -ruff==0.6.9 -pre-commit==4.0.0 +ruff==0.7.3 +pre-commit==4.0.1 From 4b0afd79bd6a3571362d89385e838ff997530838 Mon Sep 17 00:00:00 2001 From: nova Date: Tue, 12 Nov 2024 13:23:24 +0000 Subject: [PATCH 2/7] Update environment variables --- .env.sample | 1 + .github/deploy/production.hcl | 2 +- .github/deploy/review.hcl | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.env.sample b/.env.sample index f656e0f..575cdfb 100644 --- a/.env.sample +++ b/.env.sample @@ -1 +1,2 @@ TOKEN= +DEBUG= diff --git a/.github/deploy/production.hcl b/.github/deploy/production.hcl index d03fdca..97dbfe7 100644 --- a/.github/deploy/production.hcl +++ b/.github/deploy/production.hcl @@ -24,7 +24,7 @@ job "blockbot" { template { data = < Date: Tue, 12 Nov 2024 13:23:45 +0000 Subject: [PATCH 3/7] Add ruff config --- pyproject.toml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..37df71c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[tool.ruff] +target-version = "py312" + +[tool.ruff.format] +docstring-code-format = true +line-ending = "lf" + +[tool.ruff.lint.pydocstyle] +convention = "numpy" From a80ca793b9a30def85cbdc56991d0c300dcfc37d Mon Sep 17 00:00:00 2001 From: nova Date: Tue, 12 Nov 2024 13:24:47 +0000 Subject: [PATCH 4/7] Format code --- README.md | 1 - src/examples/commands.py | 4 +++- src/examples/components.py | 25 ++++++++++++++++++++----- src/examples/modals.py | 4 +++- src/examples/options.py | 24 +++++++++++++++++++----- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f755d58..39a922d 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,3 @@ Blockbot is a Discord bot, written in Python, that is maintained by the [Redbric ## Documentation Development documentation is hosted on the [Redbrick docs](https://docs.redbrick.dcu.ie/webgroup/blockbot/). - diff --git a/src/examples/commands.py b/src/examples/commands.py index 546f6a5..4103d81 100644 --- a/src/examples/commands.py +++ b/src/examples/commands.py @@ -10,7 +10,9 @@ async def hello(ctx: arc.GatewayContext) -> None: await ctx.respond("Hello from hikari and hikari-arc!") -group = plugin.include_slash_group("base_group", "A base command group, with sub groups and sub commands.") +group = plugin.include_slash_group( + "base_group", "A base command group, with sub groups and sub commands." +) @group.include diff --git a/src/examples/components.py b/src/examples/components.py index c4781e9..d6f44e5 100644 --- a/src/examples/components.py +++ b/src/examples/components.py @@ -23,10 +23,20 @@ async def click_button(self, ctx: miru.ViewContext, button: miru.Button) -> None max_values=3, options=[ miru.SelectOption(label=colour) - for colour in ["Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"] + for colour in [ + "Red", + "Orange", + "Yellow", + "Green", + "Blue", + "Indigo", + "Violet", + ] ], ) - async def colour_select(self, ctx: miru.ViewContext, select: miru.TextSelect) -> None: + async def colour_select( + self, ctx: miru.ViewContext, select: miru.TextSelect + ) -> None: await ctx.respond(f"Your favourite colours are: {', '.join(select.values)}!") # Defining a custom view check: https://miru.hypergonial.com/guides/checks_timeout/#checks @@ -35,7 +45,9 @@ async def view_check(self, ctx: miru.ViewContext) -> bool: # user who originally ran the command. # For every other user they will receive an error message. if ctx.user.id != self.user_id: - await ctx.respond("You can't press this!", flags=hikari.MessageFlag.EPHEMERAL) + await ctx.respond( + "You can't press this!", flags=hikari.MessageFlag.EPHEMERAL + ) return False return True @@ -44,7 +56,8 @@ async def view_check(self, ctx: miru.ViewContext) -> bool: # Editing view items: https://miru.hypergonial.com/guides/editing_items/ async def on_timeout(self) -> None: message = self.message - assert message # Since the view is bound to a message, we can assert it's not None + # Since the view is bound to a message, we can assert it's not None + assert message for item in self.children: item.disabled = True @@ -55,7 +68,9 @@ async def on_timeout(self) -> None: @plugin.include @arc.slash_command("components", "A command with components.") -async def components_cmd(ctx: arc.GatewayContext, miru_client: miru.Client = arc.inject()) -> None: +async def components_cmd( + ctx: arc.GatewayContext, miru_client: miru.Client = arc.inject() +) -> None: view = View(ctx.user.id) response = await ctx.respond("Here are some components...", components=view) diff --git a/src/examples/modals.py b/src/examples/modals.py index 80c02ce..aff22eb 100644 --- a/src/examples/modals.py +++ b/src/examples/modals.py @@ -30,7 +30,9 @@ async def callback(self, ctx: miru.ModalContext) -> None: @plugin.include @arc.slash_command("modal", "A command with a modal response.") -async def modal_command(ctx: arc.GatewayContext, miru_client: miru.Client = arc.inject()) -> None: +async def modal_command( + ctx: arc.GatewayContext, miru_client: miru.Client = arc.inject() +) -> None: modal = MyModal() builder = modal.build_response(miru_client) diff --git a/src/examples/options.py b/src/examples/options.py index c1ac576..af91dac 100644 --- a/src/examples/options.py +++ b/src/examples/options.py @@ -10,19 +10,33 @@ async def options( ctx: arc.GatewayContext, str_option: arc.Option[str, arc.StrParams("A string option.", name="string")], - int_option: arc.Option[int, arc.IntParams("An integer option.", name="integer", min=5, max=150)], - attachment_option: arc.Option[hikari.Attachment, arc.AttachmentParams("An attachment option.", name="attachment")], + int_option: arc.Option[ + int, arc.IntParams("An integer option.", name="integer", min=5, max=150) + ], + attachment_option: arc.Option[ + hikari.Attachment, + arc.AttachmentParams("An attachment option.", name="attachment"), + ], channel_option: arc.Option[ - hikari.TextableChannel | None, arc.ChannelParams("A textable channel option.", name="channel") + hikari.TextableChannel | None, + arc.ChannelParams("A textable channel option.", name="channel"), ] = None, ) -> None: """A command with lots of options.""" - embed = hikari.Embed(title="There are a lot of options here", description="Maybe too many...", colour=0x5865F2) + embed = hikari.Embed( + title="There are a lot of options here", + description="Maybe too many...", + colour=0x5865F2, + ) embed.set_image(attachment_option) embed.add_field("String option", str_option, inline=True) embed.add_field("Integer option", str(int_option), inline=True) - embed.add_field("Channel option", f"<#{channel_option.id}>" if channel_option else "Not supplied", inline=True) + embed.add_field( + "Channel option", + f"<#{channel_option.id}>" if channel_option else "Not supplied", + inline=True, + ) await ctx.respond(embed=embed) From aa60038a8a9c400240febff0121460032df62352 Mon Sep 17 00:00:00 2001 From: nova Date: Tue, 12 Nov 2024 13:36:40 +0000 Subject: [PATCH 5/7] Update ruff version for pre commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 601cfa3..6fad213 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.0 + rev: v0.7.3 hooks: - id: ruff args: [ --fix ] From 620f2925a7f5347eefdee080d2cb1af3bc58eb3a Mon Sep 17 00:00:00 2001 From: nova Date: Tue, 12 Nov 2024 13:43:02 +0000 Subject: [PATCH 6/7] Add newline --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6fad213..508f4df 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,4 +4,4 @@ repos: hooks: - id: ruff args: [ --fix ] - - id: ruff-format \ No newline at end of file + - id: ruff-format From b54799f68b4dc28fe8039936da859179d6ccb4b3 Mon Sep 17 00:00:00 2001 From: nova <110734810+novanai@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:56:35 +0000 Subject: [PATCH 7/7] Remove DEBUG env var Co-authored-by: wizzdom --- .github/deploy/production.hcl | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/deploy/production.hcl b/.github/deploy/production.hcl index 97dbfe7..3ad0675 100644 --- a/.github/deploy/production.hcl +++ b/.github/deploy/production.hcl @@ -24,7 +24,6 @@ job "blockbot" { template { data = <