generated from nhcarrigan/template
ec58c9c843
CI / dependency-pin-check-typescript (push) Successful in 5s
CI / dependency-pin-check-python (push) Successful in 4s
CI / python (push) Successful in 9m28s
CI / typescript (push) Successful in 9m42s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m39s
## Summary This PR completes the bash script restructuring and adds comprehensive documentation across all script categories. ### Bash Restructuring - Moved cohort shell scripts (`remove_github_members.sh`, `update_github_teams.sh`) from `python/cohort/` into a new `bash/cohort/` directory - Moved existing bash utilities (`add-keys-to-git.sh`, `fix-yubikey-perms.sh`, `list-yubikey-ssh-keys.sh`) into a new `bash/yubikey/` subdirectory - Updated `run.sh` to support **Bash** as a third language option alongside TypeScript and Python - Bash scripts are run directly (no 1Password secret injection needed) - Category discovery and script listing works the same as for TS/Python - Removed dead "Root Scripts" logic that was no longer needed ### Documentation Added `README.md` files for all script categories that were missing them: - `bash/cohort/README.md` — cohort GitHub team management scripts - `bash/yubikey/README.md` — YubiKey SSH key and permission utilities - `typescript/src/crowdin/README.md` — Crowdin translation management scripts - `typescript/src/discord/README.md` — Discord bot utility scripts - `typescript/src/discourse/README.md` — Discourse forum management scripts - `typescript/src/gitea/README.md` — Gitea bulk repository operation scripts - `typescript/src/github/README.md` — GitHub API interaction scripts - `typescript/src/music/README.md` — Music file metadata tools - `typescript/src/s3/README.md` — S3-compatible object storage scripts - `typescript/src/security/README.md` — Security analysis and reporting scripts - `python/cohort/README.md` — Updated to remove moved shell scripts, fix usage commands Also updated project-level docs: - **`README.md`** — Corrected project structure, fixed running instructions (removed references to non-existent `make run-ts`/`make run-py` targets), added Bash prerequisites - **`CLAUDE.md`** — Updated project overview, structure, development standards, and script-adding guides to reflect the current state of the project ✨ This PR was created with help from Hikari~ 🌸 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Reviewed-on: #6 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
105 lines
3.6 KiB
Python
105 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Send a capacity check-in message to each team channel.
|
|
|
|
Posts a message asking whether the team feels able to complete their project
|
|
given their current member count, and invites them to request support if needed.
|
|
|
|
Data files (place in data/):
|
|
- team_message_ids.json Channel and role IDs per team (from send_team_messages.py)
|
|
- team_assignments.json Team rosters used to report current member counts
|
|
|
|
Env vars:
|
|
- DISCORD_BOT_TOKEN Bot token for the Discord API
|
|
"""
|
|
|
|
import asyncio
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import aiohttp
|
|
|
|
DATA_DIR = Path(__file__).parent.parent.parent / "data"
|
|
|
|
DISCORD_BOT_TOKEN = os.environ["DISCORD_BOT_TOKEN"]
|
|
NAOMI_ID = "465650873650118659"
|
|
|
|
|
|
def build_checkin_message(team_name: str, team: dict, role_id: str) -> str:
|
|
"""Build the team check-in message."""
|
|
total_members = len(team["leaders"]) + len(team["participants"])
|
|
num_leaders = len(team["leaders"])
|
|
num_participants = len(team["participants"])
|
|
|
|
leader_text = "leader" if num_leaders == 1 else "leaders"
|
|
participant_text = "participant" if num_participants == 1 else "participants"
|
|
|
|
return f"""## Team Check-In
|
|
|
|
Your team currently has **{total_members} members** ({num_leaders} {leader_text} + {num_participants} {participant_text}).
|
|
|
|
Given the recent changes to team size, we want to make sure you feel confident moving forward with your project. Please discuss as a team and let us know:
|
|
|
|
**Do you feel you can still complete your project with your current team size?**
|
|
|
|
If you have concerns about capacity, need additional support, or would like to discuss options (such as combining with another team or adjusting project scope), please ping <@{NAOMI_ID}> and we'll work together to find a solution.
|
|
|
|
Your success is the priority here - we want to make sure every team has what they need to build something amazing! 💜
|
|
|
|
-# <@&{role_id}>"""
|
|
|
|
|
|
async def send_message(
|
|
session: aiohttp.ClientSession, channel_id: str, content: str
|
|
) -> dict | None:
|
|
"""Send a message to a Discord channel."""
|
|
url = f"https://discord.com/api/v10/channels/{channel_id}/messages"
|
|
headers = {
|
|
"Authorization": f"Bot {DISCORD_BOT_TOKEN}",
|
|
"Content-Type": "application/json",
|
|
}
|
|
payload = {"content": content}
|
|
|
|
async with session.post(url, headers=headers, json=payload) as resp:
|
|
if resp.status in [200, 201]:
|
|
return await resp.json()
|
|
error_text = await resp.text()
|
|
print(
|
|
f"❌ Failed to send message to channel {channel_id}: {resp.status} - {error_text}" # noqa: E501
|
|
)
|
|
return None
|
|
|
|
|
|
async def main() -> None:
|
|
"""Send check-in messages to all teams."""
|
|
with open(DATA_DIR / "team_message_ids.json") as f:
|
|
team_data = json.load(f)
|
|
|
|
with open(DATA_DIR / "team_assignments.json") as f:
|
|
teams = json.load(f)
|
|
|
|
async with aiohttp.ClientSession() as session:
|
|
print("📢 Sending team check-in messages...\n")
|
|
|
|
for team in teams:
|
|
team_name = team["name"]
|
|
channel_id = team_data[team_name]["channel_id"]
|
|
role_id = team_data[team_name]["role_id"]
|
|
|
|
print(f"Processing {team_name}...")
|
|
|
|
checkin_msg = build_checkin_message(team_name, team, role_id)
|
|
result = await send_message(session, channel_id, checkin_msg)
|
|
|
|
if result:
|
|
total = len(team["leaders"]) + len(team["participants"])
|
|
print(f" ✅ Sent check-in ({total} members)")
|
|
|
|
await asyncio.sleep(2)
|
|
|
|
print("\n✨ Done sending all team check-in messages!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|