Skip to content

feat(tg): add InvokeJSON method for MTProto JSON format#1645

Merged
ernado merged 1 commit intogotd:mainfrom
golshani-mhd:feature/tdlib-json-invoke
Dec 4, 2025
Merged

feat(tg): add InvokeJSON method for MTProto JSON format#1645
ernado merged 1 commit intogotd:mainfrom
golshani-mhd:feature/tdlib-json-invoke

Conversation

@golshani-mhd
Copy link
Contributor

Add InvokeJSON method to tg.Client that accepts MTProto JSON format (e.g., messages.sendMessage) and returns JSON response.

Features:

  • Accepts JSON with @type field in MTProto format (namespace.methodName)
  • Supports snake_case or PascalCase output via useSnakeCase parameter
  • Uses jx for input parsing (no reflection overhead)
  • Uses generated constructors and type maps (no reflection)
  • Handles nested objects with @type fields
  • Supports Int128/Int256 hex string detection

Also update README.md to document MTProto JSON format usage instead of TDLib format, showing proper usage with client.API().InvokeJSON().

Add InvokeJSON method to tg.Client that accepts MTProto JSON format
(e.g., messages.sendMessage) and returns JSON response.

Features:
- Accepts JSON with @type field in MTProto format (namespace.methodName)
- Supports snake_case or PascalCase output via useSnakeCase parameter
- Uses jx for input parsing (no reflection overhead)
- Uses generated constructors and type maps (no reflection)
- Handles nested objects with @type fields
- Supports Int128/Int256 hex string detection

Also update README.md to document MTProto JSON format usage instead
of TDLib format, showing proper usage with client.API().InvokeJSON().
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 0% with 443 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.77%. Comparing base (4c29da8) to head (ca63409).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
tg/json_invoke.go 0.00% 342 Missing ⚠️
telegram/tdlib_json.go 0.00% 101 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1645      +/-   ##
==========================================
- Coverage   70.69%   68.77%   -1.93%     
==========================================
  Files         443      445       +2     
  Lines       17950    18393     +443     
==========================================
- Hits        12690    12650      -40     
- Misses       4317     4797     +480     
- Partials      943      946       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ernado ernado merged commit 2e3b978 into gotd:main Dec 4, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants