Merges the Telegram API TL schema files from tdlib and tdesktop into a single unified superset.
Both tdlib and tdesktop maintain their own copy of the Telegram API schema. They are nearly identical but can differ in edge cases — one may add new constructors before the other, or carry internal-only definitions. This tool produces a merged schema that includes everything from both sources.
- Downloads (or reads) both
.tlfiles - Parses every combinator definition, keyed by
name#crc - Skips the tdlib preamble (built-in type aliases, internal types,
invokeWith*Prefixvariants, test functions) - Merges using CRC32 as the ground truth:
- Same name + same CRC — identical definition, keep one
- Same name + different CRC — conflict, auto-select the version with more parameters
- Name only in one source — include it
- Same CRC + different name — alias (e.g. Prefix variant), skip
- Outputs the merged schema using tdesktop's structure as the skeleton, preserving the
// LAYERmarker
No external dependencies — pure Python standard library.
# Download from GitHub and merge (default)
python main.py
# Specify output file
python main.py -o output.tl
# Use local files
python main.py --tdlib path/to/telegram_api.tl --tdesktop path/to/api.tl
# Only show differences, don't write output
python main.py --diff-onlyA GitHub Actions workflow runs daily at 08:00 CST (00:00 UTC). It downloads the latest schemas, runs the merge, and — if the result differs from the previous version — commits the updated merged.tl and creates a GitHub release tagged layer-{N}.
Unlicense — public domain.