TranslationBot is a Telegram bot that translates text between English and Persian. It supports:
- Full text translation
- Single-word translation with part-of-speech information and IPA pronunciation
- Secure access control based on allowed user IDs
- Deployment via Docker and Docker Compose
- Language Translation: Translates text between English and Persian using Google's Gemini API.
- Word Analysis: Provides part-of-speech and IPA pronunciation for English words.
- User Access Control: Only allowed users can use the bot.
- Docker Support: Easily deployable with Docker and Docker Compose.
📦 TranslationBot
├─ .gitignore
├─ Dockerfile
├─ LICENSE
├─ docker-compose.yml
├─ example.env
├─ main.py
└─ requirements.txt
main.py
: The core script for the bot, handling translation and user interactions.requirements.txt
: Lists Python dependencies.Dockerfile
: Defines the Docker container setup.docker-compose.yml
: Configuration for deploying with Docker Compose.example.env
: Example environment variable file for configuration..gitignore
: Specifies files to exclude from version control.LICENSE
: Specifies the project's license.
- Python 3.8+
- A Telegram bot token from BotFather
- A Google API key for Gemini
- Clone the repository:
git clone https://github.com/SajjadTalks/TranslationBot.git cd TranslationBot
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file:cp example.env .env
- Edit
.env
and set:BOT_TOKEN=your_telegram_bot_token GOOGLE_API_KEY=your_google_api_key MODELAI=gemini-pro # or another supported model ALLOWED_USER_IDS=123456789,987654321 # Comma-separated Telegram user IDs
Run the bot using:
python main.py
- Build the Docker image:
docker build -t translationbot .
- Run the container:
docker run --env-file .env translationbot
- Update
.env
with your credentials. - Start the bot:
docker-compose up -d
- Start the bot by sending
/start
. - Send any text to translate.
- The bot automatically detects the language and translates accordingly.
- For single-word translations, it provides:
- Part of speech
- IPA pronunciation (for English words)
- Example sentences in both languages
This project is licensed under the Apache-2.0 License. See LICENSE for details.
Feel free to submit issues or pull requests to improve the bot!