Removed unnecessary checks

This commit is contained in:
Profitroll 2024-05-30 23:17:58 +02:00 committed by Profitroll
parent b5bfbcd375
commit 7293cafd2e
3 changed files with 10 additions and 21 deletions

View File

@ -1,6 +1,7 @@
import logging import logging
from datetime import datetime, timezone from datetime import datetime
import pytz
from bson import json_util from bson import json_util
from libbot.pyrogram.classes import PyroClient from libbot.pyrogram.classes import PyroClient
@ -14,7 +15,7 @@ logger = logging.getLogger(__name__)
async def remind(app: PyroClient) -> None: 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) 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) logger.warning("Skipping reminder for %s due to invalid location", user.id)
continue continue
try: user_date = user.get_reminder_date().replace(tzinfo=None)
user_date = user.get_reminder_date()
except AttributeError:
logger.warning(
"Skipping reminder for %s due to missing attributes", user.id
)
continue
entries = await col_entries.find( entries = await col_entries.find(
{ {

View File

@ -72,12 +72,9 @@ async def command_setup(app: PyroClient, message: Message):
await user.update_location(location.id) await user.update_location(location.id)
try: user_time = user.get_reminder_time().strftime(
user_time = user.get_reminder_time().strftime( app._("time", "formats", locale=user.locale)
app._("time", "formats", locale=user.locale) )
)
except AttributeError:
user_time = "N/A"
await message.reply_text( await message.reply_text(
app._("setup_finished", "messages", locale=user.locale).format( app._("setup_finished", "messages", locale=user.locale).format(

View File

@ -88,12 +88,9 @@ async def command_start(app: PyroClient, message: Message):
await user.update_location(location.id) await user.update_location(location.id)
try: user_time = user.get_reminder_time().strftime(
user_time = user.get_reminder_time().strftime( app._("time", "formats", locale=user.locale)
app._("time", "formats", locale=user.locale) )
)
except AttributeError:
user_time = "N/A"
await answer.reply_text( await answer.reply_text(
app._("start_selection_yes", "messages", locale=user.locale).format( app._("start_selection_yes", "messages", locale=user.locale).format(