From b56eb9e71b395546eb8a2c2ebec582d1d3892b7e Mon Sep 17 00:00:00 2001 From: Kirill Kirilenko Date: Sat, 12 Nov 2016 03:13:22 +0400 Subject: [PATCH] Added Usage section --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 9262089..fe7ad14 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,39 @@ git submodule update --init --recursive ./configure make ``` +## Usage + +### Sending text message +Here is a simple example of how to send text message: +```cpp +#include + +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} +```