Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to python 3.12 #604

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: ./script/bootstrap
- name: Run migrations
run: PYTHONPATH=. alembic upgrade head
- name: Run tests
run: ./script/test
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: ./script/bootstrap
- name: Run migrations
run: PYTHONPATH=. alembic upgrade head
- name: Run tests
run: ./script/test
147 changes: 0 additions & 147 deletions bot/exts/practices/_practice_sessions.py

This file was deleted.

36 changes: 15 additions & 21 deletions bot/exts/practices/daily_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,26 @@
from bot.utils.discord import THEME_COLOR, get_event_url
from bot.utils.tasks import daily_task

from ._practice_sessions import (
get_practice_sessions,
make_base_embed,
make_practice_session_embed,
)

logger = logging.getLogger(__name__)

COMMAND_PREFIX = settings.COMMAND_PREFIX
HERE = Path(__file__).parent


def make_base_embed(dtime: dt.datetime) -> disnake.Embed:
now_pacific = utcnow().astimezone(PACIFIC)
dtime_pacific = dtime.astimezone(PACIFIC)
description = dtime_pacific.strftime("%A, %B %-d")
if dtime_pacific.date() == now_pacific.date():
description = f"Today - {description}"
elif (dtime_pacific.date() - now_pacific.date()).days == 1:
description = f"Tomorrow - {description}"
holiday = holiday_emojis.get(dtime_pacific.date())
if holiday and holiday.emoji:
description += f" {holiday.emoji}"
return disnake.Embed(description=description, color=THEME_COLOR)


def get_today_random(dtime: Optional[dt.datetime] = None) -> random.Random:
dtime = dtime or utcnow()
seed = settings.DAILY_MESSAGE_RANDOM_SEED or dtime.date().toordinal()
Expand Down Expand Up @@ -120,25 +128,11 @@ async def send_daily_message(
channel = cast(disnake.TextChannel, self.bot.get_channel(channel_id))
guild = channel.guild
logger.info(f'sending daily message for guild: "{guild.name}" in #{channel.name}')
guild_id = guild.id
dtime = dtime or utcnow()
prefer_dates_from = (
"current_period" if dtime.date() <= dt.date.today() else "future"
)
parse_settings = {"PREFER_DATES_FROM": prefer_dates_from}
settings = await store.get_guild_settings(guild.id)
if not settings:
return
embed: disnake.Embed
if settings["include_practice_schedule"]:
sessions = await get_practice_sessions(
guild_id,
dtime=dtime,
parse_settings=parse_settings,
)
embed = await make_practice_session_embed(guild_id, sessions, dtime=dtime)
else:
embed = make_base_embed(dtime=dtime)
embed = make_base_embed(dtime=dtime)

if settings["include_scheduled_events"]:
# Display scheduled events for today
Expand Down
Loading
Loading