This project is a Telegram bot that generates QR codes for URLs, WIFI auto-connection, visit card (vcard) and more sent by users. The bot validates the data and returns a QR code image.
Bot deployment is currently on Northflank, you can pay a visit directly in Telegram accessing the qrcodegen-bot.
- Data validation using Pydantic.
- QR code generation using the
qrcode
library. - Asynchronous handling of Telegram messages, thanks python-telegram-bot people.
- Future features: different kind of QR codes with inlinekeyboard guidance.
- Docker
- Docker Compose
📦 Pull the Image from Docker Hub
-
Pull the image from Docker Hub: To get the latest version of
qrcodegen
, pull it from Docker Hub:docker pull jpizquierdo/qrcodegen:latest
-
Run the container:
docker run --env TELEGRAM_TOKEN=yourGodFatherFancyToken -d jpizquierdo/qrcodegen:latest
-
Or run the container with docker compose:
Create a
.env
file with your Telegram bot token (check.env.example
):TELEGRAM_TOKEN="your_telegram_bot_token"
Execute:
docker compose up -d
-
Clone the repository:
git clone https://github.com/jpizquierdo/qrcodegen.git cd qrcodegen
-
Create a
.env
file with your Telegram bot token (check.env.example
):TELEGRAM_TOKEN="your_telegram_bot_token"
-
Build and run the Docker containers:
docker compose up -d --build
-
Open Telegram and send a message to your bot clicking in any button like a URL. The bot will respond with a QR code image.
If you prefer to use docker run sentence and build the image yourself follow the these steps:
- Build the image from Dockerfile:
docker build -t qrcode_generator_bot .
- Run the container with the environment variable:
docker run --env TELEGRAM_TOKEN=your_secret_token -d qrcode_generator_bot
- Open Telegram and send a message to your bot clicking in any button like a URL. The bot will respond with a QR code image.
This project includes optional observability features powered by Pydantic Logfire. You can enable logging and tracing by configuring the following environment variables in your .env
file:
LOGFIRE_ENABLED=true
LOGFIRE_TOKEN="your_logfire_token"
- Set
LOGFIRE_ENABLED
totrue
in your.env
file. - Provide your Logfire token in the
LOGFIRE_TOKEN
variable.
When enabled, the bot will log events and traces to Logfire, providing insights into its runtime behavior and performance.
Note: Observability is disabled by default. If
LOGFIRE_ENABLED
is set tofalse
or theLOGFIRE_TOKEN
is not provided, the bot will use a no-op logger as a fallback.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.