plugins/tools/plugin_dunechat.py
unimatrixgit 2f700ae7cc
All checks were successful
DuneChat Build / dunechat (push) Successful in 43s
DuneRealms Plugin CI / plugins (push) Successful in 4m12s
Guard Arrakis chat cutover and keep private prompts out of relay
2026-12-02 13:35:14 +01:00

34 lines
1.7 KiB
Python

"""Verify the DuneChat artifact and prepare the Arrakis public relay."""
import hashlib
import re
DISCORD_CONFIG = 'ea5460f59766315e47e343e0a6d88deb71232df065f7bde0074ab742c8f65b4d'
DISCORD_JAR = 'ef2fa1f2eb146c7c77412b7190a7dd33f1fc91282683fe45407739554c8aefef'
def enable_modern_discord(config):
setting = re.compile(r'(?m)^(UseModernPaperChatEvent:[ \t]*)false([ \t]*(?:#[^\r\n]*)?)(\r?\n)')
matches = list(setting.finditer(config))
if len(matches) != 1 or len(re.findall(r'(?m)^UseModernPaperChatEvent\s*:', config)) != 1:
raise ValueError('Expected exactly one disabled modern Discord chat setting')
if re.search(r'(?m)^RespectChatPlugins\s*:', config):
raise ValueError('Discord cancellation policy differs from the reviewed config')
return setting.sub(r'\g<1>true\g<2>\g<3>RespectChatPlugins: true\g<3>', config)
def verify_artifact(artifact, source):
expected = {
'DuneChat.jar', 'SOURCE_COMMIT', 'plugin_dunechat.py', 'install-plugin-fleet.py',
'write-plugin-manifest.py', 'plugin_menu_pack.py', 'plugin_backend_abi.py',
'plugin_fleet_rollback.py', 'plugin_pack_properties.py', 'plugin_pillager_abi.py',
}
lines = (artifact / 'SHA256SUMS').read_text().splitlines()
sums = dict(line.split(' ', 1)[::-1] for line in lines)
if len(lines) != len(sums) or sums.keys() != expected or any(
hashlib.sha256((artifact / name).read_bytes()).hexdigest() != sha for name, sha in sums.items()
):
raise ValueError('Unexpected DuneChat archive manifest')
if (artifact / 'SOURCE_COMMIT').read_text().strip() != source:
raise ValueError('DuneChat archive source differs from the selected commit')