fix leave alarm (#1265)

This commit is contained in:
NotSoToothless
2026-05-21 23:22:10 -07:00
committed by GitHub
parent cd909bc858
commit 2d5adfcbe0
2 changed files with 13 additions and 5 deletions
+10 -2
View File
@@ -1138,6 +1138,8 @@ async def execute_leave_alarm_task():
tier = await get_guild_tier(guild_id)
allowed_points = allowed_pref_keys_for(preferences, tier, "Points")
allowed_leave = allowed_pref_keys_for(preferences, tier, "Leave")
allowed_for_leave = allowed_points | allowed_leave
for pref_key, squad_prefs in preferences.items():
if not isinstance(squad_prefs, dict):
@@ -1148,8 +1150,9 @@ async def execute_leave_alarm_task():
points_chan = squad_prefs.get("Points")
if not leave_chan and not points_chan:
continue
# Respect the Points tier cap — identical gate used by execute_points_alarm_task.
if tier_enforcement_active() and pref_key not in allowed_points:
# Respect the tier cap — squadrons must be within either the Points
# or Leave cap to receive leave notifications.
if tier_enforcement_active() and pref_key not in allowed_for_leave:
continue
resolved = await resolve_pref_key(pref_key, squad_prefs)
target_name = resolved["long_name"] if resolved and resolved.get("long_name") else pref_key
@@ -1232,6 +1235,11 @@ async def execute_leave_alarm_task():
for guild_id, channel_id in guild_channels:
channel = bot.get_channel(channel_id)
if not channel:
try:
channel = await bot.fetch_channel(channel_id)
except (discord.NotFound, discord.Forbidden):
channel = None
if not channel:
logging.error("(LEAVE) Channel %s not found in guild %s", channel_id, guild_id)
continue
+3 -3
View File
@@ -157,9 +157,9 @@ TIER_ENFORCEMENT_TS: int = 1778107232
Tier = Literal["standard", "pro", "max"]
TIER_NOTIF_CAPS: Dict[str, Dict[str, Optional[int]]] = {
"standard": {"Logs": 10, "Points": 10},
"pro": {"Logs": 25, "Points": 25},
"max": {"Logs": None, "Points": None},
"standard": {"Logs": 10, "Points": 10, "Leave": 10},
"pro": {"Logs": 25, "Points": 25, "Leave": 25},
"max": {"Logs": None, "Points": None, "Leave": None},
}
TIER_ALLOWS_WILDCARDS: Dict[str, bool] = {