From 97141be93e5ce049744de7436b416592d8f5a619 Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 30 May 2024 23:17:58 +0200 Subject: [PATCH] Removed unnecessary checks --- modules/reminder.py | 13 ++++--------- plugins/commands/setup.py | 9 +++------ plugins/commands/start.py | 9 +++------ 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/modules/reminder.py b/modules/reminder.py index bd6b9aa..aca992d 100644 --- a/modules/reminder.py +++ b/modules/reminder.py @@ -1,6 +1,7 @@ import logging -from datetime import datetime, timezone +from datetime import datetime +import pytz from bson import json_util from libbot.pyrogram.classes import PyroClient @@ -14,7 +15,7 @@ logger = logging.getLogger(__name__) async def remind(app: PyroClient) -> None: - utcnow = datetime.now(timezone.utc) + utcnow = datetime.now(pytz.utc) logger.debug("Performing reminder lookup for %s (UTCNOW)", utcnow) @@ -42,13 +43,7 @@ async def remind(app: PyroClient) -> None: logger.warning("Skipping reminder for %s due to invalid location", user.id) continue - try: - user_date = user.get_reminder_date() - except AttributeError: - logger.warning( - "Skipping reminder for %s due to missing attributes", user.id - ) - continue + user_date = user.get_reminder_date().replace(tzinfo=None) entries = await col_entries.find( { diff --git a/plugins/commands/setup.py b/plugins/commands/setup.py index 174ec52..3f60ef9 100644 --- a/plugins/commands/setup.py +++ b/plugins/commands/setup.py @@ -72,12 +72,9 @@ async def command_setup(app: PyroClient, message: Message): await user.update_location(location.id) - try: - user_time = user.get_reminder_time().strftime( - app._("time", "formats", locale=user.locale) - ) - except AttributeError: - user_time = "N/A" + user_time = user.get_reminder_time().strftime( + app._("time", "formats", locale=user.locale) + ) await message.reply_text( app._("setup_finished", "messages", locale=user.locale).format( diff --git a/plugins/commands/start.py b/plugins/commands/start.py index d77325d..af11347 100644 --- a/plugins/commands/start.py +++ b/plugins/commands/start.py @@ -88,12 +88,9 @@ async def command_start(app: PyroClient, message: Message): await user.update_location(location.id) - try: - user_time = user.get_reminder_time().strftime( - app._("time", "formats", locale=user.locale) - ) - except AttributeError: - user_time = "N/A" + user_time = user.get_reminder_time().strftime( + app._("time", "formats", locale=user.locale) + ) await answer.reply_text( app._("start_selection_yes", "messages", locale=user.locale).format(