Compare commits

..
21 Commits
Author SHA1 Message Date
imcompiling 48a91dca3d Merge branch '41-editting-commands'
build_develop / build (push) Successful in 35s
build_release / build (push) Successful in 22s
2025-03-14 17:22:03 -04:00
imcompiling 5eb637a3a8 Indent so that a command can properly use session.
Remove commented out code. Also add work to an issue.
2025-03-14 17:20:50 -04:00
imcompiling f722eb1a83 Add to get's return messages. 2025-03-14 17:05:39 -04:00
imcompiling 7759bbc648 Add to set's return messages. 2025-03-14 17:04:20 -04:00
imcompiling 65de7baeda Added some log statements to provide helpful information. 2025-03-14 16:57:38 -04:00
imcompiling e243404480 Forgot to specify that is a description. 2025-03-14 16:53:15 -04:00
imcompiling f735e6d846 Merge branch '70-sqlmodel'
build_develop / build (push) Successful in 34s
build_release / build (push) Successful in 22s
2025-03-14 16:43:28 -04:00
imcompiling 9fbaf7bcf6 Merge branch 'main' of https://gitea.cheezers.org/imcompiling/agon
build_develop / build (push) Has been cancelled
2025-03-14 16:42:48 -04:00
imcompiling 1959e11e5c Merge branch '70-sqlmodel' into 41-editting-commands 2025-03-14 16:42:33 -04:00
imcompiling c25d354fc0 Correct some parameter usage, handle errors if searches return nothing. 2025-03-14 16:09:52 -04:00
imcompiling e5d90a71d9 Correct parameter usage. 2025-03-14 16:02:18 -04:00
imcompiling 74ce22dd26 Was saving the message id to the wrong spot. 2025-03-13 00:39:47 -04:00
imcompiling 170ce1cbfb Use correct message id reference. 2025-03-12 21:30:56 -04:00
imcompiling e1b761e848 Use correct variable for guild name. 2025-03-12 21:29:01 -04:00
imcompiling 68592a7df8 Typo on col usage. 2025-03-12 21:27:29 -04:00
imcompiling b28938f66a Had col around the wrong variables. 2025-03-12 21:27:12 -04:00
imcompiling 3abbff13d5 Use walrus operator when assigning and checking for None. 2025-03-12 09:50:58 -04:00
imcompiling f52b2fe49f Merge pull request 'Update ghcr.io/astral-sh/uv Docker tag to v0.6.5' (#81) from renovate/ghcr.io-astral-sh-uv-0.x into main
build_develop / build (push) Successful in 48s
Reviewed-on: #81
Reviewed-by: imcompiling <[email protected]>
2025-03-10 08:40:41 -04:00
renovate-bot 24a9fa998a Update ghcr.io/astral-sh/uv Docker tag to v0.6.5 2025-03-09 05:01:04 +00:00
imcompiling 63db4c1dd2 Merge pull request 'Update ghcr.io/astral-sh/uv Docker tag to v0.6.3' (#79) from renovate/ghcr.io-astral-sh-uv-0.x into main
build_develop / build (push) Successful in 51s
Reviewed-on: #79
Reviewed-by: imcompiling <[email protected]>
2025-03-03 23:03:42 -05:00
renovate-bot 8604ba2547 Update ghcr.io/astral-sh/uv Docker tag to v0.6.3 2025-03-02 05:01:27 +00:00
6 changed files with 50 additions and 30 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
"ondelete" "ondelete"
], ],
"python.analysis.diagnosticSeverityOverrides": { "python.analysis.diagnosticSeverityOverrides": {
"reportOptionalMemberAccess": false, "reportOptionalMemberAccess": "warning",
"reportArgumentType": "information", "reportArgumentType": "information",
"reportAttributeAccessIssue": "warning" "reportAttributeAccessIssue": "warning"
} }
+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.6.2 /uv /uvx /bin/ COPY --from=ghcr.io/astral-sh/uv:0.6.5 /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
+6 -4
View File
@@ -50,7 +50,7 @@ class GetCog(commands.Cog, name="Get command."):
return return
await interaction.response.send_message( await interaction.response.send_message(
f"{category.name} is sorted in {'ascending' if category.is_ascending else 'descending'} order.", f"**{category.name}** is sorted in **{'ascending' if category.is_ascending else 'descending'}** order.",
ephemeral=True, ephemeral=True,
) )
@@ -109,7 +109,9 @@ class GetCog(commands.Cog, name="Get command."):
await interaction.response.send_message("Group or Category was not found.", ephemeral=True) await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
return return
await interaction.response.send_message(f"{category.name} has a size of {category.size}.", ephemeral=True) await interaction.response.send_message(
f"**{category.name}** has a size of **{category.size}**.", ephemeral=True
)
@get.subcommand(description="Commands for getting group information.") @get.subcommand(description="Commands for getting group information.")
async def group(self, interaction: nextcord.Interaction) -> None: async def group(self, interaction: nextcord.Interaction) -> None:
@@ -136,7 +138,7 @@ class GetCog(commands.Cog, name="Get command."):
return return
await interaction.response.send_message( await interaction.response.send_message(
f"{group.name} has a pad length of {group.pad_length}.", ephemeral=True f"**{group.name}** has a pad length of **{group.pad_length}**.", ephemeral=True
) )
@group.subcommand(description="Get the username length of a group.") @group.subcommand(description="Get the username length of a group.")
@@ -162,7 +164,7 @@ class GetCog(commands.Cog, name="Get command."):
return return
await interaction.response.send_message( await interaction.response.send_message(
f"{group.name} has a username length of {group.username_length}.", ephemeral=True f"**{group.name}** has a username length of **{group.username_length}**.", ephemeral=True
) )
@is_ascending.on_autocomplete("category_id") @is_ascending.on_autocomplete("category_id")
+37 -22
View File
@@ -22,7 +22,7 @@ class SetCog(commands.Cog, name="Set command."):
async def set(self, interaction: nextcord.Interaction) -> None: async def set(self, interaction: nextcord.Interaction) -> None:
"""Parent slash command for setting settings. Never called.""" """Parent slash command for setting settings. Never called."""
@set.subcommand("Commands for editing a category.") @set.subcommand(description="Commands for editing a category.")
async def category(self, interaction: nextcord.Interaction) -> None: async def category(self, interaction: nextcord.Interaction) -> None:
"""Parent slash subcommand for setting category settings. Never called.""" """Parent slash subcommand for setting category settings. Never called."""
@@ -54,7 +54,6 @@ class SetCog(commands.Cog, name="Set command."):
await interaction.response.send_message("Category or Group was not found.", ephemeral=True) await interaction.response.send_message("Category or Group was not found.", ephemeral=True)
return return
category.size = size category.size = size
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
session.commit() session.commit()
# Use the relationship to get group category is in. # Use the relationship to get group category is in.
@@ -67,7 +66,9 @@ class SetCog(commands.Cog, name="Set command."):
return return
await send_highscore_message(session, interaction.guild, group) await send_highscore_message(session, interaction.guild, group)
await interaction.response.send_message(f"{category.name} size has been updated to {size}.", ephemeral=True) await interaction.response.send_message(
f"**{category.name}** size has been updated to **{size}**.", ephemeral=True
)
@category.subcommand(description="Update the is_ascending value for a category.") @category.subcommand(description="Update the is_ascending value for a category.")
async def is_ascending( async def is_ascending(
@@ -99,7 +100,6 @@ class SetCog(commands.Cog, name="Set command."):
await interaction.response.send_message("Category or Group was not found.", ephemeral=True) await interaction.response.send_message("Category or Group was not found.", ephemeral=True)
return return
category.is_ascending = ascending category.is_ascending = ascending
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
session.commit() session.commit()
# Use the relationship to get group category is in. # Use the relationship to get group category is in.
@@ -113,7 +113,7 @@ class SetCog(commands.Cog, name="Set command."):
await send_highscore_message(session, interaction.guild, group) await send_highscore_message(session, interaction.guild, group)
await interaction.response.send_message( await interaction.response.send_message(
f"{category.name} is_ascending has been updated to {ascending}.", ephemeral=True f"**{category.name}** is_ascending has been updated to **{ascending}**.", ephemeral=True
) )
@category.subcommand(description="Update the is_validated value for a category.") @category.subcommand(description="Update the is_validated value for a category.")
@@ -146,12 +146,11 @@ class SetCog(commands.Cog, name="Set command."):
await interaction.response.send_message("Category or Group was not found.", ephemeral=True) await interaction.response.send_message("Category or Group was not found.", ephemeral=True)
return return
category.is_validated = validated category.is_validated = validated
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
session.commit() session.commit()
await interaction.response.send_message( await interaction.response.send_message(
f"{category.name} is_validated has been updated to {validated}.", ephemeral=True f"**{category.name}** is_validated has been updated to **{validated}**.", ephemeral=True
) )
@category.subcommand(name="name", description="Change the name of a category.") @category.subcommand(name="name", description="Change the name of a category.")
async def category_name( async def category_name(
@@ -182,7 +181,6 @@ class SetCog(commands.Cog, name="Set command."):
return return
old_name = category.name old_name = category.name
category.name = name category.name = name
# session.add(category) test if this is needed. SQLAlchemy can do the update without adding.
session.commit() session.commit()
# Use the relationship to get group category is in. # Use the relationship to get group category is in.
@@ -195,7 +193,9 @@ class SetCog(commands.Cog, name="Set command."):
return return
await send_highscore_message(session, interaction.guild, group) await send_highscore_message(session, interaction.guild, group)
await interaction.response.send_message(f"{old_name} has been updated to {category.name}.", ephemeral=True) await interaction.response.send_message(
f"**{old_name}** has been updated to **{category.name}**.", ephemeral=True
)
@set.subcommand(description="Commands for editing a group.") @set.subcommand(description="Commands for editing a group.")
async def group(self, interaction: nextcord.Interaction) -> None: async def group(self, interaction: nextcord.Interaction) -> None:
@@ -228,7 +228,7 @@ class SetCog(commands.Cog, name="Set command."):
session.commit() session.commit()
await send_highscore_message(session, interaction.guild, group) await send_highscore_message(session, interaction.guild, group)
await interaction.response.send_message(f"{old_name} has been updated to {group.name}.", ephemeral=True) await interaction.response.send_message(f"**{old_name}** has been updated to **{group.name}**.", ephemeral=True)
@group.subcommand(description="Registers the channel for a Group's messages.") @group.subcommand(description="Registers the channel for a Group's messages.")
async def output_channel( async def output_channel(
@@ -259,9 +259,14 @@ class SetCog(commands.Cog, name="Set command."):
.where(col(CategoryGroup.guild_id) == interaction.guild_id) .where(col(CategoryGroup.guild_id) == interaction.guild_id)
.where(col(CategoryGroup.id) == int(group_id)) .where(col(CategoryGroup.id) == int(group_id))
) )
group = session.scalar(stmt) if (group := session.scalar(stmt)) is None:
group.ChannelId = channel_id await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
return
group.channel_id = channel_id
session.commit() session.commit()
# TODO(imcompiling): delete the message and call send_highscore_message to send a new one. Bug needs fixed
# first.
# 082
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True) await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
@group.subcommand( @group.subcommand(
@@ -296,10 +301,11 @@ class SetCog(commands.Cog, name="Set command."):
if (group := session.scalar(stmt)) is None: if (group := session.scalar(stmt)) is None:
await interaction.response.send_message("Group was not found.", ephemeral=True) await interaction.response.send_message("Group was not found.", ephemeral=True)
return return
group.PadLength = length
group.pad_length = length
session.commit() session.commit()
await interaction.response.send_message( await interaction.response.send_message(
f"Category pad length set to {length} for {group.name}", ephemeral=True f"Category pad length set to **{length}** for **{group.name}**.", ephemeral=True
) )
await send_highscore_message(session, interaction.guild, group) await send_highscore_message(session, interaction.guild, group)
@@ -328,7 +334,9 @@ class SetCog(commands.Cog, name="Set command."):
with Session(engine) as session: with Session(engine) as session:
stmt = select(Guild).where(col(Guild.id) == interaction.guild_id) stmt = select(Guild).where(col(Guild.id) == interaction.guild_id)
guild = session.scalar(stmt) if (guild := session.scalar(stmt)) is None:
await interaction.response.send_message("Guild was not found.", ephemeral=True)
return
guild.submission_channel = channel_id guild.submission_channel = channel_id
session.commit() session.commit()
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True) await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
@@ -358,10 +366,15 @@ class SetCog(commands.Cog, name="Set command."):
.where(col(CategoryGroup.guild_id) == interaction.guild_id) .where(col(CategoryGroup.guild_id) == interaction.guild_id)
.where(col(CategoryGroup.id) == int(group_id)) .where(col(CategoryGroup.id) == int(group_id))
) )
group = session.scalar(stmt) if (group := session.scalar(stmt)) is None:
group.UsernameLength = length await interaction.response.send_message("Group or Category was not found.", ephemeral=True)
return
group.username_length = length
session.commit() session.commit()
await interaction.response.send_message(f"Username length set to {length}.", ephemeral=True) await interaction.response.send_message(
f"Username length for **{group.name}** set to **{length}**.", ephemeral=True
)
@set.subcommand(description="Registers the channel for verification messages.") @set.subcommand(description="Registers the channel for verification messages.")
async def verify_channel( async def verify_channel(
@@ -386,8 +399,10 @@ class SetCog(commands.Cog, name="Set command."):
with Session(engine) as session: with Session(engine) as session:
stmt = select(Guild).where(col(Guild.id) == interaction.guild_id) stmt = select(Guild).where(col(Guild.id) == interaction.guild_id)
guild = session.scalar(stmt) if (guild := session.scalar(stmt)) is None:
guild.VerificationChannel = channel_id await interaction.response.send_message("Guild was not found.", ephemeral=True)
return
guild.verification_channel = channel_id
session.commit() session.commit()
await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True) await interaction.send(f"Registered <#{channel_id}>.", ephemeral=True)
+3
View File
@@ -2,13 +2,16 @@
from sqlmodel import SQLModel, create_engine from sqlmodel import SQLModel, create_engine
from utilities import config from utilities import config
from utilities.logger import agon_logger
from . import models # noqa: F401 - Need this import for creating the models. from . import models # noqa: F401 - Need this import for creating the models.
if config.ENVIRONMENT == "prod": if config.ENVIRONMENT == "prod":
url = f"mysql+pymysql://{config.SQL_USER}:{config.SQL_PASS}@{config.SQL_HOST}/{config.SQL_DB}" url = f"mysql+pymysql://{config.SQL_USER}:{config.SQL_PASS}@{config.SQL_HOST}/{config.SQL_DB}"
agon_logger.info("Connected to prod database.")
else: else:
url = "sqlite:///database.db" url = "sqlite:///database.db"
agon_logger.info("Connected to local dev database.")
engine = create_engine(url) engine = create_engine(url)
# Don't need to create all when connected to prod. # Don't need to create all when connected to prod.
+1 -1
View File
@@ -398,7 +398,7 @@ async def submit_score(
existing_score = session.scalar(stmt) existing_score = session.scalar(stmt)
if existing_score: if existing_score:
existing_score.Score = score_f existing_score.score = score_f
else: else:
score_obj = Score(username=username, score=score_f, category_id=category_id) score_obj = Score(username=username, score=score_f, category_id=category_id)
session.add(score_obj) session.add(score_obj)