Skip to content

Commit

Permalink
Fix book timekilling feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Nurdok committed Sep 28, 2024
1 parent 115c406 commit 78428e8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/spanreed/plugins/timekiller.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@


class TimekillerPlugin(Plugin):
LAST_ASKED_BOOKS_KEY = "currently-reading-books-last-asked"

@classmethod
def name(cls) -> str:
return "Timekiller"
Expand Down Expand Up @@ -58,10 +60,12 @@ async def get_available_time_killers(
"Scan Processing": self.prompt_for_scan_processing,
}

last_asked: datetime.datetime = datetime.datetime.now() - datetime.timedelta(
days=4
)
last_asked_str: str | None = await self.get_user_data(
user, "currently-reading-books-last-asked"
user, self.LAST_ASKED_BOOKS_KEY
)
last_asked: datetime.datetime = datetime.datetime.now()
if last_asked_str is not None:
last_asked = datetime.datetime.fromisoformat(
last_asked_str
Expand Down Expand Up @@ -324,6 +328,7 @@ async def prompt_for_currently_reading_books(
"\n\n### Thoughts\n"
+ await bot.request_user_input("Go ahead then:"),
)
await self.set_user_data(user, self.LAST_ASKED_BOOKS_KEY, str(datetime.datetime.now()))

async def prompt_for_scan_processing(
self, _user: User, bot: TelegramBotApi, obsidian: ObsidianApi
Expand Down

0 comments on commit 78428e8

Please sign in to comment.