Files
memoir_bot/modules/reminders.py
T
Dmitry 793716f699 init
2026-07-04 10:29:16 +03:00

33 lines
782 B
Python

import asyncio
import logging
import random
from aiogram import Bot
QUESTIONS = (
"Как дела?",
"Что нового?",
"Что сейчас происходит?",
"Чем занимаешься?",
"Есть что записать?",
"Как проходит день?",
)
async def send_reminders(
bot: Bot,
user_ids: set[int],
min_seconds: int,
max_seconds: int,
) -> None:
while True:
await asyncio.sleep(random.randint(min_seconds, max_seconds))
question = random.choice(QUESTIONS)
for user_id in user_ids:
try:
await bot.send_message(user_id, question)
except Exception:
logging.exception("Failed to send reminder to user_id=%s", user_id)