Steve Dudenhoeffer fdf1180722
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Add better error handling for Cloudflare rate limiting
- Handle None returns from pull_statuses gracefully
- Add specific error messages for rate limiting scenarios
- Skip None posts in iteration to avoid TypeErrors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 02:36:41 -05:00
2026-01-23 00:53:46 -05:00

Pravda

A Python-based Dockerized service that monitors Truth Social feeds and relays posts to Discord via webhooks. Features intelligent media handling (transcoding/splitting) and interactive message components.

Features

  • Monitors Truth Social feeds using the truthbrush library
  • Relays posts to Discord with full media support
  • Automatic video transcoding to H.264/AAC for Discord compatibility
  • Smart file size management (keeps videos under 50MB)
  • Message splitting for long posts (Discord's 2000 char limit)
  • Interactive buttons for deleting messages and viewing raw post data
  • SQLite database for tracking processed posts
  • FastAPI server for handling Discord interaction webhooks

Requirements

  • Python 3.12+
  • Docker (for containerized deployment)
  • ffmpeg (for video transcoding)
  • A Truth Social account (for API access)
  • A Discord webhook URL
  • A Discord application (for interaction components)

Environment Variables

Variable Description Required
TRUTHSOCIAL_USERNAME Truth Social account username Yes
TRUTHSOCIAL_PASSWORD Truth Social account password Yes
DISCORD_WEBHOOK Discord Webhook URL for posting messages Yes
DISCORD_APPLICATION_ID Discord Application ID for components Yes
DISCORD_PUBLIC_KEY Public Key for verifying interaction signatures Yes (if using interactions)
POLL_INTERVAL Seconds between checks (default: 300) No
TRUTH_USER Target username to monitor (default: realDonaldTrump) No
DB_PATH Path to SQLite DB (default: /data/seen.db) No

Quick Start

Local Development

# Install dependencies
pip install -r requirements.txt

# Set environment variables
export TRUTHSOCIAL_USERNAME="your_truthsocial_username"
export TRUTHSOCIAL_PASSWORD="your_truthsocial_password"
export DISCORD_WEBHOOK="your_webhook_url"
export DISCORD_APPLICATION_ID="your_app_id"
export DISCORD_PUBLIC_KEY="your_public_key"

# Run locally
python main.py

Docker

# Build image
docker build -t pravda .

# Run in daemon mode (Poller + Server)
docker run -d \
  -e TRUTHSOCIAL_USERNAME="your_truthsocial_username" \
  -e TRUTHSOCIAL_PASSWORD="your_truthsocial_password" \
  -e DISCORD_WEBHOOK="your_webhook_url" \
  -e DISCORD_APPLICATION_ID="your_app_id" \
  -e DISCORD_PUBLIC_KEY="your_public_key" \
  -v $(pwd)/data:/data \
  -p 8080:8080 \
  pravda

# One-off mode: relay a specific post
docker run --rm \
  -e TRUTHSOCIAL_USERNAME="your_truthsocial_username" \
  -e TRUTHSOCIAL_PASSWORD="your_truthsocial_password" \
  -e DISCORD_WEBHOOK="your_webhook_url" \
  pravda https://truthsocial.com/@realDonaldTrump/posts/123456789

Architecture

The application runs two concurrent processes:

  1. The Poller: Loops infinitely, checking for new posts. Processed posts are cached in SQLite to prevent duplicates.

  2. The Server: A FastAPI instance listening on port 8080 to handle Discord interaction webhooks (button clicks).

Interaction Endpoints

  • POST /interactions - Discord interaction webhook handler
  • GET /health - Health check endpoint

Discord Components

Messages include interactive buttons:

  • Delete: Removes the message (requires MANAGE_MESSAGES permission)
  • View Raw: Shows the raw post JSON (ephemeral)
  • Original Post: Links to the original Truth Social post

Media Handling

  • Images: Downloaded and attached directly
  • Videos: Transcoded to H.264/AAC MP4 format
    • Automatically scaled down if over 50MB
    • Resolution reduced progressively (720p, then 480p) if needed

Development

# Install dev dependencies
pip install -r requirements.txt
pip install black ruff mypy pytest

# Format code
black .

# Lint
ruff check .

# Type check
mypy .

# Run tests
pytest

Project Structure

pravda/
├── main.py              # Application entrypoint
├── src/
│   ├── __init__.py
│   ├── database.py      # SQLite operations
│   ├── discord.py       # Discord webhook handling
│   ├── media.py         # Media processing (ffmpeg)
│   ├── poller.py        # Truth Social polling
│   └── server.py        # FastAPI interaction handler
├── Dockerfile
├── entrypoint.sh
├── requirements.txt
├── pyproject.toml
└── .gitea/
    └── workflows/
        └── build-push.yaml

License

MIT

Description
No description provided
Readme 70 KiB
Languages
Python 97.3%
Dockerfile 1.7%
Shell 1%