Skip to content

Commit f56f0cf

Browse files
Add files via upload
1 parent a29a8c1 commit f56f0cf

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

replit.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Dandy's World Discord Bot
2+
3+
## Overview
4+
5+
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.
6+
7+
## System Architecture
8+
9+
The bot follows a modular, event-driven architecture:
10+
11+
- **Main Bot Module (`bot.py`)**: Core Discord bot logic using discord.py library
12+
- **Configuration Management (`config.py`)**: Environment-based configuration with validation
13+
- **Web Scraping (`scraper.py`)**: Asynchronous wiki page scraping using aiohttp and BeautifulSoup
14+
- **Utilities (`utils.py`)**: Logging setup and helper functions for text processing
15+
16+
The architecture prioritizes:
17+
- Asynchronous operations for non-blocking Discord interactions
18+
- Modular design for easy maintenance and testing
19+
- Robust error handling and logging
20+
- Environment variable configuration for security
21+
22+
## Key Components
23+
24+
### Discord Bot (`DandyWorldBot`)
25+
- Extends `discord.ext.commands.Bot`
26+
- Implements periodic monitoring via Discord.py tasks
27+
- Handles Discord events (on_ready, setup_hook)
28+
- Manages state tracking for twisted character changes
29+
30+
### Configuration Manager (`Config`)
31+
- Validates required environment variables
32+
- Handles Discord channel and user ID parsing
33+
- Provides centralized configuration access
34+
- Implements graceful degradation for missing optional configs
35+
36+
### Web Scraper (`DailyTwistedScraper`)
37+
- Asynchronous HTTP client using aiohttp
38+
- Session management with proper cleanup
39+
- HTML parsing with BeautifulSoup
40+
- Timeout and error handling for network requests
41+
42+
### Utilities
43+
- Centralized logging configuration with file and console output
44+
- Text processing functions for wiki content
45+
- Discord ID validation utilities
46+
47+
## Data Flow
48+
49+
1. **Bot Initialization**: Load configuration, create scraper instance, set up Discord connection
50+
2. **Initial State**: Fetch current twisted character on startup
51+
3. **Periodic Monitoring**: Every 30 minutes, scrape wiki page for updates
52+
4. **Change Detection**: Compare new twisted character with previous state
53+
5. **Notification**: Send Discord message with pings when change detected
54+
6. **State Update**: Store new twisted character as current state
55+
56+
## External Dependencies
57+
58+
### Core Libraries
59+
- `discord.py`: Discord API interaction and bot framework
60+
- `aiohttp`: Asynchronous HTTP client for web scraping
61+
- `beautifulsoup4`: HTML parsing for wiki content extraction
62+
- `asyncio`: Asynchronous programming support
63+
64+
### External Services
65+
- **Discord API**: Bot authentication, message sending, channel management
66+
- **Dandy's World Wiki**: Source of Daily Twisted Board data via web scraping
67+
68+
### Environment Variables
69+
- `DISCORD_BOT_TOKEN` (required): Bot authentication token
70+
- `DISCORD_CHANNEL_ID` (optional): Target channel for notifications
71+
- `PING_ROLE_ID` (optional): Role to ping on updates
72+
- `PING_USER_IDS` (optional): Comma-separated user IDs to ping
73+
- `LOG_LEVEL` (optional): Logging verbosity level
74+
75+
## Deployment Strategy
76+
77+
The application is designed for containerized deployment:
78+
79+
### Environment Setup
80+
- Python 3.8+ runtime environment
81+
- Environment variables for configuration
82+
- Persistent logging directory (`logs/`)
83+
84+
### Scalability Considerations
85+
- Single-instance deployment (state stored in memory)
86+
- Stateless design allows for easy restarts
87+
- Configurable monitoring intervals
88+
- Session management prevents resource leaks
89+
90+
### Monitoring
91+
- File-based logging with daily rotation
92+
- Structured log format for debugging
93+
- Health checks via Discord connection status
94+
- Error handling prevents bot crashes
95+
96+
## Changelog
97+
- July 01, 2025. Initial setup
98+
- July 01, 2025. Removed duplicate announcement prevention - bot now announces every check regardless of whether the twisted character is the same as before
99+
- July 01, 2025. Added smart change detection - bot now only announces when twisted actually changes OR when timer resets with same twisted (indicating new daily cycle)
100+
- July 01, 2025. Added timer information parsing to detect when daily board resets
101+
- July 01, 2025. Updated announcement logic to be more intelligent about when to notify users
102+
- July 01, 2025. Added hardcoded environment variables for private deployment (DISCORD_CHANNEL_ID: 1381153101414924409, PING_ROLE_ID: 1381148457212841985)
103+
- July 01, 2025. Changed monitoring schedule from every 30 minutes to every hour on the exact hour, with time synchronization to eliminate delays
104+
- July 01, 2025. Added special 1-minute delay for 8 PM EST (midnight UTC) checks to account for board update timing
105+
- July 02, 2025. Added image attachment functionality - bot now extracts and displays Twisted character images from the wiki in Discord announcements
106+
107+
## User Preferences
108+
109+
Preferred communication style: Simple, everyday language.
110+
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).
111+
Monitor timer information: Bot should parse timer data from the wiki to detect when the board resets.
112+
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.

0 commit comments

Comments
 (0)