fix leave alarm (#1265)
This commit is contained in:
+10
-2
@@ -1138,6 +1138,8 @@ async def execute_leave_alarm_task():
|
|||||||
|
|
||||||
tier = await get_guild_tier(guild_id)
|
tier = await get_guild_tier(guild_id)
|
||||||
allowed_points = allowed_pref_keys_for(preferences, tier, "Points")
|
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():
|
for pref_key, squad_prefs in preferences.items():
|
||||||
if not isinstance(squad_prefs, dict):
|
if not isinstance(squad_prefs, dict):
|
||||||
@@ -1148,8 +1150,9 @@ async def execute_leave_alarm_task():
|
|||||||
points_chan = squad_prefs.get("Points")
|
points_chan = squad_prefs.get("Points")
|
||||||
if not leave_chan and not points_chan:
|
if not leave_chan and not points_chan:
|
||||||
continue
|
continue
|
||||||
# Respect the Points tier cap — identical gate used by execute_points_alarm_task.
|
# Respect the tier cap — squadrons must be within either the Points
|
||||||
if tier_enforcement_active() and pref_key not in allowed_points:
|
# or Leave cap to receive leave notifications.
|
||||||
|
if tier_enforcement_active() and pref_key not in allowed_for_leave:
|
||||||
continue
|
continue
|
||||||
resolved = await resolve_pref_key(pref_key, squad_prefs)
|
resolved = await resolve_pref_key(pref_key, squad_prefs)
|
||||||
target_name = resolved["long_name"] if resolved and resolved.get("long_name") else pref_key
|
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:
|
for guild_id, channel_id in guild_channels:
|
||||||
channel = bot.get_channel(channel_id)
|
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:
|
if not channel:
|
||||||
logging.error("(LEAVE) Channel %s not found in guild %s", channel_id, guild_id)
|
logging.error("(LEAVE) Channel %s not found in guild %s", channel_id, guild_id)
|
||||||
continue
|
continue
|
||||||
|
|||||||
+3
-3
@@ -157,9 +157,9 @@ TIER_ENFORCEMENT_TS: int = 1778107232
|
|||||||
Tier = Literal["standard", "pro", "max"]
|
Tier = Literal["standard", "pro", "max"]
|
||||||
|
|
||||||
TIER_NOTIF_CAPS: Dict[str, Dict[str, Optional[int]]] = {
|
TIER_NOTIF_CAPS: Dict[str, Dict[str, Optional[int]]] = {
|
||||||
"standard": {"Logs": 10, "Points": 10},
|
"standard": {"Logs": 10, "Points": 10, "Leave": 10},
|
||||||
"pro": {"Logs": 25, "Points": 25},
|
"pro": {"Logs": 25, "Points": 25, "Leave": 25},
|
||||||
"max": {"Logs": None, "Points": None},
|
"max": {"Logs": None, "Points": None, "Leave": None},
|
||||||
}
|
}
|
||||||
|
|
||||||
TIER_ALLOWS_WILDCARDS: Dict[str, bool] = {
|
TIER_ALLOWS_WILDCARDS: Dict[str, bool] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user