yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.5k stars 1.55k forks source link

Bug: caption_entities not working as expected in Telegram Bot API #1240

Open LughWalle opened 3 days ago

LughWalle commented 3 days ago

Bug Report

I have read:

I am using the latest version of the library.


Expected Behavior

The caption_entities parameter should properly format the caption for media messages such as photos, videos, and documents. When using the following code snippet:

await bot.sendPhoto(targetChatId, fileId, {
  caption: "This is an example caption",
  caption_entities: [
    { offset: 0, length: 8, type: 'underline' },
    { offset: 9, length: 10, type: 'spoiler' },
    { offset: 19, length: 8, type: 'bold' }
  ],
});

The resulting caption should render with formatting applied:

This is ||an example|| caption


Actual Behavior

The message is sent, but the caption_entities parameter is ignored, and the caption appears as plain text:

This is an example caption

No formatting (e.g., underline, spoiler, bold) is applied.


Steps to reproduce the Behavior

  1. Use the sendPhoto method with the code snippet above.
  2. Observe that the caption is sent as plain text, ignoring the caption_entities.
  3. Compare this to the behavior of entities for text messages, which applies formatting correctly.

This seems like a bug where the caption_entities field is either not processed or incorrectly passed to the Telegram Bot API. If the implementation is correct, clarification in the documentation would also be helpful. Thank you for your attention to this matter!

darkywa13 commented 2 days ago

This is a normal practice for this library :( caption_entities: JSON.stringify(message.caption_entities) as any