generated from nhcarrigan/template
docs: add data file documentation and fix data path resolution
All Python cohort scripts now use DATA_DIR = Path(__file__).parent.parent.parent / "data" to correctly resolve the repo-root data/ directory regardless of the working directory set by run.sh. All TypeScript scripts have expanded JSDoc headers documenting data file requirements and environment variables.
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Discord Team Activity Checker
|
||||
Checks for team members who haven't sent messages in their channels within 36 hours
|
||||
"""Check for team members who have not sent a message in their channel within 36 hours.
|
||||
|
||||
Scans each team's Discord channel and flags members with no recent activity.
|
||||
Optionally sends a direct mention message to inactive members.
|
||||
|
||||
Data files (place in data/):
|
||||
- team_assignments.json Team rosters with leaders and participants per team
|
||||
|
||||
Outputs (written to data/):
|
||||
- discord_activity_report.json Inactive members per team with last-seen timestamps
|
||||
|
||||
Env vars:
|
||||
- DISCORD_BOT_TOKEN Bot token for the Discord API
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
@@ -8,16 +19,19 @@ import json
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
|
||||
import aiohttp
|
||||
|
||||
DATA_DIR = Path(__file__).parent.parent.parent / "data"
|
||||
|
||||
# Configuration
|
||||
DISCORD_TOKEN = os.environ["DISCORD_BOT_TOKEN"]
|
||||
DISCORD_API_BASE = "https://discord.com/api/v10"
|
||||
INACTIVE_THRESHOLD_HOURS = 36
|
||||
|
||||
# Load team assignments from file
|
||||
with open("team_assignments.json") as f:
|
||||
with open(DATA_DIR / "team_assignments.json") as f:
|
||||
team_data = json.load(f)
|
||||
|
||||
# Build TEAMS dictionary with channel IDs and member lists
|
||||
@@ -233,7 +247,7 @@ async def main():
|
||||
print("\n" + "=" * 80)
|
||||
|
||||
# Save results to JSON
|
||||
with open("discord_activity_report.json", "w") as f:
|
||||
with open(DATA_DIR / "discord_activity_report.json", "w") as f:
|
||||
json.dump(
|
||||
{
|
||||
"generated_at": datetime.now(timezone.utc).isoformat(),
|
||||
|
||||
Reference in New Issue
Block a user