{"id":49906372,"url":"https://github.com/romkravets/telegram-bot-googletrans","last_synced_at":"2026-05-16T11:00:54.715Z","repository":{"id":298634071,"uuid":"1000322284","full_name":"romkravets/telegram-bot-googletrans","owner":"romkravets","description":"Telegram Translation Bot A public Telegram bot that translates text, forwarded posts, and photos — right where you are.","archived":false,"fork":false,"pushed_at":"2026-05-16T09:01:59.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-16T10:46:49.255Z","etag":null,"topics":["deepl","google-translate","inline-bot","ocr","poll","ptb","python","python-telegram-bot","sqlite","telegram-bot-ai-assistant","tesseract","translation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/romkravets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-11T15:44:08.000Z","updated_at":"2026-05-16T09:00:16.000Z","dependencies_parsed_at":"2025-06-12T04:39:16.571Z","dependency_job_id":"03c660d4-60e1-4413-9e63-11a30a406520","html_url":"https://github.com/romkravets/telegram-bot-googletrans","commit_stats":null,"previous_names":["romkravets/telegram-bot-googletrans"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/romkravets/telegram-bot-googletrans","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romkravets%2Ftelegram-bot-googletrans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romkravets%2Ftelegram-bot-googletrans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romkravets%2Ftelegram-bot-googletrans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romkravets%2Ftelegram-bot-googletrans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romkravets","download_url":"https://codeload.github.com/romkravets/telegram-bot-googletrans/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romkravets%2Ftelegram-bot-googletrans/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33100319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepl","google-translate","inline-bot","ocr","poll","ptb","python","python-telegram-bot","sqlite","telegram-bot-ai-assistant","tesseract","translation"],"created_at":"2026-05-16T11:00:23.015Z","updated_at":"2026-05-16T11:00:54.709Z","avatar_url":"https://github.com/romkravets.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegram Translation Bot\n\nA public Telegram bot that translates text, forwarded posts, and photos — right where you are.\n\n**Developer:** [Roman Kravets](https://github.com/romkravets)\n\n---\n\n## Features\n\n| Feature | Description |\n|---------|-------------|\n| 💬 Text translation | Send any text — get an instant translation |\n| 📨 Forwarded posts | Forward a channel post or message — bot translates it automatically |\n| 📷 Photo OCR | Send a photo with text — bot extracts and translates it via Tesseract |\n| ✍️ Inline mode | Type `@botname text` in **any** chat — see translation without leaving |\n| 👥 Group support | Mention the bot `@botname your text` in any group |\n| 🌐 30+ languages | DeepL (primary) + Google Translate (fallback) |\n| 💾 Preferences | Per-user language saved in SQLite — remembered across sessions |\n\n---\n\n## How to use\n\n### Private chat\nJust send any text, forward a post, or send a photo with text.\n\n### Groups\nMention the bot with your text:\n```\n@YourBotName Привіт, як справи?\n```\nFor forwarded posts in groups — mention must appear in the caption.\n\n### Inline mode (translate anywhere)\nType `@YourBotName` followed by a space and your text **in any chat**:\n```\n@YourBotName The quick brown fox jumps over the lazy dog\n```\nA translation result will appear as a popup — tap it to send.\nThis is the fastest way to translate without switching chats.\n\n### Commands\n| Command | Description |\n|---------|-------------|\n| `/start` | Welcome message + choose target language |\n| `/lang` | Open language picker |\n| `/lang Polish` | Set language directly by name |\n| `/help` | Show this usage guide |\n\n---\n\n## Supported languages\n\nDeepL (high quality) + Google Translate (fallback for all languages):\n\n🇺🇦 Ukrainian · 🇬🇧 English · 🇩🇪 German · 🇫🇷 French · 🇪🇸 Spanish · 🇮🇹 Italian · 🇵🇱 Polish · 🇵🇹 Portuguese · 🇨🇳 Chinese · 🇯🇵 Japanese · 🇰🇷 Korean · 🇷🇺 Russian · 🇸🇦 Arabic · 🇳🇱 Dutch · 🇸🇪 Swedish · 🇩🇰 Danish · 🇫🇮 Finnish · 🇨🇿 Czech · 🇸🇰 Slovak · 🇷🇴 Romanian · 🇭🇺 Hungarian · 🇧🇬 Bulgarian · 🇬🇷 Greek · 🇹🇷 Turkish · 🇮🇩 Indonesian · 🇳🇴 Norwegian · 🇮🇳 Hindi · 🇻🇳 Vietnamese · 🇹🇭 Thai · 🇮🇱 Hebrew · 🇮🇷 Persian\n\n---\n\n## Architecture\n\n```\ntelegram-bot-googletrans/\n├── bot.py                  # Entry point: registers all handlers, starts polling\n├── config.py               # Centralised env var loading (BOT_TOKEN, DEEPL_API_KEY, DB_PATH)\n├── languages.py            # Language registry (31 languages, DeepL + Google codes)\n├── handlers/\n│   ├── start.py            # /start, /lang, /help commands + language keyboard callback\n│   ├── translate.py        # Text and forwarded message handlers\n│   ├── photo.py            # Photo handler: download → OCR → translate\n│   └── inline.py           # Inline query handler (@botname text in any chat)\n├── services/\n│   ├── translator.py       # DeepL (thread-local singleton) + Google fallback\n│   └── ocr.py              # Tesseract OCR via pytesseract + Pillow\n├── db/\n│   └── storage.py          # SQLite: init, get_language, set_language\n├── tests/                  # 20 unit tests (languages, storage, OCR, translator)\n├── ecosystem.config.js     # PM2 process config for VPS deployment\n├── requirements.txt        # Production dependencies\n└── requirements-dev.txt    # Dev dependencies (adds pytest)\n```\n\nAll blocking I/O (SQLite, HTTP translation requests, Tesseract OCR) runs via `asyncio.to_thread` so the event loop is never blocked.\n\n---\n\n## Local development\n\n### Prerequisites\n- Python 3.10+\n- Tesseract OCR installed\n\nInstall Tesseract (macOS):\n```bash\nbrew install tesseract\n```\n\nInstall Tesseract (Ubuntu/Debian):\n```bash\nsudo apt install tesseract-ocr tesseract-ocr-ukr tesseract-ocr-deu \\\n  tesseract-ocr-fra tesseract-ocr-spa tesseract-ocr-pol tesseract-ocr-chi-sim\n```\n\n### Setup\n\n```bash\ngit clone https://github.com/romkravets/telegram-bot-googletrans\ncd telegram-bot-googletrans\n\npython3 -m venv .venv\nsource .venv/bin/activate\n\npip install -r requirements-dev.txt   # includes pytest\ncp .env.example .env\n# edit .env: fill in BOT_TOKEN and optionally DEEPL_API_KEY\n```\n\n### Run tests\n\n```bash\npytest\n```\n\n### Start the bot\n\n```bash\npython3 bot.py\n```\n\n---\n\n## Enable inline mode (required for @botname in any chat)\n\n1. Open [@BotFather](https://t.me/BotFather) in Telegram\n2. Send `/setinline`\n3. Choose your bot\n4. Enter a placeholder hint, e.g. `Enter text to translate...`\n\nThat's it. No code changes needed — the bot already handles inline queries.\n\n---\n\n## VPS deployment (Ubuntu/Debian + PM2)\n\n### 1. Install Node.js + PM2\n\n```bash\ncurl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -\nsudo apt-get install -y nodejs\nsudo npm install -g pm2\n```\n\n### 2. Install Tesseract\n\n```bash\nsudo apt install tesseract-ocr tesseract-ocr-ukr tesseract-ocr-deu \\\n  tesseract-ocr-fra tesseract-ocr-spa tesseract-ocr-pol tesseract-ocr-chi-sim\n```\n\nAdd more packs as needed: `tesseract-ocr-jpn`, `tesseract-ocr-chi-sim`, etc.\n\n### 3. Clone and configure\n\n```bash\ngit clone https://github.com/romkravets/telegram-bot-googletrans /opt/translate-bot\ncd /opt/translate-bot\n\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n\ncp .env.example .env\nnano .env   # fill in BOT_TOKEN and DEEPL_API_KEY\n```\n\n### 4. Start with PM2 and enable auto-start on reboot\n\n```bash\npm2 start ecosystem.config.js\npm2 startup systemd\npm2 save\n```\n\n### PM2 commands\n\n```bash\npm2 logs translate-bot      # live logs\npm2 restart translate-bot   # restart\npm2 stop translate-bot      # stop\npm2 list                    # all running processes\n```\n\n---\n\n## Environment variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `BOT_TOKEN` | ✅ | From [@BotFather](https://t.me/BotFather) |\n| `DEEPL_API_KEY` | optional | [DeepL free tier](https://www.deepl.com/pro-api): 500k chars/month. If not set, falls back to Google Translate for all requests |\n| `DB_PATH` | optional | SQLite file path (default: `./data/translate_bot.db`) |\n\n---\n\n## Tech stack\n\n- [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) v22 — async bot framework\n- [DeepL Python SDK](https://github.com/DeepLcom/deepl-python) — primary translation engine\n- [deep-translator](https://github.com/nidhaloff/deep-translator) — Google Translate fallback\n- [pytesseract](https://github.com/madmaze/pytesseract) + [Pillow](https://python-pillow.org/) — OCR\n- SQLite (stdlib) — user language preferences\n- [PM2](https://pm2.keymetrics.io/) — process manager for VPS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromkravets%2Ftelegram-bot-googletrans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromkravets%2Ftelegram-bot-googletrans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromkravets%2Ftelegram-bot-googletrans/lists"}