You can try this bot on Telegram by searching for @IprilBot or clicking the link to start a conversation.
A Telegram bot that helps users learn languages through conversation with AI-powered corrections, tips, and follow-up questions.
- Grammar correction in 6 languages (English, Spanish, French, German, Italian, Russian)
- User language preference persistence
- Rate limiting (15 requests/minute per user)
- Adaptive conversation difficulty (beginner/intermediate)
/privacyand/forgetfor transparency and clearing chat memory- Validated configuration (missing
BOT_TOKEN/DEEPSEEK_API_KEYfails fast) - DeepSeek HTTP calls with timeouts
- Automated daily backups
- Error handling and logging
- Unit tests for core functionality
/start- Welcome message with instructions/setlang [code]- Change language preference/currentlang- Show current language/privacy- How your data is used (DeepSeek, local storage)/forget- Clear conversation memory (keeps saved language)
Here are some examples of how the bot corrects grammar and engages in conversation:
User: /setlang en
Bot: Language set to English!
User: "I goes to the store"
Bot:
[Correction: I go to the store]
Tip: Use "go" with I/you/we/they (not "goes").
Vocab: grocery store, to buy
What do you like to buy there?
User: /setlang es
Bot: ¡Idioma configurado a español!
User: "Yo ir al parque"
Bot:
[Corrección: Yo voy al parque]
Consejo: El verbo “ir” cambia: yo voy.
Vocabulario: parque, pasear
¿Qué te gusta hacer en el parque?
User: /setlang fr
Bot: Langue définie sur français !
User: "Je vais au parc"
Bot:
[Correction: Je vais au parc]
Qu'aimes-tu faire au parc?
User: /setlang de
Bot: Sprache auf Deutsch eingestellt!
User: "Ich gehen ins Kino"
Bot:
[Korrektur: Ich gehe ins Kino]
Tipp: Das Verb wird konjugiert: ich gehe (nicht „ich gehen“).
Vokabeln: Kino, gehen
Welche Filme schaust du gerne?
User: /setlang it
Bot: Lingua impostata su italiano!
User: "Io mangiare la pizza"
Bot:
[Correzione: Io mangio la pizza]
Suggerimento: Il verbo si coniuga: io mangio (non “io mangiare”).
Vocabolario: pizza, mangiare
Qual è la tua pizza preferita?
User: /setlang ru
Bot: Язык установлен на русский!
User: "Я ходить в магазин"
Bot:
[Исправление: Я хожу в магазин]
Подсказка: Глагол нужно спрягать: я хожу (не «я ходить»).
Слова: магазин, покупать
Что ты обычно покупаешь в магазине?
The bot not only corrects grammar but also:
- Maintains conversation context
- Corrects grammar in the input language (including the "Correction:" text)
- Asks follow-up questions in the chosen language
- Supports 6 languages
- Remembers user preferences
- Has a rate limit of 15 requests per minute
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Copy
.env.exampleto.envand fill in your credentials:cp .env.example .env
- Edit
.envwith your:- Telegram Bot Token (from @BotFather)
- DeepSeek API Key
Note: Messages you send for correction are forwarded to DeepSeek for processing. Avoid sending secrets. See /privacy in the bot for details.
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Run the bot:
python bot.py
-
Run tests:
pytest tests/ -v
The project includes unit tests for core functionality:
- User data management
- Rate limiting
- Bot initialization
- Data persistence
- Configuration validation (
config.py)
Run tests locally:
pytest tests/ -vbot.py- Main bot implementationconfig.py- Environment settings validationdeepseek_client.py- DeepSeek API HTTP client (timeouts)requirements.txt- Python dependencies.env- Environment variables (not in git)user_data.json- User preferences storagebackups/- Daily backups of user databot.log- Application logstests/- Unit tests
The bot includes comprehensive error handling for:
- API failures
- Invalid inputs
- Rate limit exceeded
- File system operations
All errors are logged to bot.log for debugging.
Security note: avoid sharing or committing bot.log. Logs may include URLs and snippets from upstream errors.
MIT License
