Skip to content

Commit

Permalink
Fix loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nurdok committed Jun 25, 2024
1 parent 6b64e3d commit fd6f6a5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/spanreed/plugins/timekiller.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ async def run_for_user(self, user: User) -> None:
while True:
await asyncio.sleep(
datetime.timedelta(
hours=random.randrange(3, 7)
hours=random.randrange(1, 3)
).total_seconds()
)
now: datetime.datetime = datetime.datetime.now()
if now.hour < 9 or now.hour > 22:
if now.hour < 7 or now.hour > 22:
continue

async with suppress_and_log_exception(
Expand Down Expand Up @@ -74,14 +74,14 @@ async def _kill_time_push(self, user: User) -> None:
timekillers: dict = await self.get_available_time_killers(
user, obsidian
)
choice: str = random.choice(list(timekillers.keys()))
await timekillers[choice](user, bot, obsidian)
if (
await bot.request_user_choice(
"Another?", ["Yes", "No"], columns=2
)
await bot.request_user_choice(
"Another?", ["Yes", "No"], columns=2
)
) == 1:
break
choice: str = random.choice(list(timekillers.keys()))
await timekillers[choice](user, bot, obsidian)

async def _kill_time(self, user: User) -> None:
obsidian: ObsidianApi = await ObsidianApi.for_user(user)
Expand Down

0 comments on commit fd6f6a5

Please sign in to comment.