A small, private, self-hosted Telegram bot that turns everyday data into ready-to-use PNG QR codes.
Sometimes you need a QR code right now—not another account, dashboard, ad, watermark, or subscription. This bot lives in Telegram, creates a clean PNG, sends it back, and forgets the interaction.
It is intentionally boring behind the scenes: one lightweight Python process, long polling, no database, no analytics, and no queue. Clone it, add a bot token, and keep it on your own VPS.
| QR type | What it opens or fills in |
|---|---|
| 📝 Text & links | Any text, URL, invite, code, or note |
| 📶 Wi-Fi | Network name, password, and WPA/WEP/open security |
| 👤 Contact | A portable vCard with phone, email, company, website, and address |
| 📞 Phone | International formats normalized to a ready-to-dial number |
| 💬 SMS | A number and pre-filled message |
| Recipient, subject, and body | |
| 📍 Location | Shared Telegram location or latitude/longitude |
| A profile, bot, group, or public channel link |
There are no design controls to get in the way. Every result is a standard black-on-white PNG with sensible QR error correction and a balanced 24 px edge.
- Send any text or link for instant generation.
- Use a persistent Telegram reply keyboard for structured formats without adding inline controls to the conversation.
- Share a Telegram location instead of copying coordinates.
- Get automatic Russian or English UI from the Telegram language.
- Use
/cancelat any point and/startto return to the menu. - Receive a large inline image as a direct reply to the source message, keeping the QR code and its context together.
The shortest privacy policy is the best one:
message → QR code in memory → PNG sent to Telegram → memory released
The bot has no user table, history, analytics, tracking, advertising SDK, or external API beyond Telegram itself. It never writes QR contents to disk and does not log messages, chat IDs, or user IDs. RAM keeps only a chat/user key and the selected menu item while waiting for the next message; unfinished entries expire after 15 minutes.
Telegram still receives messages and files as part of normal bot delivery. For secrets that must never reach Telegram, use an offline QR generator.
You need a token from @BotFather and a machine with Docker. FFmpeg is not required.
git clone https://github.com/Avazbek22/qr-code-generator-tgbot.git
cd qr-code-generator-tgbot
cp .env-example .envPut your token in .env:
BOT_TOKEN=123456789:replace_with_your_bot_tokenThen start the bot:
mkdir -p data logs
sudo chown -R 10001:10001 data logs
docker compose up -d --build
docker compose psOpen the bot in Telegram and send /start.
On Ubuntu 22.04 or 24.04, the included installer configures Docker Compose,
starts the bot, and enables safe updates from origin/main:
git clone https://github.com/Avazbek22/qr-code-generator-tgbot.git
cd qr-code-generator-tgbot
bash install.shIf .env has no token, the installer asks for it through a hidden prompt. It
then builds a candidate image, verifies the Telegram token, starts a healthy
container, and enables a systemd timer.
From then on, a normal update is simply:
git push origin mainThe VPS checks for fast-forward updates roughly every two minutes. A broken build or unhealthy container is rolled back automatically. Documentation-only commits update the checkout without rebuilding the bot.
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements-dev.txt
cp .env-example .env
# Add BOT_TOKEN to .env
python main.pyOn Windows PowerShell, activate with
.venv\Scripts\Activate.ps1.
The production container:
- runs as the unprivileged
10001:10001user; - has a read-only root filesystem and drops all Linux capabilities;
- is capped at 0.5 CPU, 192 MB RAM, and 64 processes;
- writes only operational, token-redacted logs and deployment state;
- uses Docker log rotation and a tiny
/tmpfilesystem; - exposes no port because Telegram long polling needs no reverse proxy;
- includes a heartbeat healthcheck for Docker and automatic rollback.
The image contains Python, the Telegram client, Pillow, and the QR generator. There is no browser, database server, Redis, web framework, FFmpeg, or native QR encoder.
Most installations only need BOT_TOKEN.
| Variable | Default | Purpose |
|---|---|---|
BOT_TOKEN |
required | Token issued by BotFather |
APP_NAME |
repository directory | Unique Docker/systemd name on the VPS |
LOG_LEVEL |
INFO |
DEBUG, INFO, WARNING, ERROR, or CRITICAL |
POLLING_TIMEOUT_SECONDS |
20 |
Telegram request timeout |
LONG_POLLING_TIMEOUT_SECONDS |
30 |
Telegram long-poll timeout |
HEALTH_HEARTBEAT_SECONDS |
25 |
Health marker refresh interval |
HEALTH_MAX_AGE_SECONDS |
120 |
Maximum accepted health marker age |
The same .env is used locally and in Docker. It is excluded from Git and the
Docker build context. Never commit a real bot token.
# Status and logs
docker compose ps
docker compose logs -f --tail=100 bot
# Restart
docker compose restart bot
# Update manually
sudo bash scripts/deploy.sh
# Restore the previous healthy release
sudo bash scripts/rollback.shIf you changed APP_NAME, use the slug printed by install.sh:
APP_SLUG=my-qr-bot docker compose ps
sudo systemctl status my-qr-bot-deploy.timerSee the VPS acceptance checklist for a full production verification.
This repository is meant to be forked:
- Fork it and rename the project if you like.
- Update
APP_NAMEin.env-example. - Replace the README banner and repository links.
- Add or remove formats in
app/qr.pyandapp/handlers/common.py. - Keep the deployment layer unchanged unless you need different infrastructure.
Runtime code is deliberately separated from the tested deployment scripts, so bot features can evolve without weakening rollback behavior.
python -m ruff check .
python -m ruff format --check .
python -m pytest
shellcheck install.sh scripts/*.sh tests/shell/*.sh
bash tests/shell/test-deploy.sh
ENV_FILE=.env-example APP_SLUG=qr-code-generator-tgbot \
docker compose config --quietCI runs Python tests on 3.11, 3.12, and 3.13, validates shell deployment and rollback scenarios, builds the production image, and checks its non-root, read-only configuration.
Small, focused improvements are welcome. Please read CONTRIBUTING.md, avoid adding tracking or mandatory hosted services, and never include a real bot token in an issue or log.
Security concerns should follow SECURITY.md.
MIT — use it, fork it, host it, and make it yours.
Built for people who want a QR code—not a platform.
telegram qr code bot · self-hosted qr generator · open source telegram bot · docker qr code generator · python telegram bot
