major-domo-v2/commands/admin/__init__.py
Cal Corum 62c658fb57 CLAUDE: Add automated weekly transaction freeze/thaw system
Implements comprehensive automated system for weekly transaction freeze periods
with priority-based contested player resolution.

New Features:
- Weekly freeze/thaw task (Monday 00:00 freeze, Saturday 00:00 thaw)
- Priority resolution for contested transactions (worst teams get first priority)
- Admin league management commands (/freeze-begin, /freeze-end, /advance-week)
- Enhanced API client to handle string-based transaction IDs (moveids)
- Service layer methods for transaction cancellation, unfreezing, and bulk operations
- Offseason mode configuration flag to disable freeze operations

Technical Changes:
- api/client.py: URL-encode object_id parameter to handle colons in moveids
- bot.py: Initialize and shutdown transaction freeze task
- config.py: Add offseason_flag to BotConfig
- services/league_service.py: Add update_current_state() for week/freeze updates
- services/transaction_service.py: Add cancel/unfreeze methods with bulk support
- tasks/transaction_freeze.py: Main freeze/thaw automation with error recovery
- commands/admin/league_management.py: Manual admin controls for freeze system

Infrastructure:
- .gitlab-ci.yml and .gitlab/: GitLab CI/CD pipeline configuration
- .mcp.json: MCP server configuration
- Dockerfile.versioned: Versioned Docker build support
- .dockerignore: Added .gitlab/ to ignore list

Testing:
- tests/test_tasks_transaction_freeze.py: Comprehensive freeze task tests

The system uses team standings to fairly resolve contested players (multiple teams
trying to acquire the same player), with worst-record teams getting priority.
Includes comprehensive error handling, GM notifications, and admin reporting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-20 12:16:13 -05:00

54 lines
1.7 KiB
Python

"""
Admin command package for Discord Bot v2.0
Contains administrative commands for league management.
"""
import logging
from typing import List, Tuple, Type
import discord
from discord.ext import commands
from .management import AdminCommands
from .users import UserManagementCommands
from .league_management import LeagueManagementCommands
logger = logging.getLogger(f'{__name__}.setup_admin')
async def setup_admin(bot: commands.Bot) -> Tuple[int, int, List[str]]:
"""
Set up admin command modules.
Returns:
Tuple of (successful_loads, failed_loads, failed_modules)
"""
admin_cogs: List[Tuple[str, Type[commands.Cog]]] = [
("AdminCommands", AdminCommands),
("UserManagementCommands", UserManagementCommands),
("LeagueManagementCommands", LeagueManagementCommands),
]
successful = 0
failed = 0
failed_modules = []
for cog_name, cog_class in admin_cogs:
try:
await bot.add_cog(cog_class(bot))
logger.info(f"✅ Loaded admin command module: {cog_name}")
successful += 1
except Exception as e:
logger.error(f"❌ Failed to load admin command module {cog_name}: {e}")
failed += 1
failed_modules.append(cog_name)
# Log summary
if failed == 0:
logger.info(f"🎉 All {successful} admin command modules loaded successfully")
else:
logger.warning(f"⚠️ Admin commands loaded with issues: {successful} successful, {failed} failed")
if failed_modules:
logger.warning(f"Failed modules: {', '.join(failed_modules)}")
return successful, failed, failed_modules