Deploy SQLite WAL SHA256 audit core, modular sources, and per-ministry Charcoal dispatcher
This commit is contained in:
parent
ea32bde3ac
commit
1e003c2f50
6 changed files with 190 additions and 0 deletions
55
core/audit_sources/source_minecraft.py
Normal file
55
core/audit_sources/source_minecraft.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import os, re, json
|
||||
from core.audit_core import emit_audit
|
||||
|
||||
LINKS_DB = "/root/flexicraft-discord-setup/data/crossplay_links.json"
|
||||
|
||||
CMD_MINISTRY_RULES = [
|
||||
(re.compile(r"^/(?:lp|luckperms|ban|tempban|banip|unban|unbanip|kick|co|whitelist|op|deop)\b", re.I), "netherite", "Serveur Minecraft — Sécurité & Sanctions"),
|
||||
(re.compile(r"^/(?:mute|unmute|socialspy|broadcast)\b", re.I), "amethyst", "Serveur Minecraft — Modération Communication"),
|
||||
(re.compile(r"^/(?:invsee|enderchest|echest|teamadmin)\b", re.I), "coal", "Serveur Minecraft — Intérieur & Clans"),
|
||||
(re.compile(r"^/(?:worldedit|we|/)\b", re.I), "copper", "Serveur Minecraft — Travaux Publics"),
|
||||
(re.compile(r"^/(?:tp|tphere|tppos)\b", re.I), "gold", "Serveur Minecraft — Transports & Mobilité"),
|
||||
(re.compile(r"^/(?:spark|tps)\b", re.I), "quartz", "Serveur Minecraft — Technique & Performance"),
|
||||
(re.compile(r"^/(?:datapack|gamerule)\b", re.I), "lapis", "Serveur Minecraft — Mécaniques & Datapacks"),
|
||||
(re.compile(r"^/(?:save-all)\b", re.I), "emerald", "Serveur Minecraft — Économie & Sauvegarde"),
|
||||
(re.compile(r"^/(?:gamemode|gm|give)\b", re.I), "diamond", "Serveur Minecraft — Administration Suprême"),
|
||||
]
|
||||
|
||||
def _resolve_discord_id_for_mc_player(mc_name: str):
|
||||
if not os.path.exists(LINKS_DB):
|
||||
return None
|
||||
low = mc_name.lower().lstrip(".")
|
||||
try:
|
||||
with open(LINKS_DB, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
for did, info in data.items():
|
||||
if not isinstance(info, dict):
|
||||
continue
|
||||
jname = str(info.get("java_name") or info.get("mc_name") or "").lower()
|
||||
bname = str(info.get("bedrock_name") or "").lower().lstrip(".")
|
||||
if low and (low == jname or low == bname):
|
||||
return str(did)
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
def process_mc_log_line(line: str):
|
||||
m = re.search(r":\s+([A-Za-z0-9_\.]{2,20})\s+issued server command:\s+(/.*)$", line.strip())
|
||||
if not m:
|
||||
return None
|
||||
player, cmd = m.group(1), m.group(2).strip()
|
||||
if player.upper() == "CONSOLE":
|
||||
return None
|
||||
for regex, ministry, sphere in CMD_MINISTRY_RULES:
|
||||
if regex.search(cmd):
|
||||
did = _resolve_discord_id_for_mc_player(player)
|
||||
return emit_audit(
|
||||
ministry=ministry,
|
||||
source="minecraft",
|
||||
actor_name=player,
|
||||
actor_discord_id=did,
|
||||
action="Commande exécutée en jeu",
|
||||
target=cmd,
|
||||
details={"sphere": sphere}
|
||||
)
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue