node-telegram-bot-api-tutorial
node-telegram-bot-api-tutorial copied to clipboard
How do I strike text?
Hi, Im writing a code in node js, using the "node-telegram-bot-api" library version"^0.64.0".
Im using the sendPhoto method... to send a photo... and in the caption im trying to do some formatting. I am able to do bold, but im not able to do strike.
I have tried parse_mode = MarkdownV2, but it breaks. I have also tried using a single and double ~ character.
let message = "*bold text*\n\n~strike~\n\n~~Striked~~";
const imgStream = request.get(imageUrl).on('error', function(err) { console.log(err); });
bot.sendPhoto(process.env.telegram_group_id, imgStream, { parse_mode: 'Markdown', caption: message, })
.then(() => {
console.log('Message sent successfully');
})
.catch((error) => {
console.error('Error sending message: ', error);
});
}
Any ideas? Thanks
In Telegram, strikethrough text is not supported in Markdown or MarkdownV2. However, you can use HTML parse mode to achieve the strikethrough formatting.
Here’s how you can modify your code to use HTML for formatting the caption:
- Change the parse_mode to HTML.
- Use
ortags for strikethrough text.