A Python application that monitors Truth Social posts from specified users and forwards them to Discord.
- Monitors Truth Social users' posts using Mastodon-compatible API
- Forwards posts to Discord via webhooks
- Stores processed posts in MongoDB to avoid duplicates
- Supports media attachments (images, videos, GIFs)
- Rate limiting for Discord notifications
- Automatic retries for failed requests
- Comprehensive error handling and logging
- Python 3.8 or higher
- MongoDB instance
- Discord webhook URL
- Flaresolverr to run requests through
-
Clone the repository:
git clone https://github.com/darrenwatt/truthy.git cd truthy -
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile with your configuration:# Logging LOG_LEVEL=INFO APPNAME="Truth Social Monitor" ENV=PROD REPEAT_DELAY=300 # Discord DISCORD_NOTIFY=true DISCORD_USERNAME="Truth Social Bot" DISCORD_WEBHOOK_URL=your_webhook_url_here # MongoDB MONGO_DBSTRING=mongodb://localhost:27017/ MONGO_DB=truthsocial MONGO_COLLECTION=posts # Truth Social TRUTH_USERNAME=username_to_monitor TRUTH_INSTANCE=truthsocial.com # Request Settings REQUEST_TIMEOUT=30 MAX_RETRIES=3 # Flaresolverr FLARESOLVERR_ADDRESS=localhost FLARESOLVERR_PORT=8191
Run flaresolverr locally with docker compose (supplied):
docker compose up -dRun the monitor:
python main.pyOr using Docker:
docker build -t truth-social-monitor .
docker run -d --env-file .env truth-social-monitorAll configuration is handled via environment variables, typically set in a .env file at the project root.
| Variable | Description | Example/Default |
|---|---|---|
TRUTH_USERNAME |
The Truth Social username to monitor | realDonaldTrump |
MONGO_DBSTRING |
MongoDB connection string (URI) | mongodb+srv://... |
| Variable | Description | Example/Default |
|---|---|---|
LOG_FORMAT |
Python logging format string | See config.py for default |
LOG_LEVEL |
Logging level | INFO |
APPNAME |
Application name | Truth Social Monitor |
ENV |
Environment name | DEV |
REPEAT_DELAY |
Delay between checks (seconds) | 300 |
DISCORD_NOTIFY |
Enable Discord notifications (true/false) |
true |
DISCORD_USERNAME |
Username for Discord bot | Truth Social Bot |
DISCORD_WEBHOOK_URL |
Discord webhook URL | (required if notify enabled) |
MONGO_DB |
MongoDB database name | truthsocial |
MONGO_COLLECTION |
MongoDB collection name | posts |
TRUTH_INSTANCE |
Truth Social instance domain | truthsocial.com |
POST_TYPE |
Type of posts to monitor | post |
REQUEST_TIMEOUT |
HTTP request timeout (seconds) | 30 |
MAX_RETRIES |
Max HTTP request retries | 3 |
FLARESOLVERR_ADDRESS |
Flaresolverr server address | localhost |
FLARESOLVERR_PORT |
Flaresolverr server port | 8191 |
LOG_LEVEL=INFO
APPNAME="Truth Social Monitor"
ENV=DEV
REPEAT_DELAY=300
DISCORD_NOTIFY=true
DISCORD_USERNAME="Truth Social Bot"
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
MONGO_DBSTRING=mongodb+srv://user:pass@host/db
MONGO_DB=truthsocial
MONGO_COLLECTION=posts
TRUTH_USERNAME=realDonaldTrump
TRUTH_INSTANCE=truthsocial.com
POST_TYPE=post
REQUEST_TIMEOUT=30
MAX_RETRIES=3
FLARESOLVERR_ADDRESS=localhost
FLARESOLVERR_PORT=8191- If
DISCORD_NOTIFYistrue,DISCORD_WEBHOOK_URLmust be set. TRUTH_USERNAMEandMONGO_DBSTRINGare always required.
For more details, see the config.py file.
The application includes comprehensive error handling:
- Automatic retries for network failures
- Rate limiting for Discord notifications
- Validation of configuration settings
- Detailed logging of errors and operations
- Safe storage of processed posts
Feel free to submit issues and pull requests.
MIT License