Compare commits

...
13 Commits
Author SHA1 Message Date
imcompiling ff85c8d485 Bugfix in record command. Missed moving a positional argument.
build_latest / build (push) Successful in 1m36s
build_release / build (push) Successful in 17s
build_develop / build (push) Successful in 24s
2024-05-26 20:06:43 -04:00
imcompiling ca0d27a929 Update dockerfile image. Need python3.12
build_latest / build (push) Successful in 1m47s
build_release / build (push) Successful in 23s
2024-05-24 14:19:17 -04:00
imcompiling 8ebb689ee7 Merge branch '63-bad-sorting'
build_latest / build (push) Failing after 31s
build_release / build (push) Failing after 29s
2024-05-24 14:11:44 -04:00
imcompiling ecc81c5f35 Sort the council member info.
build_develop / build (push) Failing after 31s
2024-05-24 14:03:23 -04:00
imcompiling 96c1fcb17c Sort all members by lowercase display name. 2024-05-24 13:58:25 -04:00
imcompiling 840e17e03a Adjust the presence because I can. Easier to understand.
build_develop / build (push) Failing after 29s
2024-05-24 13:56:39 -04:00
imcompiling f744d0d387 Merge branch '52-update-packages'
build_latest / build (push) Failing after 30s
build_release / build (push) Failing after 28s
2024-05-24 13:39:56 -04:00
imcompiling 9c71d24fe3 Unneeded file.
build_develop / build (push) Failing after 36s
2024-05-24 13:36:56 -04:00
imcompiling cdc335936c update dependencies
build_develop / build (push) Failing after 30s
2024-05-22 23:35:40 -04:00
imcompiling 303f0aa804 Update python, sqlalchemy, pandas, and nextcord. 2024-05-22 23:16:22 -04:00
imcompiling bc743cbb1a Merge branch 'fix-ruff-lint-smells'
build_latest / build (push) Successful in 18s
build_release / build (push) Successful in 19s
build_develop / build (push) Successful in 16s
2024-05-22 23:01:08 -04:00
imcompiling ed0895056d remove quotes from type annotation.
build_develop / build (push) Successful in 1m23s
2024-05-22 22:48:54 -04:00
imcompiling 985e253954 edits to the pyproject.
build_develop / build (push) Successful in 1m23s
2024-05-22 21:59:12 -04:00
10 changed files with 36 additions and 30 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM python:3.11.9-slim FROM python:3.12.3-slim
# install dependencies # install dependencies
RUN apt-get update && apt-get -y upgrade && apt-get -y install git sqlite3 RUN apt-get update && apt-get -y upgrade && apt-get -y install git sqlite3
+2 -2
View File
@@ -141,7 +141,7 @@ class VoteHighcouncilView(nextcord.ui.View):
) )
for nominee in sorted( for nominee in sorted(
session.scalars(stmt), session.scalars(stmt),
key=lambda nominee: self.guild.get_member(nominee).display_name, key=lambda nominee: self.guild.get_member(nominee).display_name.lower(),
) )
] ]
options.append( options.append(
@@ -213,7 +213,7 @@ class VoteHighcouncilView(nextcord.ui.View):
) )
for nominee in sorted( for nominee in sorted(
session.scalars(stmt), session.scalars(stmt),
key=lambda nominee: self.guild.get_member(nominee).display_name, key=lambda nominee: self.guild.get_member(nominee).display_name.lower(),
) )
] ]
options.append( options.append(
+1 -1
View File
@@ -130,7 +130,7 @@ class VoteView(nextcord.ui.View):
) )
for nominee in sorted( for nominee in sorted(
session.scalars(stmt), session.scalars(stmt),
key=lambda nominee: self.guild.get_member(nominee).display_name, key=lambda nominee: self.guild.get_member(nominee).display_name.lower(),
) )
] ]
options.append( options.append(
+1 -1
View File
@@ -109,8 +109,8 @@ class EventView(nextcord.ui.View):
record_event_points( record_event_points(
self.config, self.config,
discord_users_list, discord_users_list,
True, # noqa: FBT003
self.config.params.event_participate_points, self.config.params.event_participate_points,
is_member=True,
) )
non_discord_users = interaction.message.embeds[0].fields[1].value non_discord_users = interaction.message.embeds[0].fields[1].value
+2 -2
View File
@@ -54,14 +54,14 @@ class RemoveCog(commands.Cog, name="Remove Commands"):
""" """
with Session(engine) as session: with Session(engine) as session:
stmt = select(Presences) stmt = select(Presences)
presences_dict: "dict[str,str]" = {pres.Presence: str(pres.Id) for pres in session.scalars(stmt)} presences_dict: dict[str,str] = {pres.Presence: str(pres.Id) for pres in session.scalars(stmt)}
# if empty compare string # if empty compare string
if not presence_str: if not presence_str:
await interaction.response.send_autocomplete(dict(list(presences_dict.items())[:25])) await interaction.response.send_autocomplete(dict(list(presences_dict.items())[:25]))
return return
autofilled_presences: "dict[str,str]" = { autofilled_presences: dict[str,str] = {
pres: pres_id for pres, pres_id in presences_dict.items() if presence_str.lower() in pres.lower() pres: pres_id for pres, pres_id in presences_dict.items() if presence_str.lower() in pres.lower()
} }
await interaction.response.send_autocomplete(autofilled_presences[:25]) await interaction.response.send_autocomplete(autofilled_presences[:25])
+3 -3
View File
@@ -74,7 +74,7 @@ class ViewCog(commands.Cog, name="View Commands"):
sorted_members = members.sort_values( sorted_members = members.sort_values(
by="UserId", by="UserId",
key=lambda user_ids: ( key=lambda user_ids: (
[interaction.guild.get_member(int(user_id)).display_name for user_id in user_ids] [interaction.guild.get_member(int(user_id)).display_name.lower() for user_id in user_ids]
), ),
) )
sorted_non_members = non_members.sort_values(by="UserId") sorted_non_members = non_members.sort_values(by="UserId")
@@ -184,7 +184,7 @@ class ViewCog(commands.Cog, name="View Commands"):
await interaction.response.send_autocomplete(list(elections)[:25]) await interaction.response.send_autocomplete(list(elections)[:25])
return return
autofilled_elections: "list[str]" = [ autofilled_elections: list[str] = [
election for election in elections if election.lower().startswith(election_name.lower()) election for election in elections if election.lower().startswith(election_name.lower())
] ]
await interaction.response.send_autocomplete(autofilled_elections[:25]) await interaction.response.send_autocomplete(autofilled_elections[:25])
@@ -207,7 +207,7 @@ class ViewCog(commands.Cog, name="View Commands"):
await interaction.response.send_autocomplete(list(quarters)[:25]) await interaction.response.send_autocomplete(list(quarters)[:25])
return return
autofilled_quarters: "list[str]" = [ autofilled_quarters: list[str] = [
quarter for quarter in quarters if quarter.lower().startswith(quarter_name.lower()) quarter for quarter in quarters if quarter.lower().startswith(quarter_name.lower())
] ]
await interaction.response.send_autocomplete(autofilled_quarters[:25]) await interaction.response.send_autocomplete(autofilled_quarters[:25])
+1 -1
View File
@@ -35,4 +35,4 @@ class BotPresence(commands.Cog, name="Bot Presence"):
with Session(engine) as session: with Session(engine) as session:
presence = session.scalar(select(Presences.Presence).order_by(func.random())) presence = session.scalar(select(Presences.Presence).order_by(func.random()))
await self.bot.change_presence(activity=nextcord.CustomActivity(name="Custom Status", state=presence)) await self.bot.change_presence(activity=nextcord.CustomActivity(presence))
+15 -10
View File
@@ -4,20 +4,25 @@ version = "0.1.0"
description = "Dakiny's Discord Bot." description = "Dakiny's Discord Bot."
authors = ["imcompiling <[email protected]>"] authors = ["imcompiling <[email protected]>"]
readme = "README.md" readme = "README.md"
package-mode = false
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.11" python = "^3.12"
gitpython = "3.1.43" gitpython = "^3.1.43"
fastapi = "0.111.0" fastapi = "^0.111.0"
hydra-core = "1.3.2" hydra-core = "^1.3.2"
nextcord = "2.4.2" nextcord = "^2.6.0"
pandas = "1.5.2" pandas = "^2.2.2"
python-dotenv = "1.0.0" python-dotenv = "^1.0.1"
pytz = "2022.7.1" pytz = "^2024.1"
sqlalchemy = "1.4.46" sqlalchemy = "^2.0.30"
aiofiles = "^23.2.1" aiofiles = "^23.2.1"
setuptools = "^70.0.0"
[tool.poetry.group.dev.dependencies]
ruff = "^0.4.5"
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
@@ -59,7 +64,7 @@ line-length = 120
indent-width = 4 indent-width = 4
# Assume Python 3.8 # Assume Python 3.8
target-version = "py311" target-version = "py312"
[tool.ruff.lint] [tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
-1
View File
@@ -1 +0,0 @@
python-3.10.4
+10 -8
View File
@@ -47,12 +47,10 @@ def get_datetime(day: str) -> datetime:
day = int(day.split("/")[1]) day = int(day.split("/")[1])
# ensure that year rolls over if current month is December and the next month is less than 12. # ensure that year rolls over if current month is December and the next month is less than 12.
# TODO(imcompiling): replace with Calendar.DECEMBER when updating to python 3.12 if today.month == calendar.DECEMBER and month < calendar.DECEMBER:
# https://gitea.cheezers.org/imcompiling/dakiny-bot/issues/52
if today.month == 12 and month < 12:
year += 1 year += 1
if today.month == 1 and month > 1: if today.month == calendar.JANUARY and month > calendar.JANUARY:
year -= 1 year -= 1
return datetime(year, month, day, tzinfo=UTC) return datetime(year, month, day, tzinfo=UTC)
@@ -153,7 +151,7 @@ def build_votes_str(config: DakinyConfig, guild: nextcord.Guild) -> str:
for nominee in sorted( for nominee in sorted(
session.scalars(stmt), session.scalars(stmt),
key=lambda nominee: guild.get_member(nominee.MemberId).display_name, key=lambda nominee: guild.get_member(nominee.MemberId).display_name.lower(),
): ):
votes[nominee.MemberId] = 0 votes[nominee.MemberId] = 0
@@ -194,7 +192,7 @@ def build_highcouncil_votes_str(config: DakinyConfig, guild: nextcord.Guild) ->
for nominee in sorted( for nominee in sorted(
session.scalars(stmt), session.scalars(stmt),
key=lambda nominee: guild.get_member(nominee.MemberId).display_name, key=lambda nominee: guild.get_member(nominee.MemberId).display_name.lower(),
): ):
cl_votes[nominee.MemberId] = 0 cl_votes[nominee.MemberId] = 0
@@ -212,7 +210,7 @@ def build_highcouncil_votes_str(config: DakinyConfig, guild: nextcord.Guild) ->
for nominee in sorted( for nominee in sorted(
session.scalars(stmt), session.scalars(stmt),
key=lambda nominee: guild.get_member(nominee.MemberId).display_name, key=lambda nominee: guild.get_member(nominee.MemberId).display_name.lower(),
): ):
dm_votes[nominee.MemberId] = 0 dm_votes[nominee.MemberId] = 0
@@ -541,8 +539,12 @@ async def edit_clan_council_info(guild: nextcord.Guild, config: DakinyConfig) ->
.where(CouncilMembers.Elected == true()) .where(CouncilMembers.Elected == true())
) )
council_member_ids = sorted(
session.scalars(stmt), key=lambda user_id: guild.get_member(user_id).display_name.lower()
)
council_members_strs = [ council_members_strs = [
f"<@{user_id}>" for user_id in session.scalars(stmt) if user_id not in (discord_manager, clan_leader) f"<@{user_id}>" for user_id in council_member_ids if user_id not in (discord_manager, clan_leader)
] ]
quarter = get_quarter_name(config) quarter = get_quarter_name(config)