Compare commits
102
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be7bffb866 | ||
|
|
aaef1f249f | ||
|
|
4936013697 | ||
|
|
945f5766d5 | ||
|
|
8727c0d6f6 | ||
|
|
64e2c10b39 | ||
|
|
3d44c5c905 | ||
|
|
6653bb9bdd | ||
|
|
f5b45b8cab | ||
|
|
412a81db6e | ||
|
|
8069176128 | ||
|
|
5b5e699f7a | ||
|
|
3b0535663a | ||
|
|
6fd61c79cc | ||
|
|
c2c2b132e1 | ||
|
|
66f3d797fd | ||
|
|
ccc489dbaf | ||
|
|
d0961bb9f0 | ||
|
|
83b11206da | ||
|
|
6f28f09b66 | ||
|
|
e1508e6f31 | ||
|
|
be88f1e179 | ||
|
|
ae64ab6dde | ||
|
|
a76df955ec | ||
|
|
2473d258ff | ||
|
|
9c94704fbd | ||
|
|
0c62678797 | ||
|
|
0528eea5cd | ||
|
|
2836237b76 | ||
|
|
4c741136cc | ||
|
|
b221f1e438 | ||
|
|
1b08ba1355 | ||
|
|
e191df1a38 | ||
|
|
e35a2a8c8d | ||
|
|
d7046e4595 | ||
|
|
70037fb47a | ||
|
|
4ae3866e44 | ||
|
|
1349813f0d | ||
|
|
294b672fe2 | ||
|
|
72349a4cae | ||
|
|
f6e9d3c32e | ||
|
|
7c8455bf29 | ||
|
|
f4c4a0435b | ||
|
|
bbc63dd77a | ||
|
|
7ed3f0d613 | ||
|
|
eb6a8c7479 | ||
|
|
58b230afe6 | ||
|
|
fb8dfef55e | ||
|
|
487d174b6d | ||
|
|
abb50d71b4 | ||
|
|
7409e2fd2d | ||
|
|
6a67804937 | ||
|
|
4f4d76d151 | ||
|
|
f3985b5d21 | ||
|
|
142cc337a0 | ||
|
|
fd1d1c075e | ||
|
|
e3ffafcff2 | ||
|
|
855f3c1df8 | ||
|
|
a3371e9e8c | ||
|
|
a158248a35 | ||
|
|
886ac2f7ee | ||
|
|
f06033d2ec | ||
|
|
2ffc4126d2 | ||
|
|
4280ddd841 | ||
|
|
58c167bbe3 | ||
|
|
303e359c32 | ||
|
|
fb460ccc2c | ||
|
|
c5e4a94cd2 | ||
|
|
f95955dc7f | ||
|
|
dfea936aaa | ||
|
|
1df639499c | ||
|
|
be3ec007af | ||
|
|
e8839d2930 | ||
|
|
29eb21b286 | ||
|
|
b7439631d9 | ||
|
|
6b9d8f6ad9 | ||
|
|
c48fba9c85 | ||
|
|
7e3b57f4b6 | ||
|
|
889ba2fd6b | ||
|
|
8b5c954aa5 | ||
|
|
adc44d4466 | ||
|
|
969f380b08 | ||
|
|
10d7014c41 | ||
|
|
89e77a6671 | ||
|
|
c2ff656114 | ||
|
|
81e2957fa5 | ||
|
|
ba24a268ec | ||
|
|
70d262d947 | ||
|
|
6199350cca | ||
|
|
c5e2b39648 | ||
|
|
5db2b43d6a | ||
|
|
b9be9e5470 | ||
|
|
6700199a36 | ||
|
|
8f9821e9c9 | ||
|
|
83af20e04c | ||
|
|
f1dd3cbd3b | ||
|
|
d56251c0b9 | ||
|
|
667a600ec6 | ||
|
|
03a94ca6dd | ||
|
|
9da598e4d9 | ||
|
|
3a280696ca | ||
|
|
8825afdb46 |
@@ -5,19 +5,21 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- '*'
|
- '*'
|
||||||
- '!main'
|
- '!main'
|
||||||
|
paths-ignore:
|
||||||
|
- "README.md"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- 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
|
||||||
@@ -3,19 +3,21 @@ name: build_latest
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
paths-ignore:
|
||||||
|
- "README.md"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- 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
|
||||||
@@ -9,13 +9,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- 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
|
||||||
@@ -105,7 +105,6 @@ venv/
|
|||||||
ENV/
|
ENV/
|
||||||
env.bak/
|
env.bak/
|
||||||
venv.bak/
|
venv.bak/
|
||||||
poetry.lock
|
|
||||||
|
|
||||||
# Spyder project settings
|
# Spyder project settings
|
||||||
.spyderproject
|
.spyderproject
|
||||||
|
|||||||
Vendored
+4
-1
@@ -9,7 +9,10 @@
|
|||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"module": "dakiny_bot",
|
"module": "dakiny_bot",
|
||||||
"justMyCode": true
|
"justMyCode": true,
|
||||||
|
"env": {
|
||||||
|
"DEBUG": "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
@@ -3,6 +3,8 @@
|
|||||||
"aiofiles",
|
"aiofiles",
|
||||||
"autofilled",
|
"autofilled",
|
||||||
"blurple",
|
"blurple",
|
||||||
|
"CAKEDAY",
|
||||||
|
"cakedays",
|
||||||
"CLANLEADER",
|
"CLANLEADER",
|
||||||
"Dakiny",
|
"Dakiny",
|
||||||
"DISCORDMANAGER",
|
"DISCORDMANAGER",
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
FROM python:3.12.3-slim
|
FROM python:3.13.7-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
|
||||||
|
|
||||||
# install uv
|
# install uv
|
||||||
COPY --from=ghcr.io/astral-sh/uv:0.6.5 /uv /uvx /bin/
|
COPY --from=ghcr.io/astral-sh/uv:0.9.28 /uv /uvx /bin/
|
||||||
|
|
||||||
COPY . /home
|
COPY . /home
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class ChannelIds:
|
|||||||
event_post: int
|
event_post: int
|
||||||
general: int
|
general: int
|
||||||
voting: int
|
voting: int
|
||||||
|
ban: int
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
+2
-9
@@ -1,6 +1,5 @@
|
|||||||
"""Main file for bot."""
|
"""Main file for bot."""
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
@@ -16,12 +15,6 @@ from .DakinySettings import settings
|
|||||||
|
|
||||||
birthday_list: list[int] = []
|
birthday_list: list[int] = []
|
||||||
|
|
||||||
logger = logging.getLogger("nextcord")
|
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
handler = logging.FileHandler(filename="nextcord.log", encoding="utf-8", mode="w")
|
|
||||||
handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
|
|
||||||
logger.addHandler(handler)
|
|
||||||
|
|
||||||
|
|
||||||
def run() -> None:
|
def run() -> None:
|
||||||
"""Builds and runs bot."""
|
"""Builds and runs bot."""
|
||||||
@@ -38,8 +31,8 @@ def run() -> None:
|
|||||||
bot = commands.Bot(intents=intents)
|
bot = commands.Bot(intents=intents)
|
||||||
|
|
||||||
# Get the modules of all cogs whose directory structure is ./cogs/<module_name>
|
# Get the modules of all cogs whose directory structure is ./cogs/<module_name>
|
||||||
for folder in os.listdir("cogs"):
|
for folder in os.listdir("dakiny_bot/cogs"):
|
||||||
bot.load_extension(f"cogs.{folder}")
|
bot.load_extension(f"dakiny_bot.cogs.{folder}")
|
||||||
|
|
||||||
@bot.listen()
|
@bot.listen()
|
||||||
async def on_ready() -> None:
|
async def on_ready() -> None:
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ from datetime import UTC, datetime, timedelta
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from sqlalchemy import select, true, update
|
|
||||||
from sqlalchemy.orm import Session
|
|
||||||
|
|
||||||
from dakiny_bot.classes.nominate_highcouncil_views import NominateHighCouncilView
|
from dakiny_bot.classes.nominate_highcouncil_views import NominateHighCouncilView
|
||||||
from dakiny_bot.classes.nominate_views import NominateView
|
from dakiny_bot.classes.nominate_views import NominateView
|
||||||
from dakiny_bot.classes.voting_highcouncil_views import VoteHighcouncilView
|
from dakiny_bot.classes.voting_highcouncil_views import VoteHighcouncilView
|
||||||
@@ -19,6 +16,7 @@ from dakiny_bot.database.sql_data_classes import (
|
|||||||
Votes,
|
Votes,
|
||||||
engine,
|
engine,
|
||||||
)
|
)
|
||||||
|
from dakiny_bot.logger import dakiny_logger
|
||||||
from dakiny_bot.utils import (
|
from dakiny_bot.utils import (
|
||||||
TEMPLATES_DIR,
|
TEMPLATES_DIR,
|
||||||
VoteType,
|
VoteType,
|
||||||
@@ -28,6 +26,8 @@ from dakiny_bot.utils import (
|
|||||||
get_datetime,
|
get_datetime,
|
||||||
get_election_name,
|
get_election_name,
|
||||||
)
|
)
|
||||||
|
from sqlalchemy import select, true, update
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
REQUIRED_VOTES_TO_BE_ELECTED = 3
|
REQUIRED_VOTES_TO_BE_ELECTED = 3
|
||||||
|
|
||||||
@@ -144,20 +144,29 @@ class Election:
|
|||||||
async def check_date(self) -> None:
|
async def check_date(self) -> None:
|
||||||
"""Function checks current date to see if something needs to be run."""
|
"""Function checks current date to see if something needs to be run."""
|
||||||
today = datetime.now(tz=UTC)
|
today = datetime.now(tz=UTC)
|
||||||
|
dakiny_logger.debug("Checking date.")
|
||||||
|
|
||||||
# check all dates if action is needed
|
# check all dates if action is needed
|
||||||
if today.date() == self.election_start.date():
|
if today.date() == self.election_start.date():
|
||||||
|
dakiny_logger.debug("Election start.")
|
||||||
await self.election_start_action()
|
await self.election_start_action()
|
||||||
elif today.date() == self.voting_start.date():
|
elif today.date() == self.voting_start.date():
|
||||||
|
dakiny_logger.debug("Voting start.")
|
||||||
await self.voting_start_action()
|
await self.voting_start_action()
|
||||||
elif (self.voting_end - timedelta(3)).date() <= today.date() < self.voting_end.date():
|
elif (self.voting_end - timedelta(3)).date() <= today.date() < self.voting_end.date():
|
||||||
|
dakiny_logger.debug("Election reminder.")
|
||||||
await self.election_reminder()
|
await self.election_reminder()
|
||||||
elif today.date() == self.voting_end.date():
|
elif today.date() == self.voting_end.date():
|
||||||
|
dakiny_logger.debug("Voting end.")
|
||||||
await self.voting_end_action()
|
await self.voting_end_action()
|
||||||
elif today.date() == self.highcouncil_election_start.date():
|
elif today.date() == self.highcouncil_election_start.date():
|
||||||
|
dakiny_logger.debug("Highcouncil election start.")
|
||||||
await self.highcouncil_election_start_action()
|
await self.highcouncil_election_start_action()
|
||||||
elif today.date() == self.term_start.date():
|
elif today.date() == self.term_start.date():
|
||||||
|
dakiny_logger.debug("Term start")
|
||||||
await self.term_start_action()
|
await self.term_start_action()
|
||||||
|
else:
|
||||||
|
dakiny_logger.warning("Check date didn't do anything. This should never happen.")
|
||||||
|
|
||||||
async def election_start_action(self) -> None:
|
async def election_start_action(self) -> None:
|
||||||
"""Performs required actions for when the election cycle starts."""
|
"""Performs required actions for when the election cycle starts."""
|
||||||
@@ -201,7 +210,7 @@ class Election:
|
|||||||
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
|
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
|
||||||
await election_thread.send(message)
|
await election_thread.send(message)
|
||||||
vote_msg = await election_thread.send(
|
vote_msg = await election_thread.send(
|
||||||
build_votes_str(settings, self.guild),
|
build_votes_str(self.guild),
|
||||||
view=VoteView(self.guild),
|
view=VoteView(self.guild),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
# Extend the `pyproject.toml` file in the parent directory...
|
# Extend the `pyproject.toml` file in the parent directory...
|
||||||
extend = "../pyproject.toml"
|
extend = "../../pyproject.toml"
|
||||||
|
|
||||||
# Exclude a variety of commonly ignored directories.
|
# Exclude a variety of commonly ignored directories.
|
||||||
exclude = ["gitea_webhook.py"]
|
exclude = ["gitea_webhook.py"]
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
|||||||
session.execute(stmt)
|
session.execute(stmt)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
vote_message_str = build_votes_str(settings, interaction.guild)
|
vote_message_str = build_votes_str(interaction.guild)
|
||||||
vote_msg: nextcord.Message = await interaction.channel.fetch_message(vote_msg_id)
|
vote_msg: nextcord.Message = await interaction.channel.fetch_message(vote_msg_id)
|
||||||
await vote_msg.edit(content=vote_message_str)
|
await vote_msg.edit(content=vote_message_str)
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ from typing import TYPE_CHECKING
|
|||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from git import Repo
|
from git import Repo
|
||||||
|
from git.exc import GitCommandError
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from dakiny_bot.classes.gitea_webhook import GiteaWebhook
|
from dakiny_bot.classes.gitea_webhook import GiteaWebhook
|
||||||
from dakiny_bot.DakinySettings import settings
|
from dakiny_bot.DakinySettings import settings
|
||||||
|
from dakiny_bot.logger import dakiny_logger
|
||||||
from dakiny_bot.utils import REPO_DIR, edit_clan_council_info, update_clan_messages
|
from dakiny_bot.utils import REPO_DIR, edit_clan_council_info, update_clan_messages
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@@ -55,7 +57,12 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
|
|||||||
template_updates = {file.split("/")[1] for file in modified_files if "message_templates" in file}
|
template_updates = {file.split("/")[1] for file in modified_files if "message_templates" in file}
|
||||||
channel_updates = {file.split("/")[1] for file in modified_files if file.split("/")[1] not in template_updates}
|
channel_updates = {file.split("/")[1] for file in modified_files if file.split("/")[1] not in template_updates}
|
||||||
|
|
||||||
self.origin.pull()
|
try:
|
||||||
|
self.origin.pull()
|
||||||
|
except GitCommandError:
|
||||||
|
# I think the git connection timed out. Get a new one.
|
||||||
|
dakiny_logger.info("Refreshing git connection.")
|
||||||
|
self.repo_setup()
|
||||||
guild: nextcord.Guild = self.bot.get_guild(settings.params.guild_id)
|
guild: nextcord.Guild = self.bot.get_guild(settings.params.guild_id)
|
||||||
|
|
||||||
await update_clan_messages(guild, channel_updates)
|
await update_clan_messages(guild, channel_updates)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import nextcord
|
|||||||
from nextcord.ext import application_checks, commands
|
from nextcord.ext import application_checks, commands
|
||||||
|
|
||||||
from dakiny_bot.classes.election import Election
|
from dakiny_bot.classes.election import Election
|
||||||
|
from dakiny_bot.cogs.loops import daily_loop
|
||||||
from dakiny_bot.DakinySettings import settings
|
from dakiny_bot.DakinySettings import settings
|
||||||
from dakiny_bot.utils import GUILDS, get_active_election_cycle, get_quarter_name
|
from dakiny_bot.utils import GUILDS, get_active_election_cycle, get_quarter_name
|
||||||
|
|
||||||
@@ -119,11 +120,8 @@ class TestCog(commands.Cog, name="Test commands."):
|
|||||||
Args:
|
Args:
|
||||||
interaction (nextcord.Interaction): Interaction with the message.
|
interaction (nextcord.Interaction): Interaction with the message.
|
||||||
"""
|
"""
|
||||||
cycle = Election(
|
dl = daily_loop.DailyLoop(self.bot)
|
||||||
get_active_election_cycle(),
|
await dl.daily_loop()
|
||||||
self.bot.get_guild(settings.params.guild_id),
|
|
||||||
)
|
|
||||||
await cycle.check_date()
|
|
||||||
await interaction.send("Test command sent.", ephemeral=True)
|
await interaction.send("Test command sent.", ephemeral=True)
|
||||||
|
|
||||||
@test.subcommand()
|
@test.subcommand()
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from dakiny_bot.app import birthday_list
|
|||||||
from dakiny_bot.classes.election import Election
|
from dakiny_bot.classes.election import Election
|
||||||
from dakiny_bot.DakinySettings import settings
|
from dakiny_bot.DakinySettings import settings
|
||||||
from dakiny_bot.database.sql_data_classes import UserBirthday, engine
|
from dakiny_bot.database.sql_data_classes import UserBirthday, engine
|
||||||
|
from dakiny_bot.logger import dakiny_logger
|
||||||
from dakiny_bot.utils import get_active_election_cycle
|
from dakiny_bot.utils import get_active_election_cycle
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@@ -20,6 +21,8 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
KANDY = 239547993106284544
|
KANDY = 239547993106284544
|
||||||
|
|
||||||
|
IGNORE_CAKEDAY = [266378407682506754]
|
||||||
|
|
||||||
|
|
||||||
class DailyLoop(commands.Cog, name="Daily Loop"):
|
class DailyLoop(commands.Cog, name="Daily Loop"):
|
||||||
"""Class for performing daily functions."""
|
"""Class for performing daily functions."""
|
||||||
@@ -41,8 +44,10 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
|||||||
an active election, runs the check_date() function for the election to perform actions. Finally checks if the
|
an active election, runs the check_date() function for the election to perform actions. Finally checks if the
|
||||||
election is over to delete the current election object.
|
election is over to delete the current election object.
|
||||||
"""
|
"""
|
||||||
|
dakiny_logger.debug("Daily loop. Current election: %s.", self.current_election)
|
||||||
if self.current_election is None:
|
if self.current_election is None:
|
||||||
self.current_election = self.get_election()
|
self.current_election = self.get_election()
|
||||||
|
dakiny_logger.debug("Current election: %s.", self.current_election)
|
||||||
|
|
||||||
if self.current_election is not None:
|
if self.current_election is not None:
|
||||||
await self.current_election.check_date()
|
await self.current_election.check_date()
|
||||||
@@ -76,13 +81,17 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
|||||||
Election: Current election cycle, None if there is no election happening.
|
Election: Current election cycle, None if there is no election happening.
|
||||||
"""
|
"""
|
||||||
cycle = get_active_election_cycle()
|
cycle = get_active_election_cycle()
|
||||||
|
dakiny_logger.debug("Current cycle: %s.", cycle)
|
||||||
|
|
||||||
# prevent exception from using cycle as an Int in an array
|
# prevent exception from using cycle as an Int in an array
|
||||||
if cycle is None:
|
if cycle is None:
|
||||||
|
dakiny_logger.info("Cycle was None. Returning without an election.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
election = Election(cycle, self.bot.get_guild(settings.params.guild_id))
|
election = Election(cycle, self.bot.get_guild(settings.params.guild_id))
|
||||||
|
|
||||||
|
dakiny_logger.debug("Election active: %s", election.active)
|
||||||
|
|
||||||
return election if election.active else None
|
return election if election.active else None
|
||||||
|
|
||||||
def update_birthdays(self) -> None:
|
def update_birthdays(self) -> None:
|
||||||
@@ -112,7 +121,11 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
|||||||
announce_channel: nextcord.TextChannel = guild.get_channel(settings.channel_ids.general)
|
announce_channel: nextcord.TextChannel = guild.get_channel(settings.channel_ids.general)
|
||||||
|
|
||||||
cakedays: list[nextcord.Member] = [
|
cakedays: list[nextcord.Member] = [
|
||||||
human for human in guild.humans if human.joined_at.month == today.month and human.joined_at.day == today.day
|
human
|
||||||
|
for human in guild.humans
|
||||||
|
if human.joined_at.month == today.month
|
||||||
|
and human.joined_at.day == today.day
|
||||||
|
and human.id not in IGNORE_CAKEDAY
|
||||||
]
|
]
|
||||||
|
|
||||||
for member in cakedays:
|
for member in cakedays:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import nextcord
|
|||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
from dakiny_bot.app import birthday_list
|
from dakiny_bot.app import birthday_list
|
||||||
|
from dakiny_bot.DakinySettings import settings
|
||||||
|
|
||||||
|
|
||||||
class SubmissionListener(commands.Cog, name="Message Listener"):
|
class SubmissionListener(commands.Cog, name="Message Listener"):
|
||||||
@@ -16,7 +17,15 @@ class SubmissionListener(commands.Cog, name="Message Listener"):
|
|||||||
async def on_message(self, message: nextcord.Message) -> None:
|
async def on_message(self, message: nextcord.Message) -> None:
|
||||||
"""Listener for message creation. Adds score and attachments to submission."""
|
"""Listener for message creation. Adds score and attachments to submission."""
|
||||||
# don't want to process any messages from bot.
|
# don't want to process any messages from bot.
|
||||||
if message.author.id == self.bot.user.id:
|
if message.author.id == self.bot.user.id: # pyright: ignore[reportOptionalMemberAccess]
|
||||||
|
return
|
||||||
|
|
||||||
|
# Ban all members who message in this channel. Everyone in guild is a member, so shouldn't miss a ban
|
||||||
|
# due to message.author not being a nextcord.Member object.
|
||||||
|
if message.channel.id == settings.channel_ids.ban and isinstance(message.author, nextcord.Member):
|
||||||
|
await message.author.ban(
|
||||||
|
delete_message_seconds=30 * 60, reason="Probable spam. The ban channel was messaged."
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
await birthday_action(message)
|
await birthday_action(message)
|
||||||
@@ -31,7 +40,7 @@ def setup(bot: commands.Bot) -> None:
|
|||||||
|
|
||||||
async def birthday_action(message: nextcord.Message) -> None:
|
async def birthday_action(message: nextcord.Message) -> None:
|
||||||
"""
|
"""
|
||||||
Checks a message's auther and mentions to see if they are in the birthday list.
|
Checks a message's author and mentions to see if they are in the birthday list.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
message (nextcord.Message): The message to check for a birthday person.
|
message (nextcord.Message): The message to check for a birthday person.
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
"""Module controls connection to Dakiny bot database."""
|
||||||
@@ -7,7 +7,7 @@ if not Path("database/dakiny.db").exists():
|
|||||||
with sqlite3.connect("database/dakiny.db") as con:
|
with sqlite3.connect("database/dakiny.db") as con:
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
|
|
||||||
with Path("database_setup/database.sql", encoding="utf-8").open() as file:
|
with Path("dakiny_bot/database/database.sql").open() as file:
|
||||||
database_script = file.read()
|
database_script = file.read()
|
||||||
cur.executescript(database_script)
|
cur.executescript(database_script)
|
||||||
con.commit()
|
con.commit()
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
[tool.ruff]
|
|
||||||
# Extend the `pyproject.toml` file in the parent directory...
|
|
||||||
extend = "../pyproject.toml"
|
|
||||||
|
|
||||||
[tool.ruff.lint]
|
|
||||||
# ignore implicit-namespace-package in this directory.
|
|
||||||
ignore = ["INP001"]
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
"""Creates logger for Dakiny bot."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
dakiny_logger = logging.getLogger("default")
|
||||||
|
dakiny_logger.setLevel(logging.DEBUG if os.getenv("DEBUG") == "true" else logging.INFO)
|
||||||
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
|
handler.setFormatter(
|
||||||
|
logging.Formatter("%(asctime)s:%(levelname)s [%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s")
|
||||||
|
)
|
||||||
|
dakiny_logger.addHandler(handler)
|
||||||
+14
-6
@@ -20,6 +20,7 @@ from dakiny_bot.database.sql_data_classes import (
|
|||||||
Votes,
|
Votes,
|
||||||
engine,
|
engine,
|
||||||
)
|
)
|
||||||
|
from dakiny_bot.logger import dakiny_logger
|
||||||
|
|
||||||
from .DakinySettings import settings
|
from .DakinySettings import settings
|
||||||
|
|
||||||
@@ -34,20 +35,20 @@ VoteType = StrEnum("VoteType", ["COUNCIL", "DISCORDMANAGER", "CLANLEADER"])
|
|||||||
PointType = StrEnum("PointType", ["CLAN", "EVENT"])
|
PointType = StrEnum("PointType", ["CLAN", "EVENT"])
|
||||||
|
|
||||||
|
|
||||||
def get_datetime(day: str) -> datetime:
|
def get_datetime(month_day: str) -> datetime:
|
||||||
"""
|
"""
|
||||||
Takes in a string month and day and returns a datetime object of that Month/Day this year.
|
Takes in a string month and day and returns a datetime object of that Month/Day this year.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
day (str): Month/Day in that format.
|
month_day (str): Month/Day in that format.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
datetime: Datetime representation of Month/Day.
|
datetime: Datetime representation of Month/Day.
|
||||||
"""
|
"""
|
||||||
today = datetime.now(tz=UTC).date()
|
today = datetime.now(tz=UTC).date()
|
||||||
year = today.year
|
year = today.year
|
||||||
month = int(day.split("/")[0])
|
month = int(month_day.split("/")[0])
|
||||||
day = int(day.split("/")[1])
|
day = int(month_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.
|
||||||
if today.month == calendar.DECEMBER and month < calendar.OCTOBER:
|
if today.month == calendar.DECEMBER and month < calendar.OCTOBER:
|
||||||
@@ -55,8 +56,10 @@ def get_datetime(day: str) -> datetime:
|
|||||||
|
|
||||||
if today.month == calendar.JANUARY and month > calendar.MARCH:
|
if today.month == calendar.JANUARY and month > calendar.MARCH:
|
||||||
year -= 1
|
year -= 1
|
||||||
|
try:
|
||||||
return datetime(year, month, day, tzinfo=UTC)
|
return datetime(year, month, day, tzinfo=UTC)
|
||||||
|
except ValueError:
|
||||||
|
dakiny_logger.warning("Invalid month day: %s.", month_day)
|
||||||
|
|
||||||
|
|
||||||
def get_election_name() -> str:
|
def get_election_name() -> str:
|
||||||
@@ -92,12 +95,14 @@ def get_active_election_cycle() -> int:
|
|||||||
int: cycle index for active election. None for no active cycle
|
int: cycle index for active election. None for no active cycle
|
||||||
"""
|
"""
|
||||||
today = datetime.now(tz=UTC)
|
today = datetime.now(tz=UTC)
|
||||||
|
dakiny_logger.debug("Today is %s", today)
|
||||||
|
|
||||||
for cycle, election in enumerate(settings.election_cycles):
|
for cycle, election in enumerate(settings.election_cycles):
|
||||||
if (
|
if (
|
||||||
today.date() >= get_datetime(election.election_start).date()
|
today.date() >= get_datetime(election.election_start).date()
|
||||||
and today.date() <= get_datetime(election.term_start).date()
|
and today.date() <= get_datetime(election.term_start).date()
|
||||||
):
|
):
|
||||||
|
dakiny_logger.debug("Cycle is %d", cycle)
|
||||||
return cycle
|
return cycle
|
||||||
|
|
||||||
# It isn't a current election, get the quarter
|
# It isn't a current election, get the quarter
|
||||||
@@ -114,13 +119,16 @@ def get_quarter_cycle() -> int:
|
|||||||
int: cycle index for current cycle.
|
int: cycle index for current cycle.
|
||||||
"""
|
"""
|
||||||
today = datetime.now(tz=UTC)
|
today = datetime.now(tz=UTC)
|
||||||
|
dakiny_logger.debug("Today is %s", today)
|
||||||
for cycle, election in enumerate(settings.election_cycles):
|
for cycle, election in enumerate(settings.election_cycles):
|
||||||
if (
|
if (
|
||||||
today.date() >= get_datetime(election.term_start).date()
|
today.date() >= get_datetime(election.term_start).date()
|
||||||
and today.date() <= get_datetime(election.term_end).date()
|
and today.date() <= get_datetime(election.term_end).date()
|
||||||
):
|
):
|
||||||
|
dakiny_logger.debug("Cycle is %d", cycle)
|
||||||
return cycle
|
return cycle
|
||||||
|
|
||||||
|
dakiny_logger.debug("Quarter cycle is None.")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -1,17 +1,18 @@
|
|||||||
[project]
|
[project]
|
||||||
authors = [{ name = "imcompiling", email = "[email protected]" }]
|
authors = [{ name = "imcompiling", email = "[email protected]" }]
|
||||||
requires-python = "<4.0,>=3.12"
|
requires-python = "<4.0,>=3.13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gitpython<4.0.0,>=3.1.43",
|
"gitpython<4.0.0,>=3.1.43",
|
||||||
"fastapi<1.0.0,>=0.111.0",
|
"fastapi<1.0.0,>=0.111.0",
|
||||||
"nextcord<3.0.0,>=2.6.0",
|
"nextcord<3.0.0,>=2.6.0",
|
||||||
"pandas<3.0.0,>=2.2.2",
|
"pandas<3.1.0,>=3.0.6",
|
||||||
"pytz<2025.0,>=2024.1",
|
"pytz<2025.3,>=2025.2",
|
||||||
"sqlalchemy<3.0.0,>=2.0.30",
|
"sqlalchemy<3.0.0,>=2.0.30",
|
||||||
"aiofiles<24.0.0,>=23.2.1",
|
"aiofiles<24.0.0,>=23.2.1",
|
||||||
"setuptools<71.0.0,>=70.0.0",
|
"setuptools<80.10.3,>=80.10.2",
|
||||||
"dataclass-wizard[yaml]>=0.22.3,<1.0.0",
|
"dataclass-wizard[yaml]>=0.22.3,<1.0.0",
|
||||||
"uvicorn>=0.34.0",
|
"uvicorn>=0.34.0",
|
||||||
|
"audioop-lts>=0.2.1",
|
||||||
]
|
]
|
||||||
name = "dakiny-bot"
|
name = "dakiny-bot"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"lockFileMaintenance": {
|
||||||
|
"automerge": true
|
||||||
|
},
|
||||||
|
"major": {
|
||||||
|
"automerge": false,
|
||||||
|
"automergeType": "pr"
|
||||||
|
},
|
||||||
|
"minor": {
|
||||||
|
"automerge": true,
|
||||||
|
"automergeType": "branch"
|
||||||
|
},
|
||||||
|
"patch": {
|
||||||
|
"automerge": true,
|
||||||
|
"automergeType": "branch"
|
||||||
|
},
|
||||||
|
"pin": {
|
||||||
|
"automerge": true,
|
||||||
|
"automergeType": "branch"
|
||||||
|
},
|
||||||
|
"ignoreTests": true,
|
||||||
|
"dockerfile": {
|
||||||
|
"minor": {
|
||||||
|
"automerge": false,
|
||||||
|
"automergeType": "pr"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user