fix: start with zero servers when config is missing or corrupt
Removed _create_default_config() which hardcoded a specific guild ID (759889672804630530) as a fallback. Now: - Missing servers_config.json → starts with empty servers dict - Corrupt JSON → logs error, starts with empty servers dict - Servers are added via the API/dashboard, not by magic defaults All code that iterates server_manager.servers handles empty dicts safely.
This commit is contained in:
@@ -94,9 +94,9 @@ class ServerManager:
|
||||
self.repair_config()
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to load server config: {e}")
|
||||
self._create_default_config()
|
||||
logger.info("Starting with zero servers — add servers via the API or dashboard")
|
||||
else:
|
||||
self._create_default_config()
|
||||
logger.info("No servers_config.json found — starting with zero servers")
|
||||
|
||||
def repair_config(self):
|
||||
"""Repair corrupted configuration data and save it back"""
|
||||
@@ -122,22 +122,6 @@ class ServerManager:
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to repair config: {e}")
|
||||
|
||||
def _create_default_config(self):
|
||||
"""Create default configuration for backward compatibility"""
|
||||
default_server = ServerConfig(
|
||||
guild_id=759889672804630530,
|
||||
guild_name="Default Server",
|
||||
autonomous_channel_id=761014220707332107,
|
||||
autonomous_channel_name="miku-chat",
|
||||
bedtime_channel_ids=[761014220707332107],
|
||||
enabled_features={"autonomous", "bedtime", "monday_video"},
|
||||
autonomous_interval_minutes=10,
|
||||
conversation_detection_interval_minutes=3
|
||||
)
|
||||
self.servers[default_server.guild_id] = default_server
|
||||
self.save_config()
|
||||
logger.info("Created default server configuration")
|
||||
|
||||
def save_config(self):
|
||||
"""Save server configurations to file"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user