node-telegram-bot-api-tutorial icon indicating copy to clipboard operation
node-telegram-bot-api-tutorial copied to clipboard

How do I strike text?

Open liben96 opened this issue 1 year ago • 1 comments

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

liben96 avatar Feb 23 '24 13:02 liben96

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:

  1. Change the parse_mode to HTML.
  2. Use or tags for strikethrough text.

kanhapise avatar Jun 06 '24 14:06 kanhapise