This is a Discord bot that monitors the Daily Twisted Board from the Dandy's World wiki and sends notifications to Discord channels when the twisted character changes. The bot scrapes the wiki page every 30 minutes and alerts users when a new twisted character is available.
The bot follows a modular, event-driven architecture:
- Main Bot Module (
bot.py): Core Discord bot logic using discord.py library - Configuration Management (
config.py): Environment-based configuration with validation - Web Scraping (
scraper.py): Asynchronous wiki page scraping using aiohttp and BeautifulSoup - Utilities (
utils.py): Logging setup and helper functions for text processing
The architecture prioritizes:
- Asynchronous operations for non-blocking Discord interactions
- Modular design for easy maintenance and testing
- Robust error handling and logging
- Environment variable configuration for security
- Extends
discord.ext.commands.Bot - Implements periodic monitoring via Discord.py tasks
- Handles Discord events (on_ready, setup_hook)
- Manages state tracking for twisted character changes
- Validates required environment variables
- Handles Discord channel and user ID parsing
- Provides centralized configuration access
- Implements graceful degradation for missing optional configs
- Asynchronous HTTP client using aiohttp
- Session management with proper cleanup
- HTML parsing with BeautifulSoup
- Timeout and error handling for network requests
- Centralized logging configuration with file and console output
- Text processing functions for wiki content
- Discord ID validation utilities
- Bot Initialization: Load configuration, create scraper instance, set up Discord connection
- Initial State: Fetch current twisted character on startup
- Periodic Monitoring: Every 30 minutes, scrape wiki page for updates
- Change Detection: Compare new twisted character with previous state
- Notification: Send Discord message with pings when change detected
- State Update: Store new twisted character as current state
discord.py: Discord API interaction and bot frameworkaiohttp: Asynchronous HTTP client for web scrapingbeautifulsoup4: HTML parsing for wiki content extractionasyncio: Asynchronous programming support
- Discord API: Bot authentication, message sending, channel management
- Dandy's World Wiki: Source of Daily Twisted Board data via web scraping
DISCORD_BOT_TOKEN(required): Bot authentication tokenDISCORD_CHANNEL_ID(optional): Target channel for notificationsPING_ROLE_ID(optional): Role to ping on updatesPING_USER_IDS(optional): Comma-separated user IDs to pingLOG_LEVEL(optional): Logging verbosity level
The application is designed for containerized deployment:
- Python 3.8+ runtime environment
- Environment variables for configuration
- Persistent logging directory (
logs/)
- Single-instance deployment (state stored in memory)
- Stateless design allows for easy restarts
- Configurable monitoring intervals
- Session management prevents resource leaks
- File-based logging with daily rotation
- Structured log format for debugging
- Health checks via Discord connection status
- Error handling prevents bot crashes
Preferred communication style: Simple, everyday language. Daily Twisted Board updates at 8PM EST: Bot should continue checking but only announce when there's an actual change or when the timer resets with the same twisted (indicating a new daily cycle). Monitor timer information: Bot should parse timer data from the wiki to detect when the board resets. Smart notifications: Always check the board, but only send Discord announcements when there's a meaningful change - either a new twisted character or a timer reset with the same character.