A multi-platform posting system that automatically collects activities from Matrix, GitHub, and Mwmbl stats API, then posts daily updates to Mastodon and X, and weekly summaries to a GitHub Pages blog.
-
Data Collection: Automatically collects activities from:
- Matrix room messages (#mwmbl:matrix.org)
- GitHub repositories (mwmbl organization)
- Mwmbl statistics API
-
Content Processing:
- Filters newsworthy activities
- Formats content for different platforms
- Uses Claude AI for weekly summaries
-
Multi-Platform Publishing:
- Daily posts to Mastodon and X/Twitter
- Weekly blog posts to GitHub Pages
- Platform-specific formatting and character limits
-
Robust Architecture:
- PostgreSQL database for activity tracking
- Comprehensive error handling and logging
- Duplicate detection and rate limiting
- Docker deployment ready
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Data Sources │ │ Processors │ │ Publishers │
├─────────────────┤ ├──────────────────┤ ├─────────────────┤
│ Matrix Collector│───▶│ Content Filter │───▶│ Mastodon │
│ GitHub Collector│ │ Content Formatter│ │ X/Twitter │
│ Stats Collector │ │ AI Summarizer │ │ Blog (GitHub) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
└───────────────────────┼───────────────────────┘
▼
┌─────────────────────────┐
│ PostgreSQL Database │
│ - Activities │
│ - Posts │
│ - Scheduling │
└─────────────────────────┘
- Python 3.13+
- PostgreSQL database
- API credentials for all platforms
- Clone the repository:
git clone <repository-url>
cd post
- Install dependencies:
pip install -e .
- Copy and configure environment variables:
cp config/.env.example .env
# Edit .env with your API credentials
- Initialize the database:
python main.py init-db
- Test connections:
python main.py test-connections
Copy config/.env.example
to .env
and configure:
DATABASE_URL=postgresql://user:password@localhost:5432/post_db
MATRIX_HOMESERVER=https://matrix.org
MATRIX_USER_ID=@your_username:matrix.org
MATRIX_ACCESS_TOKEN=your_matrix_access_token
MATRIX_ROOM_ID=!mwmbl:matrix.org
GITHUB_TOKEN=your_github_personal_access_token
GITHUB_ORG=mwmbl
MASTODON_INSTANCE_URL=https://your.mastodon.instance
MASTODON_ACCESS_TOKEN=your_mastodon_access_token
X_API_KEY=your_x_api_key
X_API_SECRET=your_x_api_secret
X_ACCESS_TOKEN=your_x_access_token
X_ACCESS_TOKEN_SECRET=your_x_access_token_secret
X_BEARER_TOKEN=your_x_bearer_token
ANTHROPIC_API_KEY=your_anthropic_api_key
- Create a Matrix account
- Get access token from Element → Settings → Help & About → Advanced
- Go to GitHub Settings → Developer settings → Personal access tokens
- Create token with
repo
andread:org
permissions
- Go to your Mastodon instance → Preferences → Development
- Create new application with
read
andwrite
permissions
- Apply for Twitter Developer account
- Create app and get API keys and tokens
- Sign up at https://console.anthropic.com/
- Get API key from the dashboard
# Initialize database
python main.py init-db
# Test all connections
python main.py test-connections
# Collect activities (last 24 hours)
python main.py collect
# Run daily posting
python main.py daily-post
# Run weekly posting
python main.py weekly-post
# View statistics
python main.py stats --days 7
# Clean up temporary files
python main.py cleanup
For production deployment, use the provided scripts:
python scripts/daily_post.py
python scripts/weekly_post.py
# Build image
docker build -t mwmbl-post .
# Run with environment file
docker run --env-file .env mwmbl-post python main.py daily-post
- Create Dokku app:
dokku apps:create mwmbl-post
- Set environment variables:
dokku config:set mwmbl-post DATABASE_URL=postgresql://...
# Set all other environment variables
- Deploy:
git remote add dokku dokku@your-server:mwmbl-post
git push dokku main
- Set up cron jobs:
# Daily posting at 9 AM
dokku cron:set mwmbl-post "0 9 * * *" "python scripts/daily_post.py"
# Weekly posting on Mondays at 10 AM
dokku cron:set mwmbl-post "0 10 * * 1" "python scripts/weekly_post.py"
post/
├── src/
│ ├── collectors/ # Data collection from sources
│ ├── processors/ # Content filtering and formatting
│ ├── publishers/ # Platform publishing
│ ├── scheduler/ # Task orchestration
│ └── storage/ # Database models and management
├── config/ # Configuration and settings
├── scripts/ # Deployment scripts
├── main.py # CLI interface
├── Dockerfile # Docker configuration
└── README.md # This file
- Create new collector in
src/collectors/
- Inherit from
BaseCollector
- Implement
collect()
method - Add to
TaskScheduler
- Create new publisher in
src/publishers/
- Inherit from
BasePublisher
- Implement required methods
- Add to
TaskScheduler
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=src
# Format code
black src/ config/ scripts/ main.py
# Sort imports
isort src/ config/ scripts/ main.py
# Type checking
mypy src/
- Logs are written to both console and file (
post.log
) - Log rotation: 10MB files, 30 days retention
- Health checks available for Docker deployment
- Statistics tracking for all posting activities
-
Database Connection Failed
- Check PostgreSQL is running
- Verify DATABASE_URL is correct
- Ensure database exists
-
API Authentication Errors
- Verify all API credentials are correct
- Check token permissions and expiry
- Test individual connections
-
Matrix Connection Issues
- Ensure Matrix room ID is correct
- Check access token has room permissions
- Verify homeserver URL
-
Blog Publishing Fails
- Check GitHub repository permissions
- Verify blog repository URL
- Ensure Git credentials are configured
Run with verbose logging:
python main.py -v <command>
- Check logs in
post.log
- Run connection tests:
python main.py test-connections
- View recent statistics:
python main.py stats
[Add your license here]
[Add contribution guidelines here]