Export plaintext message content in JSON text
field
#26295
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Problem
As of v4.8.1, when exporting chats as JSON, the
text
fields of messages has two return types:string
if message is entirely in plain text, with no message entitiesarray
of mixed types otherwise (string
for plain text,object
for styled text)This was first identified in #25000.
Consider the following message:
The
text
field of the resulting JSON export for the message isProposed Solution
Concatenate the plaintext content for all message entities, producing a single string for the text field.
For example, the
text
andtext_entity
fields for message above would be exported asThis behaviour is also in keeping with the Telegram API and Bot API, where Message objects have
message
andtext
fields respectively for storing the plaintext content of a message.