baderouaich / tgbotxx

Telegram Bot C++ Library
https://baderouaich.github.io/tgbotxx/
MIT License
11 stars 0 forks source link

Sending multiply images in one message #3

Closed OMRKiruha closed 10 months ago

OMRKiruha commented 10 months ago

Hi! Can I send 4-5 local photo in one message by sendMediaGroup? I can't found how make InputMediaPhoto from local file.

baderouaich commented 10 months ago

Hi @OMRKiruha , you're right, currently sendMediaGroup is implemented to send only URL & already uploaded files ids. I have made some changes to the Api. Now you can send local files by wrapping your file path with a cpr::File of any media type. for example sending a photo media group will be like:

std::vector<Ptr<InputMedia>> mediaGroup;
for (const std::string localPhoto : {"/path/to/photo1.jpg", "/path/to/photo2.jpg", "/path/to/photo3.jpg"}) {
  Ptr<InputMediaPhoto> photo(new InputMediaPhoto());
  photo->media = cpr::File{localPhoto}; // Local
  photo->hasSpoiler = false;
  mediaGroup.push_back(photo);
}
api()->sendMediaGroup(message->chat->id, mediaGroup);

Note: You can also mix local and URL/id photos in one media group, as well as other media types (document, video, audio and animation).

Please don't hesitate to open an issue of any question or problem you may encounter. Thank you for reporting this missing feature and have a great day!

OMRKiruha commented 10 months ago

Thank you very much. I am glad that the library is developing. Thanks for the great support.