mirror of
https://github.com/UltraCoderRU/telebotxx.git
synced 2026-01-28 04:05:13 +00:00
Added Usage section
This commit is contained in:
parent
0315344af0
commit
b56eb9e71b
1 changed files with 36 additions and 0 deletions
36
README.md
36
README.md
|
|
@ -17,3 +17,39 @@ git submodule update --init --recursive
|
||||||
./configure
|
./configure
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Sending text message
|
||||||
|
Here is a simple example of how to send text message:
|
||||||
|
```cpp
|
||||||
|
#include <telebotxx/BotApi.hpp>
|
||||||
|
|
||||||
|
std::string token = "YOUR:BOT:TOKEN";
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using namespace telebotxx;
|
||||||
|
BotApi bot(token);
|
||||||
|
Message answer = bot.sendMessage(ChatId{"@chat_name"},
|
||||||
|
Text{"Hello, world!"}
|
||||||
|
);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Member function ```BotApi::sendMessage()``` returns information about sent message on success or throws an exception.
|
||||||
|
|
||||||
|
You can pass additional options in any combination and order:
|
||||||
|
```cpp
|
||||||
|
int messageId = ...; // ID of the original message to reply
|
||||||
|
Message answer = bot.sendMessage(ChatId{"@chat_name"},
|
||||||
|
Text{"Hello, world!"},
|
||||||
|
ReplyTo{messageId},
|
||||||
|
ParseMode::Markdown,
|
||||||
|
DisableNotification(),
|
||||||
|
DisableWebPagePreview()
|
||||||
|
);
|
||||||
|
```
|
||||||
|
Note, that ```ChatId``` argument can be specified with its name or id:
|
||||||
|
```cpp
|
||||||
|
ChatId{"@chat_name"}
|
||||||
|
ChatId{123456}
|
||||||
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue