init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user