tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
2.94k stars 569 forks source link

send a pdf document with sendMessage #577

Open salicius opened 2 months ago

salicius commented 2 months ago

Hi, how can i attach a document with the sendMessage method ?

levlam commented 2 months ago

To send a document you need to pass inputMessageDocument as input_message_content to sendMessage.

salicius commented 2 months ago

To send a document you need to pass inputMessageDocument as input_message_content to sendMessage.

sorry but i cant find it in https://core.telegram.org/bots/api#sendmessage, could you do an example please?

levlam commented 2 months ago

In Bot API you can use https://core.telegram.org/bots/api#senddocument.

salicius commented 2 months ago

In Bot API you can use https://core.telegram.org/bots/api#senddocument.

yes but in this way i have to use two different methods sendMessage and sendDocument, while i'd like use a single sendMessage and attach a document if it's possible. With sendDocument i can't send even a message, just a caption and i can't choose to put the document above or below the message

levlam commented 2 months ago

sendMessage Use this method to send text messages.

sendDocument Use this method to send general files.

salicius commented 2 months ago

sendMessage Use this method to send text messages.

sendDocument Use this method to send general files.

ok thanks, i know that. i'm saying if i can add an attachment file to sendMessage instead using two different methods and choose to put it above or below the message text like the link preview:

levlam commented 2 months ago

See link_preview_options parameter. If the document is small enough it can be seen in link preview.

salicius commented 2 months ago

thanks, but as he said i can't use that in sendDocument to decide whether to place it above or below

levlam commented 2 months ago

Currently, caption is always shown below the corresponding document.