From e9ad038876bf82db6759d315215095fc65b0cd89 Mon Sep 17 00:00:00 2001 From: Lou-M <73669620+Lou-M@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:49:46 +0200 Subject: [PATCH 1/2] Umformulierung Erinnerung appointments.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Klarheit und Emotes ✨ Sollte identisch sein zu: https://github.com/FU-Hagen-Discord/fernuni-bot/pull/228/commits/027e0c1175b1725c681bba561bd7beeb7f4fcc69 --- extensions/appointments.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/appointments.py b/extensions/appointments.py index 5c43301..34ef356 100644 --- a/extensions/appointments.py +++ b/extensions/appointments.py @@ -12,9 +12,9 @@ async def send_notification(appointment, channel): message = f"Benachrichtigung!\nDer Termin \"{appointment.title}\" startet " if appointment.reminder_sent: - message += f"jetzt! :loudspeaker: " + message += f"**jetzt**! :alarm_clock: " else: - message += f"<t:{int(appointment.date_time.timestamp())}:R>." + message += f"um <t:{int(appointment.date_time.timestamp())}:t> (<t:{int(appointment.date_time.timestamp())}:R>) :person_running: " message += f"\n" message += " ".join([f"<@!{str(attendee.member_id)}>" for attendee in appointment.attendees]) -- GitLab From abcdbcd81e1a94a2b2533ed9c939847f54f7b694 Mon Sep 17 00:00:00 2001 From: Lou-M <73669620+Lou-M@users.noreply.github.com> Date: Sun, 21 Jul 2024 22:24:05 +0200 Subject: [PATCH 2/2] Update appointments.py Neuste Version ~~von Boty~~ vom [fernuni-bot](https://github.com/FU-Hagen-Discord/fernuni-bot/blob/develop/extensions/appointments.py) importiert. Mit drei verschiedenen Embeds! Und schlauen Zeitangaben! --- extensions/appointments.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/extensions/appointments.py b/extensions/appointments.py index 34ef356..96b5643 100644 --- a/extensions/appointments.py +++ b/extensions/appointments.py @@ -1,4 +1,5 @@ import asyncio +import uuid from datetime import datetime, timedelta from discord import app_commands, errors, Interaction @@ -9,17 +10,15 @@ from views.appointment_view import AppointmentView async def send_notification(appointment, channel): - message = f"Benachrichtigung!\nDer Termin \"{appointment.title}\" startet " - - if appointment.reminder_sent: - message += f"**jetzt**! :alarm_clock: " - else: - message += f"um <t:{int(appointment.date_time.timestamp())}:t> (<t:{int(appointment.date_time.timestamp())}:R>) :person_running: " + message = f"Erinnerung!" message += f"\n" message += " ".join([f"<@!{str(attendee.member_id)}>" for attendee in appointment.attendees]) - await channel.send(message) + if appointment.reminder_sent: + return await channel.send(message, embed=appointment.get_embed(2)) + + return await channel.send(message, embed=appointment.get_embed(1), view=AppointmentView()) @app_commands.guild_only() @@ -40,11 +39,11 @@ class Appointments(commands.GroupCog, name="appointments", description="Handle A try: channel = await self.bot.fetch_channel(appointment.channel) message = await channel.fetch_message(appointment.message) - await send_notification(appointment, channel) + new_message = await send_notification(appointment, channel) + Appointment.update(message=new_message.id).where(Appointment.id == appointment.id).execute() + await message.delete() if appointment.reminder_sent: - await message.delete() - if appointment.recurring == 0: appointment.delete_instance(recursive=True) else: @@ -53,7 +52,7 @@ class Appointments(commands.GroupCog, name="appointments", description="Handle A Appointment.update(reminder_sent=reminder_sent, date_time=new_date_time).where( Appointment.id == appointment.id).execute() updated_appointment = Appointment.get(Appointment.id == appointment.id) - new_message = await channel.send(embed=updated_appointment.get_embed(), + new_message = await channel.send(embed=updated_appointment.get_embed(0), view=AppointmentView()) Appointment.update(message=new_message.id).where(Appointment.id == appointment.id).execute() else: @@ -77,16 +76,16 @@ class Appointments(commands.GroupCog, name="appointments", description="Handle A channel = interaction.channel author_id = interaction.user.id try: - date_time = datetime.strptime(f"{date} {time}", "%d.%m.%Y %H:%M") + date_time = datetime.strptime(f"{date} {time}", self.bot.dt_format()) except ValueError: await channel.send("Fehler! Ungültiges Datums und/oder Zeit Format!") return appointment = Appointment.create(channel=channel.id, message=0, date_time=date_time, reminder=reminder, title=title, description=description, author=author_id, recurring=recurring, - reminder_sent=reminder == 0) + reminder_sent=reminder == 0, uuid=uuid.uuid4()) - await interaction.response.send_message(embed=appointment.get_embed(), view=AppointmentView()) + await interaction.response.send_message(embed=appointment.get_embed(0), view=AppointmentView()) message = await interaction.original_response() Appointment.update(message=message.id).where(Appointment.id == appointment.id).execute() -- GitLab