Skip to content

Commit

Permalink
Don't allow mood tracking if it was already done today.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nurdok committed Apr 9, 2024
1 parent adeafd7 commit 9662207
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/spanreed/plugins/timekiller.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ async def _journal_prompt(self, user: User, bot: TelegramBotApi) -> None:
async def _poll_for_metrics(
self, user: User, bot: TelegramBotApi, obsidian: ObsidianApi
) -> None:
# TODO: Use ObsidianApi to check if we've already done this today.
daily_note: str = await obsidian.get_daily_note("Daily")
if await obsidian.get_property(daily_note, "mood") is not None:
await bot.send_message("You've already recorded your mood today.")
return

mood: int = (
await bot.request_user_choice(
"How would you rate your mood right now?\n"
Expand Down Expand Up @@ -192,7 +196,6 @@ async def _poll_for_metrics(

await obsidian.safe_generate_today_note()
# TODO: Use ObsidianApi to get the daily note path.
daily_note: str = await obsidian.get_daily_note("Daily")
await obsidian.set_value_of_property(daily_note, "mood", str(mood))
await obsidian.set_value_of_property(daily_note, "feelings", feelings)
await bot.send_message("Noted!")
Expand Down

0 comments on commit 9662207

Please sign in to comment.