yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.31k stars 1.51k forks source link

Parse mode in .editMessageCaption method not working #849

Closed hugorplobo closed 2 years ago

hugorplobo commented 3 years ago

I need to edit the caption of a photo that has some HTML and was sent by my bot:

const videoDetails = `šŸŽ¬ <a href="${url}">${info.videoDetails.title}</a>
šŸ‘¤ <a href="${info.videoDetails.ownerProfileUrl}">${info.videoDetails.ownerChannelName}</a>
šŸ•‘ <b>${videoLength}</b>   šŸ’¾ <b>${functions.getVideoSize(audioFormat.contentLength)} MB</b>`

When I use the editMessageCaption method, formatting is lost

bot.editMessageCaption( query.message.caption + "\n\nāš™ļø Processing your video...", { message_id: query.message.message_id, chat_id: query.from.id, parse_mode: "HTML", //caption_entities: query.message.caption_entities } )

Neither parse mode nor caption_entities work. Any idea how to solve?

kamikazechaser commented 3 years ago

This is probably not an issue with the library. Your template literal might be broken. Check around the href tags.

Edit: Your templating looks fine. I'll check what the issue might be.

seeya commented 3 years ago

Facing the same issue here. On the official telegram it states passing in either parse_mode or caption_entites. However neither work using this library.

AlonBe commented 3 years ago

I'm using version 0.50 and encountered a problem using "entities" or "caption_entities" properties when sending/editing messages.

I'm not sure if there's another issue about it, the workaround that worked for me is below: const entitiesAsString = JSON.stringify(entitiesArray); await bot.sendMessage(chatId, 'some text', { entities: entitiesAsString, });

danielperez9430 commented 2 years ago

Fix on next release. Not more need JSON. stringify()