Compare commits

..
10 Commits
Author SHA1 Message Date
imcompiling 6a26440c4d Remove view for submit button.
build_develop / build (push) Successful in 38s
build_release / build (push) Successful in 22s
2025-02-26 20:26:42 -05:00
imcompiling 2735d6877f Remove messages intent. 2025-02-26 20:18:21 -05:00
imcompiling 117f5655d7 Merge pull request 'Update docker/login-action action to v3' (#75) from renovate/docker-login-action-3.x into main
build_develop / build (push) Successful in 20s
Reviewed-on: #75
Reviewed-by: imcompiling <[email protected]>
2025-02-25 09:28:16 -05:00
imcompiling c808bb2610 Merge branch 'main' into renovate/docker-login-action-3.x 2025-02-25 09:25:40 -05:00
imcompiling 5e7b3790eb Merge pull request 'Update ghcr.io/astral-sh/uv Docker tag to v0.6.2' (#74) from renovate/ghcr.io-astral-sh-uv-0.x into main
build_develop / build (push) Successful in 51s
Reviewed-on: #74
Reviewed-by: imcompiling <[email protected]>
2025-02-25 09:24:44 -05:00
renovate-bot 07ea150ad3 Update docker/login-action action to v3 2025-02-22 13:05:40 +00:00
renovate-bot 9280bbfbca Update ghcr.io/astral-sh/uv Docker tag to v0.6.2 2025-02-22 13:05:35 +00:00
imcompiling abf076fceb Remove exclude that isn't in this project.
build_develop / build (push) Successful in 36s
2025-02-21 14:05:30 -05:00
imcompiling 0c0997624f Remove guild ids.
build_develop / build (push) Successful in 39s
build_release / build (push) Successful in 21s
2025-02-20 20:29:16 -05:00
imcompiling 67090e0d6f Remove submission from table once handled by admins.
build_develop / build (push) Successful in 32s
build_release / build (push) Successful in 21s
2025-02-20 17:53:14 -05:00
10 changed files with 22 additions and 24 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ jobs:
- name: Install Docker - name: Install Docker
uses: https://github.com/papodaca/install-docker-action@v1 uses: https://github.com/papodaca/install-docker-action@v1
- name: Log into container registry - name: Log into container registry
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
registry: gitea.cheezers.org registry: gitea.cheezers.org
username: imcompiling username: imcompiling
+1 -1
View File
@@ -15,7 +15,7 @@ jobs:
- name: Install Docker - name: Install Docker
uses: https://github.com/papodaca/install-docker-action@v1 uses: https://github.com/papodaca/install-docker-action@v1
- name: Log into container registry - name: Log into container registry
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
registry: gitea.cheezers.org registry: gitea.cheezers.org
username: imcompiling username: imcompiling
+1 -1
View File
@@ -1,7 +1,7 @@
FROM python:3.12.3-slim FROM python:3.12.3-slim
# install uv # install uv
COPY --from=ghcr.io/astral-sh/uv:0.4.30 /uv /uvx /bin/ COPY --from=ghcr.io/astral-sh/uv:0.6.2 /uv /uvx /bin/
RUN apt-get update && apt-get -y upgrade && apt-get -y install sqlite3 RUN apt-get update && apt-get -y upgrade && apt-get -y install sqlite3
+1 -3
View File
@@ -5,7 +5,6 @@ from nextcord.ext import commands
from sqlalchemy import exc, select from sqlalchemy import exc, select
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from cogs.submission.submission_views import SubmissionCreateButton
from database_setup.sql_data_classes import Category, CategoryGroup, engine from database_setup.sql_data_classes import Category, CategoryGroup, engine
from utilities.utils import MAX_LINE_LENGTH, autofill_groups, send_highscore_message from utilities.utils import MAX_LINE_LENGTH, autofill_groups, send_highscore_message
@@ -134,8 +133,7 @@ class CreateCog(commands.Cog, name="Create Cog"):
try: try:
session.add(new_group) session.add(new_group)
session.commit() session.commit()
message: nextcord.Message = await send_highscore_message(session, interaction.guild, new_group) await send_highscore_message(session, interaction.guild, new_group)
await message.edit(view=SubmissionCreateButton(self._bot))
await interaction.response.send_message(f'"{group_name}" has been created!', ephemeral=True) await interaction.response.send_message(f'"{group_name}" has been created!', ephemeral=True)
except exc.IntegrityError: except exc.IntegrityError:
# Category Group already exists in guild # Category Group already exists in guild
+2 -6
View File
@@ -8,7 +8,6 @@ from sqlalchemy import select
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
# pylint: disable=import-error # pylint: disable=import-error
from cogs.submission.submission_views import SubmissionCreateButton
from database_setup.sql_data_classes import CategoryGroup, engine from database_setup.sql_data_classes import CategoryGroup, engine
from utilities.utils import autofill_groups, send_highscore_message from utilities.utils import autofill_groups, send_highscore_message
@@ -50,9 +49,7 @@ class RefreshCog(commands.Cog, name="Refresh Cog"):
) )
group = session.scalar(stmt) group = session.scalar(stmt)
message: nextcord.Message = await send_highscore_message(session, interaction.guild, group) await send_highscore_message(session, interaction.guild, group)
await message.edit(view=SubmissionCreateButton(self._bot))
await interaction.response.send_message(f"Updated group {group.GroupName}!", ephemeral=True) await interaction.response.send_message(f"Updated group {group.GroupName}!", ephemeral=True)
@refresh.subcommand() @refresh.subcommand()
@@ -77,8 +74,7 @@ class RefreshCog(commands.Cog, name="Refresh Cog"):
await interaction.response.defer(ephemeral=True) await interaction.response.defer(ephemeral=True)
for group in session.scalars(stmt): for group in session.scalars(stmt):
message: nextcord.Message = await send_highscore_message(session, interaction.guild, group) await send_highscore_message(session, interaction.guild, group)
await message.edit(view=SubmissionCreateButton(self._bot))
await interaction.send(f"Posted all groups in {interaction.guild.name}'s highscores.", ephemeral=True) await interaction.send(f"Posted all groups in {interaction.guild.name}'s highscores.", ephemeral=True)
+3 -2
View File
@@ -10,7 +10,7 @@ from sqlalchemy.orm import Session
from cogs.submission.verification_view import VerificationView from cogs.submission.verification_view import VerificationView
from database_setup.sql_data_classes import Category, CategoryGroup, Guild, Submission, engine from database_setup.sql_data_classes import Category, CategoryGroup, Guild, Submission, engine
from main import logger from main import logger
from utilities.utils import GUILDS, autofill_categories, autofill_groups, submit_score from utilities.utils import autofill_categories, autofill_groups, submit_score
class SubmissionCog(commands.Cog): class SubmissionCog(commands.Cog):
@@ -19,7 +19,7 @@ class SubmissionCog(commands.Cog):
def __init__(self) -> None: def __init__(self) -> None:
return return
@nextcord.slash_command(guild_ids=GUILDS) @nextcord.slash_command()
async def submit( # noqa: PLR0913 async def submit( # noqa: PLR0913
self, self,
interaction: nextcord.Interaction, interaction: nextcord.Interaction,
@@ -47,6 +47,7 @@ class SubmissionCog(commands.Cog):
group_id (str): Is SlashOption. Group that the score category belongs in. group_id (str): Is SlashOption. Group that the score category belongs in.
category_id (str): Is SlashOption. Category to submit the score in. category_id (str): Is SlashOption. Category to submit the score in.
score (str): Is SlashOption. The score. score (str): Is SlashOption. The score.
proof (nextcord.Attachment): Is SlashOption. Picture to provide proof of score.
username (str, optional): Is SlashOption. Username to associate with the score. username (str, optional): Is SlashOption. Username to associate with the score.
""" """
# fill out username if not passed in # fill out username if not passed in
+11 -1
View File
@@ -1,7 +1,7 @@
"""View for verification buttons.""" """View for verification buttons."""
import nextcord import nextcord
from sqlalchemy import select from sqlalchemy import delete, select
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from database_setup.sql_data_classes import Submission, engine from database_setup.sql_data_classes import Submission, engine
@@ -19,6 +19,14 @@ class VerificationView(nextcord.ui.View):
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny-button-submission") @nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny-button-submission")
async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002 async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
"""Button for denying score submission.""" """Button for denying score submission."""
with Session(engine) as session:
stmt = (
delete(Submission)
.where(Submission.GuildId == interaction.guild_id)
.where(Submission.MessageId == interaction.message.id)
)
session.execute(stmt)
session.commit()
await interaction.message.delete() await interaction.message.delete()
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green, custom_id="approve-button-submission") @nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green, custom_id="approve-button-submission")
@@ -41,6 +49,8 @@ class VerificationView(nextcord.ui.View):
await submit_score( await submit_score(
interaction, submission.GroupId, submission.CategoryId, submission.UserName, submission.Score interaction, submission.GroupId, submission.CategoryId, submission.UserName, submission.Score
) )
session.delete(submission)
session.commit()
content = interaction.message.content content = interaction.message.content
content += f"\nApproved by <@{interaction.user.id}>." content += f"\nApproved by <@{interaction.user.id}>."
# remove the bot information embed. it should always be the first one. # remove the bot information embed. it should always be the first one.
-3
View File
@@ -33,9 +33,6 @@ def main() -> None:
# These need to be enabled in the developer portal as well # These need to be enabled in the developer portal as well
intents = nextcord.Intents.default() intents = nextcord.Intents.default()
# Required in order to read messages (eg. prefix commands)
intents.message_content = True
bot = commands.Bot( bot = commands.Bot(
commands.when_mentioned_or(config.BOT_PREFIX), commands.when_mentioned_or(config.BOT_PREFIX),
intents=intents, intents=intents,
-1
View File
@@ -47,7 +47,6 @@ exclude = [
"node_modules", "node_modules",
"site-packages", "site-packages",
"venv", "venv",
"dakiny-messages", # Don't need to lint this git repo.
] ]
# Same as Black. # Same as Black.
+2 -5
View File
@@ -1,6 +1,4 @@
""" """Contains various utility functions for highscores bot."""
Contains various utlity functions for highscores bot
"""
import time import time
@@ -14,12 +12,11 @@ from database_setup.sql_data_classes import Category, CategoryGroup, Guild, Scor
MAX_LINE_LENGTH = 142 MAX_LINE_LENGTH = 142
GUILDS = [1000247361639030804]
def autofill_categories(guild_id: int, group_id: int, category_begin: str) -> "dict[str, str]": def autofill_categories(guild_id: int, group_id: int, category_begin: str) -> "dict[str, str]":
""" """
Returns all category names that start with category_begin. Returns all category names that start with category_begin.
If category_begin is empty, returns list of all category names. If category_begin is empty, returns list of all category names.
Args: Args: