blacklist DSPL 💔 (#1293)

This commit is contained in:
NotSoToothless
2026-06-01 13:16:43 -07:00
committed by GitHub
parent cb0a18f748
commit 38726d6340
3 changed files with 17 additions and 15 deletions
+4 -2
View File
@@ -42,7 +42,7 @@ from .utils import (
replay_session_dir, replay_session_dir,
SQ_BATTLES_DB_PATH, SQ_BATTLES_DB_PATH,
SQUADRONS_DB_PATH, SQUADRONS_DB_PATH,
BLACKLISTED_SERVER_IDS, blacklisted_guilds,
DEFAULT_FOOTER_CAT, DEFAULT_FOOTER_CAT,
compress_json, compress_json,
decompress_json, decompress_json,
@@ -768,6 +768,8 @@ async def prune_invalid_channels(bot, mapping: dict[str, tuple[dict, list[tuple]
pruning so the dispatch step can decide between a real scoreboard and an pruning so the dispatch step can decide between a real scoreboard and an
over-cap/wildcard-blocked warning. over-cap/wildcard-blocked warning.
""" """
blacklist = blacklisted_guilds()
for sid in list(mapping): for sid in list(mapping):
game, targets = mapping[sid] game, targets = mapping[sid]
valid_targets: list[tuple] = [] valid_targets: list[tuple] = []
@@ -787,7 +789,7 @@ async def prune_invalid_channels(bot, mapping: dict[str, tuple[dict, list[tuple]
continue continue
# Drop any target from a blacklisted server # Drop any target from a blacklisted server
if guild.id in BLACKLISTED_SERVER_IDS: if guild.id in blacklist:
continue continue
# Check channel exists in Discord # Check channel exists in Discord
+3 -2
View File
@@ -32,7 +32,7 @@ from .utils import (
STORAGE_DIR, STORAGE_DIR,
SQUADRONS_DB_PATH, SQUADRONS_DB_PATH,
SQ_BATTLES_DB_PATH, SQ_BATTLES_DB_PATH,
BLACKLISTED_SERVER_IDS, blacklisted_guilds,
DEFAULT_FOOTER_CAT, DEFAULT_FOOTER_CAT,
compress_json, compress_json,
discord_len, discord_len,
@@ -1034,11 +1034,12 @@ async def execute_points_alarm_task(region: str):
# Step 1: Collect squadron -> [(guild_id, channel_str, flag)] mappings # Step 1: Collect squadron -> [(guild_id, channel_str, flag)] mappings
# flag: "ok" (dispatch normal) | "over_cap" (send orange upgrade warning) # flag: "ok" (dispatch normal) | "over_cap" (send orange upgrade warning)
squadron_channels: dict[str, list[tuple[int, str, str, str]]] = {} squadron_channels: dict[str, list[tuple[int, str, str, str]]] = {}
blacklist = blacklisted_guilds()
for guild in bot.guilds: for guild in bot.guilds:
guild_id = guild.id guild_id = guild.id
if guild_id in BLACKLISTED_SERVER_IDS: if guild_id in blacklist:
continue continue
prefs_path = PREFS_DIR / f"{guild_id}-preferences.json" prefs_path = PREFS_DIR / f"{guild_id}-preferences.json"
+10 -11
View File
@@ -34,7 +34,7 @@ from wcwidth import wcswidth
# BOT/__init__.py has already put BOTS/SHARED on sys.path; re-export it # BOT/__init__.py has already put BOTS/SHARED on sys.path; re-export it
# under a public name so peer modules can use it for asset paths. # under a public name so peer modules can use it for asset paths.
from . import SHARED_DIR # noqa: F401 — re-exported for siblings from . import SHARED_DIR # noqa: F401 — re-exported for siblings
from shared_store import check_user_blacklist from shared_store import check_user_blacklist, blacklisted_guilds
from data_parser import ( from data_parser import (
LangTableReader, LangTableReader,
UnitTags, UnitTags,
@@ -127,12 +127,10 @@ def decompress_json(data):
# BLACKLISTS # BLACKLISTS
# ============================================================================ # ============================================================================
BLACKLISTED_SERVER_IDS = [ # Blacklisted users, squadrons, and guilds now live in the shared,
] # version-controlled BOTS/SHARED/BLACKLIST.json (read via shared_store) so both
# bots share one source of truth. Use check_user_blacklist() /
# Blacklisted users and squadrons now live in the shared, version-controlled # shared_store.blacklisted_squadrons() / shared_store.blacklisted_guilds().
# BOTS/SHARED/BLACKLIST.json (read via shared_store) so both bots share one
# source of truth. Use check_user_blacklist() / shared_store.blacklisted_squadrons().
# ── Premium / Entitlements ──────────────────────────────────────────────────── # ── Premium / Entitlements ────────────────────────────────────────────────────
PREMIUM_ACTIVATION_TS: int = 1775459700 # Unix timestamp when premium gating activates PREMIUM_ACTIVATION_TS: int = 1775459700 # Unix timestamp when premium gating activates
@@ -527,9 +525,10 @@ async def is_dev_team(interaction: discord.Interaction) -> bool:
def is_blacklisted(): def is_blacklisted():
"""Return an app-command check that rejects blacklisted users or guilds. """Return an app-command check that rejects blacklisted users or guilds.
Blacklisted users come from the shared BLACKLIST.json (see Both blacklisted users and blacklisted guilds come from the shared
``shared_store.check_user_blacklist``); entries there may include an BLACKLIST.json (see ``shared_store.check_user_blacklist`` and
internal comment/name and an optional reason. ``shared_store.blacklisted_guilds``); entries there may include an internal
comment/name and an optional reason.
Raises: Raises:
BlacklistCheckFailure: If the guild or user is blacklisted, BlacklistCheckFailure: If the guild or user is blacklisted,
@@ -537,7 +536,7 @@ def is_blacklisted():
""" """
async def predicate(interaction: discord.Interaction): async def predicate(interaction: discord.Interaction):
guild = interaction.guild guild = interaction.guild
if guild is not None and guild.id in BLACKLISTED_SERVER_IDS: if guild is not None and guild.id in blacklisted_guilds():
raise BlacklistCheckFailure(t("en", "common.access_denied_desc")) raise BlacklistCheckFailure(t("en", "common.access_denied_desc"))
blocked, reason = check_user_blacklist(interaction.user.id) blocked, reason = check_user_blacklist(interaction.user.id)