lets get this party starteddddd (#1287)
This commit is contained in:
+23
-28
@@ -34,6 +34,7 @@ from wcwidth import wcswidth
|
||||
# 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.
|
||||
from . import SHARED_DIR # noqa: F401 — re-exported for siblings
|
||||
from shared_store import check_user_blacklist
|
||||
from data_parser import (
|
||||
LangTableReader,
|
||||
UnitTags,
|
||||
@@ -129,23 +130,9 @@ def decompress_json(data):
|
||||
BLACKLISTED_SERVER_IDS = [
|
||||
]
|
||||
|
||||
BLACKLISTED_SQUADRONS = [
|
||||
"FIR3",
|
||||
"F4WRD",
|
||||
]
|
||||
|
||||
BLACKLISTED_USER_IDS = [
|
||||
635917136619110411, #wolfhunter4374
|
||||
498231384238850048, #liquidtaeja
|
||||
1166571862789193769, #astro
|
||||
872791644947234847, #nova
|
||||
591290628722393090, #rayan
|
||||
1129994258267512842, #squawk
|
||||
1417443909918916670, #maverickfighter9
|
||||
1034483237197713539, #HK416A6
|
||||
(601497771266277387, "Z supporter + racism"), #lowe/koniglion
|
||||
815535178122002463, #markboss
|
||||
]
|
||||
# Blacklisted users and squadrons 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() / shared_store.blacklisted_squadrons().
|
||||
|
||||
# ── Premium / Entitlements ────────────────────────────────────────────────────
|
||||
PREMIUM_ACTIVATION_TS: int = 1775459700 # Unix timestamp when premium gating activates
|
||||
@@ -540,8 +527,9 @@ async def is_dev_team(interaction: discord.Interaction) -> bool:
|
||||
def is_blacklisted():
|
||||
"""Return an app-command check that rejects blacklisted users or guilds.
|
||||
|
||||
Entries in BLACKLISTED_USER_IDS may be plain ints or
|
||||
``(user_id, reason)`` tuples.
|
||||
Blacklisted users come from the shared BLACKLIST.json (see
|
||||
``shared_store.check_user_blacklist``); entries there may be a plain id or
|
||||
``[id, reason]``.
|
||||
|
||||
Raises:
|
||||
BlacklistCheckFailure: If the guild or user is blacklisted,
|
||||
@@ -552,14 +540,9 @@ def is_blacklisted():
|
||||
if guild is not None and guild.id in BLACKLISTED_SERVER_IDS:
|
||||
raise BlacklistCheckFailure(t("en", "common.access_denied_desc"))
|
||||
|
||||
uid = interaction.user.id
|
||||
for entry in BLACKLISTED_USER_IDS:
|
||||
if isinstance(entry, tuple):
|
||||
blocked_id, reason = entry
|
||||
else:
|
||||
blocked_id, reason = entry, None
|
||||
if uid == blocked_id:
|
||||
raise BlacklistCheckFailure(reason)
|
||||
blocked, reason = check_user_blacklist(interaction.user.id)
|
||||
if blocked:
|
||||
raise BlacklistCheckFailure(reason)
|
||||
return True
|
||||
return app_commands.check(predicate)
|
||||
|
||||
@@ -778,9 +761,21 @@ def is_notif_enabled(entry: Any, notif_type: str) -> bool:
|
||||
return bool(re.search(r"\d{17,19}", raw))
|
||||
|
||||
|
||||
def is_foreign_pref_entry(entry: Any) -> bool:
|
||||
"""True if a preferences entry belongs to another bot (TSSBOT) and SRE should skip it.
|
||||
|
||||
Both bots share ``STORAGE/PREFERENCES/<guild>-preferences.json``. TSSBOT entries
|
||||
carry a ``Type`` of ``tss-team``/``tss-player``; SRE entries have no such Type.
|
||||
"""
|
||||
return isinstance(entry, dict) and str(entry.get("Type", "")).lower().startswith("tss")
|
||||
|
||||
|
||||
def enabled_pref_keys_for(prefs: Dict[str, Any], notif_type: str) -> List[str]:
|
||||
"""Squadron keys (in JSON insertion order) whose entry has this notif enabled."""
|
||||
return [k for k, v in prefs.items() if is_notif_enabled(v, notif_type)]
|
||||
return [
|
||||
k for k, v in prefs.items()
|
||||
if not is_foreign_pref_entry(v) and is_notif_enabled(v, notif_type)
|
||||
]
|
||||
|
||||
|
||||
def allowed_pref_keys_for(prefs: Dict[str, Any], tier: Optional[str], notif_type: str) -> set[str]:
|
||||
|
||||
Reference in New Issue
Block a user