Skip to content

Commit

Permalink
Update timekiller.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Nurdok authored Dec 7, 2024
1 parent c910203 commit 48cb381
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/spanreed/plugins/timekiller.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def run_for_user(self, user: User) -> None:
)

async def get_available_time_killers(
self, user: User, obsidian: ObsidianApi
self, user: User, obsidian: ObsidianApi, push: boolean,
) -> dict:
timekillers: dict = {
"Journaling Prompt": self._journal_prompt,
Expand All @@ -73,7 +73,7 @@ async def get_available_time_killers(
)
except TypeError:
raise ValueError(f"{last_asked_str}, {type(last_asked_str)}")
if datetime.datetime.now() - last_asked > datetime.timedelta(days=3):
if not push or datetime.datetime.now() - last_asked > datetime.timedelta(days=3):
timekillers["Books"] = self.prompt_for_currently_reading_books

await obsidian.safe_generate_today_note()
Expand All @@ -91,7 +91,7 @@ async def _kill_time_push(self, user: User) -> None:
obsidian: ObsidianApi = await ObsidianApi.for_user(user)
bot: TelegramBotApi = await TelegramBotApi.for_user(user)
timekillers: dict = await self.get_available_time_killers(
user, obsidian
user, obsidian, True,
)
choice: str = random.choice(list(timekillers.keys()))
await timekillers[choice](user, bot, obsidian)
Expand All @@ -100,7 +100,7 @@ async def _kill_time(self, user: User) -> None:
obsidian: ObsidianApi = await ObsidianApi.for_user(user)
bot: TelegramBotApi = await TelegramBotApi.for_user(user)
timekillers: dict = await self.get_available_time_killers(
user, obsidian
user, obsidian, False,
)
choices: list[str] = [name for name in timekillers.keys()]
choice: int = await bot.request_user_choice(
Expand Down

0 comments on commit 48cb381

Please sign in to comment.