A powerful bridge system that synchronizes messages between Telegram and Discord with a RESTful API.
- π Bidirectional Message Sync: Messages flow seamlessly between Telegram and Discord
- π Secure API: Token-based authentication with admin management
- π Message History: MongoDB-powered message storage and retrieval
- π¬ Reply Threading: Maintains reply context across platforms
- π REST API: Full-featured API for external integrations
- ποΈ Admin Dashboard: Web interface for token management
βββ main.py # Application entry point
βββ src/
β βββ api/ # FastAPI REST endpoints
β β βββ server.py # Main API routes
β β βββ admin_routes.py # Admin & token management
β βββ auth/ # Authentication system
β β βββ auth_manager.py # Token & admin management
β βββ bot/ # Bot implementations
β β βββ tg_bot.py # Telegram bot
β β βββ dc_bot.py # Discord bot
β βββ core/ # Core functionality
β β βββ forward.py # Main application logic
β β βββ models.py # Pydantic models
β βββ database/ # Database layer
β β βββ database.py # MongoDB connection
β β βββ store_functions.py # Data operations
β βββ utils/ # Utilities
β βββ bridge.py # Message forwarding
β βββ misc.py # Helper functions
βββ test_api.py # Comprehensive test suite
pip install -r requirements.txtCreate a .env file with:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
TELEGRAM_CHAT_ID=your_telegram_chat_id
DISCORD_BOT_TOKEN=your_discord_bot_token
DISCORD_CHANNEL_ID=your_discord_channel_id
MONGO_URI=your_mongodb_connection_string
MONGO_DB=your_database_name
API_HOST=0.0.0.0
API_PORT=8000python main.pyThe test_api.py script provides comprehensive testing capabilities.
python test_api.py systemVerifies:
- β Health endpoint
- β Admin status
- β Bot connectivity
- β Database connection
- β API protection
First time setup - register admin account:
python test_api.py setupTest admin login and token creation:
python test_api.py auth <username> <password>This will:
- Login as admin
- Create an API token
- Test API with the token
- Test token revocation
- Verify revoked token is rejected
Quick Test - Fast API status check:
python test_api.py quickMessage Test - Test message sending:
python test_api.py messageToken Test - Test with existing token:
python test_api.py token <your_api_token>Full Test - Comprehensive test suite:
python test_api.py fullpython test_api.py helpGET /- Landing pageGET /health- System health checkGET /admin- Admin login pageGET /admin/status- Check if admin existsPOST /admin/register- Register admin (first time only)POST /admin/login- Admin login
GET /messages- List messagesGET /messages/{id}- Get specific messagePOST /messages- Send new messagePOST /messages/{id}/reply- Reply to message
GET /admin/tokens- List API tokensPOST /admin/tokens- Create new API tokenPATCH /admin/tokens/{name}/revoke- Revoke tokenDELETE /admin/tokens/{name}- Delete tokenPOST /admin/logout- Logout
curl -H "X-API-Token: your_token" http://localhost:8000/messages?limit=10curl -X POST -H "X-API-Token: your_token" \
-H "Content-Type: application/json" \
-d '{"username":"API","text":"Hello from API!"}' \
http://localhost:8000/messagescurl -X POST -H "X-API-Token: your_token" \
-H "Content-Type: application/json" \
-d '{"username":"API","text":"This is a reply"}' \
http://localhost:8000/messages/{message_id}/reply{
"status": "healthy",
"version": "4.0.0",
"runtime": {
"telegram_bot": true,
"discord_bot": true,
"api_configured": true,
"message_mapping": true
},
"services": {
"database": "connected",
"telegram": "running",
"discord": "running"
}
}python main.pydocker build -t bindsync .
docker run -d --env-file .env -p 8000:8000 bindsync- API tokens are required for all message operations
- Admin sessions are managed separately from API tokens
- Tokens can have expiration dates
- Tokens can be revoked at any time
- All authentication uses secure token generation
Check the health endpoint to verify bot status:
curl http://localhost:8000/health- Check if admin exists:
python test_api.py system - Register admin:
python test_api.py setup - Test authentication:
python test_api.py auth <user> <pass>
Verify MongoDB connection in the health check response.
MIT License
4.0.0