Skip to content

Commit eedf981

Browse files
committed
docs: update README for 2.1.0, reminders now sent as Telegram messages
1 parent 9d5a469 commit eedf981

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ env/
134134
ENV/
135135
env.bak/
136136
venv.bak/
137-
# .venv/ # НЕ добавлять, чтобы не удалять локальное окружение
137+
# .venv/ # Do NOT add, so as not to delete the local environment
138138

139139
# IDEs
140140
.idea/

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# EduPlannerBotAI
22

3-
**EduPlannerBotAI** is a Telegram bot built with `aiogram 3.x` and powered by OpenAI GPT. It generates personalized study plans, exports them to PDF/TXT, and schedules reminders. All data is stored using TinyDB.
3+
**EduPlannerBotAI** is a Telegram bot built with `aiogram 3.x` and powered by OpenAI GPT. It generates personalized study plans, exports them to PDF/TXT, and sends reminders as Telegram messages. All data is stored using TinyDB.
44

55
> **Note:** All code comments and docstrings are now in English for better international collaboration and code clarity.
66
77
## 📌 Features
88

99
- 📚 Generate personalized study plans (LLM/OpenAI)
1010
- 📝 Export study plans to PDF/TXT
11-
-Schedule reminders (async simulation)
11+
-Send reminders as Telegram messages for each study step
1212
- 🗄️ Store data using TinyDB
1313
- 📊 Python 3.10–3.13 support
1414

@@ -47,6 +47,10 @@ docker-compose up --build
4747
```
4848
Environment variables are loaded from `.env`.
4949

50+
## 🔔 How Reminders Work
51+
52+
When you choose to schedule reminders, the bot will send you a separate Telegram message for each step of your study plan. This ensures you receive timely notifications directly in your chat.
53+
5054
## 🧪 Testing & Code Quality
5155

5256
- 100% of core logic is covered by automated tests (`pytest`).

bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
os.makedirs("plans", exist_ok=True)
1515
os.makedirs("fonts", exist_ok=True)
1616

17-
# Проверка наличия токенов
17+
# Check for token presence
1818
if not TOKEN:
1919
print("[ERROR] BOT_TOKEN is not set in environment variables.", file=sys.stderr)
2020
sys.exit(1)
2121

22-
# Настройка логирования
22+
# Logging setup
2323
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()
2424
LOG_FILE = os.getenv("LOG_FILE")
2525

handlers/planner.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ async def handle_reminders(callback: types.CallbackQuery, state: FSMContext):
149149
callback.message, Message
150150
) else None
151151
# Run async reminder scheduling task
152-
reminders_count = await schedule_reminders(user_id, plan)
152+
if callback.bot is None:
153+
if isinstance(callback.message, Message):
154+
await callback.message.answer("Internal error: bot instance is not available.")
155+
return
156+
reminders_count = await schedule_reminders(user_id, plan, callback.bot)
153157
# Update message after scheduling completion
154158
if isinstance(message, Message):
155159
await message.edit_text(

services/reminders.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
import asyncio
22
import logging
3+
from aiogram import Bot
34

45
logger = logging.getLogger(__name__)
56

67

7-
async def schedule_reminders(user_id: int, plan: list):
8-
"""Schedule reminders for study plan steps"""
8+
async def schedule_reminders(user_id: int, plan: list, bot: Bot):
9+
"""Schedule reminders for study plan steps and send messages to the user"""
910
logger.info("Scheduling reminders for user %s", user_id)
1011

12+
count = 0
1113
for i, task in enumerate(plan, start=1):
1214
if task.strip(): # Skip empty lines in plan
1315
await asyncio.sleep(0.1) # Simulate delay for scheduling
16+
reminder_text = f"⏰ Reminder {i}: {task}"
17+
try:
18+
await bot.send_message(user_id, reminder_text)
19+
except Exception as e:
20+
logger.error("Failed to send reminder to %s: %s", user_id, e)
1421
logger.info("Reminder for %s: day %s — %s", user_id, i, task)
22+
count += 1
1523

16-
return len([task for task in plan if task.strip()]) # Return number of reminders
24+
return count # Return number of reminders

0 commit comments

Comments
 (0)