100% vibe coded btw
A Telegram bot that monitors lab results at https://lablaudo.com.br/acesso_paciente and provides notifications when results are ready. Available as both a Python application and a standalone executable binary.
- 🤖 Interactive Telegram bot interface
- 🔐 Secure credential storage in SQLite database
- ⏰ Automatic monitoring every 30 minutes
- 📱 Instant Telegram notifications when results are ready
- 📄 Automatic PDF download and delivery when results are available
- 🔓 Base64 PDF decoding from embedded HTML responses
- 👥 Multi-user support
- 📊 Status tracking and monitoring history
- ✅ Immediate startup check - Checks all users when bot starts
- 🔄 Auto-removal from monitoring after PDF delivery
- 📦 Standalone executable binary - No Python installation required
# Download the latest release (or build from source)
wget https://github.com/your-repo/lablaudo/releases/latest/download/lablaudo
# Make executable
chmod +x lablaudo
# Run with your bot token
TELEGRAM_BOT_TOKEN=your_bot_token_here ./lablaudo
- Create and activate virtual environment:
python3 -m venv venv
source venv/bin/activate
- Install dependencies:
pip install -e .
- Run in development mode:
export TELEGRAM_BOT_TOKEN=your_bot_token_here
python3 main.py
- Create a bot with @BotFather on Telegram
- Get your bot token
- Run the application (binary or Python)
- Start a chat with your bot and use
/start
to begin
/start
- Welcome message and setup instructions/add
- Add your lab portal credentials/remove
- Remove your stored credentials/check
- Check your results immediately/status
- Show your monitoring status/help
- Show help message
- Startup Check: When the bot starts, it immediately checks all stored users for ready results
- Login: Authenticates with the patient portal using provided credentials
- Parse Results: Finds all table rows (
<tr>
) containing lab results - Check Status: Examines each row's background color/style for green indicators (
bgcolor="#8FF08F"
and "Liberado" status) - PDF Download: When all results are ready, searches for "Visualizar Laudo" or "Baixar" links
- Base64 Decoding: Extracts PDF content from embedded base64 data in HTML responses
- Delivery: Downloads PDF using authenticated session and sends directly to user via Telegram
- Auto-cleanup: Removes user from monitoring after successful PDF delivery
- Periodic Monitoring: Continues checking every 30 minutes for remaining users
The bot uses SQLite to store user data:
CREATE TABLE users (
telegram_id INTEGER PRIMARY KEY,
username TEXT NOT NULL,
password TEXT NOT NULL,
active INTEGER DEFAULT 1,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_check TIMESTAMP,
last_status TEXT
);
requests
: HTTP client for web scrapingbeautifulsoup4
: HTML parsingpython-telegram-bot
: Telegram bot frameworkapscheduler
: Periodic task scheduling
- Credentials are stored locally in SQLite database
- No data is transmitted to external services except the lab portal
- Bot token should be kept secure and not committed to version control
- PDF files are temporarily processed in memory and not stored on disk
source venv/bin/activate
python3 test_bot.py
python3 test_pdf.py