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 improve their writing in multiple languages using AI-powered grammar correction.
- Grammar correction in 6 languages (English, Spanish, French, German, Italian, Russian)
- User language preference persistence
- Rate limiting (15 requests/minute per user)
- 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
Here are some examples of how the bot corrects grammar and engages in conversation:
User: /setlang en
Bot: Language set to English!
User: "Je mange un pomme"
Bot: "[Correction: Je mange une pomme] What do you like to eat?"
User: /setlang es
Bot: ¡Idioma configurado a español!
User: "I goes to the store"
Bot: "[Corrección: I go to the store] ¿Qué te gusta comprar en la tienda?"
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: "Io mangiare la pizza"
Bot: "[Korrektur: Io mangio la pizza] Was isst du gerne?"
User: /setlang it
Bot: Lingua impostata su italiano!
User: "Я ходить в магазин"
Bot: "[Correzione: Я хожу в магазин] Cosa ti piace comprare?"
User: /setlang ru
Bot: Язык установлен на русский!
User: "Yo ir al parque"
Bot: "[Исправление: Yo voy al parque] Что тебе нравится делать в парке?"
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
-
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
Run tests locally:
pytest tests/ -vbot.py- Main bot implementationrequirements.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.
MIT License
