ZaStoGram/Tools/check_settings_durov_links.py
loop-uh 5202862ff6 Add edit history, refactor Zapret sponsor, improve privacy controls
Implement ZaSto edit history tracking for remotely-edited messages, fixing channel vs global deleted message tracking, and refactor Zapret VPN sponsor from synthetic custom dialog to real username resolution. Add granular privacy flags (ALLOW_SCREENSHOTS, ALLOW_SAVE_PROTECTED, KEEP_EDIT_HISTORY) to control screenshot blocking, protected media saving, and edit history display. Improve ephemeral and anti-delete message handling with better read state guards. Update message timestamps to show colored markers (удалено, разово) for ZaSto-kept content. Add ABI-split APK design doc for GitHub Actions builds.
2026-06-27 00:55:14 +03:00

82 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""Static guard for the custom help links in Settings."""
from pathlib import Path
import re
import sys
ROOT = Path(__file__).resolve().parents[1]
SETTINGS_ACTIVITY = ROOT / "TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java"
STRINGS = ROOT / "TMessagesProj/src/main/res/values/strings.xml"
EXPECTED_STRINGS = {
"DurovLalka": "Дуров лалка",
"OurChannel": "Наш канал",
"OurVpn": "Наш VPN",
}
EXPECTED_LINKS = {
24: ("OurChannel", "settings_channel", "https://t.me/bypassblock"),
25: ("OurVpn", "settings_privacy", "https://t.me/vpndiscordyooutube"),
}
def main() -> int:
java = SETTINGS_ACTIVITY.read_text(encoding="utf-8")
strings = STRINGS.read_text(encoding="utf-8")
errors: list[str] = []
def require(condition: bool, message: str) -> None:
if not condition:
errors.append(message)
for name, value in EXPECTED_STRINGS.items():
require(
f'<string name="{name}">{value}</string>' in strings,
f"Missing string resource {name}={value}",
)
require(
"items.add(UItem.asHeader(getString(R.string.DurovLalka)))" in java,
"Settings help section must include the custom DurovLalka header",
)
for item_id, (string_name, icon_name, url) in EXPECTED_LINKS.items():
require(
re.search(
rf"SettingCell\.Factory\.of\({item_id},[^;]+R\.drawable\.{icon_name},\s*getString\(R\.string\.{string_name}\)\)",
java,
re.DOTALL,
)
is not None,
f"Settings item {item_id} must use {string_name} with {icon_name}",
)
require(
re.search(
rf"case {item_id}:\s+Browser\.openUrl\(getParentActivity\(\), \"{re.escape(url)}\"\);\s+break;",
java,
re.DOTALL,
)
is not None,
f"Settings item {item_id} must open {url}",
)
require(
"https://t.me/zapretvpns_bot" not in java,
"Zapret VPNs sponsor link must live in the chat list, not Settings",
)
if errors:
print("Settings Durov links check failed:")
for error in errors:
print(f"- {error}")
return 1
print("Settings Durov links check passed")
return 0
if __name__ == "__main__":
sys.exit(main())