A bot that monitors Indonesian news sites and sends filtered articles to your Discord channels based on customizable keywords.
- Multi-source monitoring: CNN Indonesia, Detik.com, Kompas.com, BBC Indonesia
- Smart keyword filtering: Supports both single words and multi-word phrases with whole-word matching
- Rich Discord integration: Beautiful embeds with article images, descriptions, and highlighted keywords
- Visual content: Automatically fetches and displays article images from OpenGraph meta tags
- Article previews: Extracts first 1-2 sentences for better content insight
- Real-time monitoring: Only new articles (no historical spam)
- Fast & efficient: Built with Bun.js for optimal performance
- Robust: Handles rate limiting and errors gracefully with automatic recovery
- Smart deduplication: SQLite database prevents duplicate notifications
- Production-ready: Optimized for Railway deployment with health checks and monitoring
- Bun.js installed on your system
- Discord webhook URL
- Node.js 18+ (for SQLite compatibility)
-
Clone and install dependencies:
git clone https://github.com/itujono/pemerintah-bot cd pemerintah-bot bun install -
Run the interactive setup:
bun run setup
The setup wizard will:
- Guide you through deployment target selection (Local/Railway/Cloud)
- Configure Discord webhook
- Set up keywords with smart defaults
- Optimize settings for your deployment environment
- Generate deployment-specific configurations
-
Start the bot:
# Development mode (with auto-reload) bun run dev # Production mode bun start
If you prefer to configure manually:
-
Copy the example environment file:
cp env.example .env
-
Edit
.envwith your settings:- Set your Discord webhook URL
- Configure your keywords
- Adjust monitoring settings
Required:
DISCORD_WEBHOOK_URL: Your Discord webhook URL
Optional (with smart defaults):
KEYWORDS: Comma-separated keywords (default: comprehensive Indonesian political keywords)CHECK_INTERVAL_MINUTES: Monitoring frequency (default: 5 local, 20 Railway)MAX_ARTICLES_PER_CHECK: Articles per cycle (default: 10)LOG_LEVEL: Logging level (default: debug local, info production)DATABASE_PATH: SQLite database location (default: ./data/news.db)
- CNN Indonesia: RSS feed + metadata extraction
- Detik.com: RSS feed + metadata extraction
- BBC Indonesia: RSS feed + metadata extraction
- Kompas.com: RSS feed + metadata extraction
- RSS Monitoring: Efficiently fetches latest articles via RSS feeds
- Smart Filtering: Matches articles against your keywords using intelligent whole-word matching
- Metadata Enhancement: Extracts OpenGraph images and article descriptions
- Duplicate Prevention: SQLite database tracks processed articles
- Rich Notifications: Sends beautifully formatted Discord embeds
- Error Recovery: Automatic database recovery and graceful error handling
Railway deployment is fully optimized with:
- Enhanced resource allocation: 1Gi memory, 1 CPU core
- Automatic health checks: Built-in monitoring endpoints
- Database optimizations: SQLite configured for Railway's filesystem
- Error recovery: Automatic restart on failures
- Performance tuning: Memory and CPU optimizations
Quick Deploy:
-
Run setup with Railway target:
bun run setup # Choose option 2 (Railway) for optimal configuration -
Deploy to Railway:
# Install Railway CLI npm install -g @railway/cli # Login and deploy railway login railway up
-
Set environment variables in Railway dashboard:
DISCORD_WEBHOOK_URL: Your Discord webhook URL- Other variables are automatically configured by setup
For detailed Railway deployment instructions, see RAILWAY_DEPLOYMENT.md
Your deployed bot includes comprehensive monitoring:
- Status Endpoint:
https://your-app.railway.app/- Basic health status - Health Endpoint:
https://your-app.railway.app/health- Detailed system info - Debug Endpoint:
https://your-app.railway.app/debug- Recent articles and config
The bot works on any Node.js/Bun-compatible platform:
- Render: Set build command to
bun installand start command tobun start - Heroku: Add
bunbuildpack - DigitalOcean App Platform: Use Node.js environment
- VPS: Clone repo, run
bun install && bun start
├── src/
│ ├── index.ts # Main application entry
│ ├── config/
│ │ └── settings.ts # Configuration management
│ ├── scrapers/
│ │ ├── base.ts # Base scraper interface
│ │ ├── cnn-indonesia.ts # CNN Indonesia scraper
│ │ ├── detik.ts # Detik.com scraper
│ │ ├── kompas.ts # Kompas.com scraper
│ │ └── bbc-indonesia.ts # BBC Indonesia scraper
│ ├── services/
│ │ ├── database.ts # SQLite database service
│ │ ├── discord.ts # Discord webhook service
│ │ └── scheduler.ts # Cron job scheduler
│ └── utils/
│ ├── logger.ts # Logging utilities
│ └── keywords.ts # Keyword matching utilities
├── setup.ts # Interactive setup wizard
├── railway.toml # Railway deployment config
├── railway-start.sh # Railway startup script
├── RAILWAY_DEPLOYMENT.md # Detailed Railway guide
├── data/
│ └── news.db # SQLite database (auto-created)
└── logs/
└── app.log # Application logs
# Install dependencies
bun install
# Run in development mode
bun run dev
# Format code
bun run format
# Lint code
bun run lint
# Build for production
bun run build
# Run setup wizard
bun run setup- Bot stops working on Railway: Check health endpoints and Railway logs
- Database errors: The bot automatically recovers from SQLite corruption
- No articles found: Verify keywords and check debug endpoint
- Discord not receiving messages: Verify webhook URL and test connection
# Check bot status (when running)
curl https://your-app.railway.app/health
# View recent articles and config
curl https://your-app.railway.app/debug
# Railway logs
railway logs- Rate limiting: Respects source websites with intelligent delays
- Error recovery: Automatic database corruption recovery
- Resource optimization: Memory and CPU usage optimized for Railway
- Secure configuration: Environment variables for sensitive data
- Health monitoring: Built-in endpoints for deployment monitoring
MIT License - see LICENSE file for details