Skip to content

Commit c818760

Browse files
committed
Refactor code comments for clarity and update README with Python version compatibility
1 parent ff9b44a commit c818760

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@ EduPlannerBotAI/
6060

6161
## 🛠 Technologies Used
6262

63-
| Component | Purpose |
64-
|------------------|----------------------------------------|
65-
| Python 3.8+ | Programming language |
66-
| aiogram 3.x | Telegram Bot Framework |
67-
| OpenAI API | LLM for text generation |
68-
| matplotlib | Chart rendering |
69-
| fpdf | PDF file generation |
70-
| TinyDB | Lightweight NoSQL database |
71-
| python-dotenv | Environment variable management |
63+
| Component | Purpose |
64+
|---------------|----------------------------------------|
65+
| Python 3.10+ | Programming language |
66+
| aiogram 3.x | Telegram Bot Framework |
67+
| OpenAI API | LLM for text generation |
68+
| matplotlib | Chart rendering |
69+
| fpdf | PDF file generation |
70+
| TinyDB | Lightweight NoSQL database |
71+
| python-dotenv | Environment variable management |
7272

7373
## 🔧 CI/CD
7474

7575
- GitHub Actions workflow for Pylint analysis
76-
- Python version compatibility: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
76+
- Python version compatibility: 3.10, 3.11, 3.12, 3.13
7777
- Custom `.pylintrc` configuration
7878

7979
## 🤝 Collaboration

bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from config import TOKEN
1010
from handlers import start, planner
1111

12-
# Создаем необходимые директории
12+
# Create necessary directories
1313
os.makedirs("plans", exist_ok=True)
1414
os.makedirs("fonts", exist_ok=True)
1515

services/db.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
db = TinyDB("db.json")
44

5+
56
def save_user_plan(user_id: int, plan: list):
67
db.insert({"user_id": user_id, "plan": plan})

services/llm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
from openai import OpenAI, RateLimitError, APIError, OpenAIError
44
from config import OPENAI_API_KEY
55

6-
# Настройка логгера
6+
# Configure logging
77
logger = logging.getLogger(__name__)
88

99
# Initialize client
1010
client = OpenAI(api_key=OPENAI_API_KEY) if OPENAI_API_KEY else None
1111

1212
# Max retries and delay between retries
1313
MAX_RETRIES = 3
14-
RETRY_DELAY = 5 # Увеличиваем задержку между попытками
14+
RETRY_DELAY = 5 # Icrease delay for each retry
1515

1616

1717
# Локальный генератор
@@ -61,7 +61,7 @@ async def generate_study_plan(topic: str) -> list:
6161
except RateLimitError as e:
6262
logger.warning("Rate limit error: %s. Retrying in %s seconds...",
6363
str(e), RETRY_DELAY * (attempt + 1))
64-
await asyncio.sleep(RETRY_DELAY * (attempt + 1)) # Экспоненциальная задержка
64+
await asyncio.sleep(RETRY_DELAY * (attempt + 1)) # Exponential backoff
6565

6666
except (APIError, OpenAIError) as e:
6767
logger.error("OpenAI API error: %s", str(e))
@@ -72,6 +72,6 @@ async def generate_study_plan(topic: str) -> list:
7272
logger.error("Unexpected error: %s", str(e))
7373
return generate_local_plan(topic)
7474

75-
# Если все попытки исчерпаны, используем локальный генератор
75+
# If all attempts fail, fallback to local generator
7676
logger.warning("All OpenAI API attempts failed, using local generator")
7777
return generate_local_plan(topic)

services/pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def save_plan_to_pdf(plan_lines: list[str], user_id: int) -> str:
99

1010
filename = f"plans/plan_{user_id}.pdf"
1111

12-
# Создаем простой PDF без кастомных шрифтов, которые могут отсутствовать
12+
# Create a PDF object
1313
pdf = FPDF()
1414
pdf.add_page()
1515

services/reminders.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22

3+
34
async def schedule_reminders(user_id: int, plan: list):
45
# Emulate scheduling reminders
56
for i, task in enumerate(plan, start=1):

0 commit comments

Comments
 (0)