gramjs
gramjs copied to clipboard
Telegram entity classes are lost after message serialization
Telegram entity classes are lost after message serialization
/// get one message with bold in text
const chanId = 123 // insert yours
const offset = 456 // insert yours
const result = await client.client.invoke(new Api.messages.GetHistory({
peer: chanId,
limit: 1,
offsetId: offset
}));
console.log(message, JSON.parse(JSON.stringify(message))) // printing both plain and stringified version
in the console (excerpts):
// when doing console.log()
entities: [
{
CONSTRUCTOR_ID: 3177253833,
SUBCLASS_OF_ID: 3479443932,
className: 'MessageEntityBold',
classType: 'constructor',
offset: 19,
length: 7
},
{
CONSTRUCTOR_ID: 3177253833,
SUBCLASS_OF_ID: 3479443932,
className: 'MessageEntityBold',
classType: 'constructor',
offset: 35,
length: 7
}
],
// when doing JSON.parse(JSON.stringify())
entities: [ { offset: 19, length: 7 }, { offset: 35, length: 7 } ],
As a result, className: 'MessageEntityBold', is lost forever.
ah you're right,
I don't think the other info (constructor id , subclass id , class type) are relevant so I'm only going to add the class name for now
Should be fixed in https://github.com/gram-js/gramjs/commit/6fc7ea29b72b8386be86be3b4d50020d31942ec3 Please test and close this issue if it's working now.
Tested, looks fine, many thanks!