wiz0u / WTelegramClient

Telegram Client API (MTProto) library written 100% in C# and .NET
https://wiz0u.github.io/WTelegramClient/
MIT License
956 stars 156 forks source link

how to get raw json text from tg updates/responses? #235

Closed Arcanum7 closed 6 months ago

Arcanum7 commented 6 months ago

Hi! how to get raw json as text which come with update or as response from tg server?

wiz0u commented 6 months ago

This library use binary structures/classes, not JSON, for better performance with the underlying binary protocol/connection MTProto.

For some reason (logs? dump?), if you really need a JSON version of those structures, you can serialize them like this:

string json = JsonSerializer.Serialize(update, WTelegram.Helpers.JsonOptions);
Arcanum7 commented 6 months ago

For some reason (logs? dump?)

if i do this:


var channels = await _client.Messages_GetAllChats();
var channel = (Channel)channels.chats[chid];
var chmsg = await _client.Channels_GetMessages(channel, _in);
richTextBox_exp.AppendText($"{chmsg.Messages[0]}");

with msg with media or/and markdown then i'll get somthing like this:

2037247235> text with picture TL.MessageMediaPhoto

what to do to get only text without "2037247235>" ? what to do to get text with markdown opening and close tags OR get text with formating and show it in richtextbox as is?

wiz0u commented 6 months ago

GitHub Issues should be used only for signaling bugs in the library code itself.

For questions about Telegram API usage, you can search the API official documentation or click here to ask your question on StackOverflow so the whole community can help and benefit.

For other programming questions or support, you may ask on Telegram groups: here, here or here.

wiz0u commented 6 months ago

Please read or search the documentation before asking a question.

The answer to your problem is likely already in those pages !

Also note that Github Issues are reserved for signaling bugs in the library code itself. General questions can be asked in our Telegram support group: @WTelegramClient