mirror of
https://github.com/UltraCoderRU/telebotxx.git
synced 2026-01-28 04:05:13 +00:00
Added examples of sending photos
This commit is contained in:
parent
b56eb9e71b
commit
7599c99113
1 changed files with 36 additions and 1 deletions
37
README.md
37
README.md
|
|
@ -45,7 +45,7 @@ Message answer = bot.sendMessage(ChatId{"@chat_name"},
|
||||||
ReplyTo{messageId},
|
ReplyTo{messageId},
|
||||||
ParseMode::Markdown,
|
ParseMode::Markdown,
|
||||||
DisableNotification(),
|
DisableNotification(),
|
||||||
DisableWebPagePreview()
|
DisableWebPagePreview()
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
Note, that ```ChatId``` argument can be specified with its name or id:
|
Note, that ```ChatId``` argument can be specified with its name or id:
|
||||||
|
|
@ -53,3 +53,38 @@ Note, that ```ChatId``` argument can be specified with its name or id:
|
||||||
ChatId{"@chat_name"}
|
ChatId{"@chat_name"}
|
||||||
ChatId{123456}
|
ChatId{123456}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Sending images
|
||||||
|
To send a photo use any of the folowing variants depending of image source:
|
||||||
|
```cpp
|
||||||
|
// for local file
|
||||||
|
Message answer = bot.sendPhoto(ChatId{"@chat_name"}, Photo{File{"photo.jpg"}});
|
||||||
|
|
||||||
|
// for in-memory image stored in std::vector
|
||||||
|
std::vector<char> photo = ...;
|
||||||
|
Message answer = bot.sendPhoto(ChatId{"@chat_name"},
|
||||||
|
Photo{Buffer{photo, "photo.jpg"}}
|
||||||
|
);
|
||||||
|
|
||||||
|
// for in-memory image stored in C-array
|
||||||
|
Message answer = bot.sendPhoto(ChatId{"@chat_name"},
|
||||||
|
Photo{Buffer{photo.data(), photo.size(), "photo.jpg"}}
|
||||||
|
);
|
||||||
|
|
||||||
|
// for image available by URL
|
||||||
|
Message answer = bot.sendPhoto(ChatId{"@chat_name"},
|
||||||
|
Photo{Url{"http://sample.com/sample.jpg"}}
|
||||||
|
);
|
||||||
|
|
||||||
|
// for already uploaded photo you can send it by id
|
||||||
|
Message answer = bot.sendPhoto(ChatId{"@chat_name"}, Photo{123456});
|
||||||
|
```
|
||||||
|
As in the case of messages, you can pass additional options:
|
||||||
|
```cpp
|
||||||
|
Message answer = bot.sendPhoto(ChatId{"@chat_name"},
|
||||||
|
Photo{File{"photo.jpg"}}
|
||||||
|
Caption{"Sample photo"},
|
||||||
|
ReplyTo(messageId),
|
||||||
|
DisableNotification()
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue