Compare commits
4
Commits
abb50d71b4
...
v2.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb6a8c7479 | ||
|
|
58b230afe6 | ||
|
|
fb8dfef55e | ||
|
|
487d174b6d |
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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
+8
-6
@@ -35,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:
|
||||||
@@ -56,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:
|
||||||
|
|||||||
Reference in New Issue
Block a user