diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-09-09 17:33:11 +0200 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2022-09-09 17:33:11 +0200 |
commit | 707bcac4dd0fffd961dbb325e7d11752ee55392d (patch) | |
tree | 42f980b0c9a6e2b2b9d0d7541e2a04ee24188414 /README.md | |
parent | 349a54107d23ab58cff9afccad27741fa3ad8937 (diff) |
Update to API 5.7
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 194 |
1 files changed, 97 insertions, 97 deletions
@@ -1,98 +1,98 @@ -# tgbot-cpp
-
-[![Travis build Status](https://travis-ci.org/reo7sp/tgbot-cpp.svg?branch=master)](https://travis-ci.org/reo7sp/tgbot-cpp)
-<br>
-[![GitHub contributors](https://img.shields.io/github/contributors/reo7sp/tgbot-cpp.svg)](https://github.com/reo7sp/tgbot-cpp/graphs/contributors)
-
-C++14 library for Telegram bot API.
-
-Documentation is located [here](http://reo7sp.github.io/tgbot-cpp).
-
-
-## State
-
-- [x] Bot API 3.0 ~ 3.6
+# tgbot-cpp + +[![Travis build Status](https://travis-ci.org/reo7sp/tgbot-cpp.svg?branch=master)](https://travis-ci.org/reo7sp/tgbot-cpp) +<br> +[![GitHub contributors](https://img.shields.io/github/contributors/reo7sp/tgbot-cpp.svg)](https://github.com/reo7sp/tgbot-cpp/graphs/contributors) + +C++14 library for Telegram bot API. + +Documentation is located [here](http://reo7sp.github.io/tgbot-cpp). + + +## State + +- [x] Bot API 3.0 ~ 3.6 - [x] Bot API 4.0 ~ 4.9 -- [x] Bot API 5.0 ~ 5.6 (Implemented all APIs except 'Run Your Own Bot API Server')
-
-
-## Sample
-
-Simple echo bot which sends everything it receives:
-```cpp
-#include <stdio.h>
-#include <tgbot/tgbot.h>
-
-int main() {
- TgBot::Bot bot("PLACE YOUR TOKEN HERE");
- bot.getEvents().onCommand("start", [&bot](TgBot::Message::Ptr message) {
- bot.getApi().sendMessage(message->chat->id, "Hi!");
- });
- bot.getEvents().onAnyMessage([&bot](TgBot::Message::Ptr message) {
- printf("User wrote %s\n", message->text.c_str());
- if (StringTools::startsWith(message->text, "/start")) {
- return;
- }
- bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text);
- });
- try {
- printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
- TgBot::TgLongPoll longPoll(bot);
- while (true) {
- printf("Long poll started\n");
- longPoll.start();
- }
- } catch (TgBot::TgException& e) {
- printf("error: %s\n", e.what());
- }
- return 0;
-}
-```
-
-All other samples are located [here](samples).
-
-
-## Dependencies
-
-Firstly you need to install some dependencies such as Boost and build tools such as CMake. On Debian-based distibutives you can do it with these commands:
-```sh
-sudo apt-get install g++ make binutils cmake libssl-dev libboost-system-dev zlib1g-dev
-```
-If you want to use curl-based http client `CurlHttpClient`, you also need to install `libcurl4-openssl-dev` package.
-
-## Library installation
-
-If you want to install the library system-wide:
-```sh
-git clone https://github.com/reo7sp/tgbot-cpp
-cd tgbot-cpp
-cmake .
-make -j4
-sudo make install
-```
-
-You can treat this repository as a submodule of your project, for example, see [echobot-submodule](samples/echobot-submodule/CMakeLists.txt)
-
-You can use Docker to build and run your bot. Set the base image of your's Dockerfile to [reo7sp/tgbot-cpp](https://hub.docker.com/r/reo7sp/tgbot-cpp/).
-
-
-## Bot compilation
-
-### With CMake
-[Example CMakeLists.txt](samples/echobot/CMakeLists.txt)
-
-### Without CMake
-```sh
-g++ telegram_bot.cpp -o telegram_bot --std=c++14 -I/usr/local/include -lTgBot -lboost_system -lssl -lcrypto -lpthread
-```
-
-### Build options
-```
--DTGBOT_DISABLE_NAGLES_ALGORITHM # Disable 'Nagle's algorithm'
--DTGBOT_CHANGE_SOCKET_BUFFER_SIZE # Socket Buffer Size Expansion
--DTGBOT_CHANGE_READ_BUFFER_SIZE # Read Buffer Size Expansion
-```
-
-
-## Licence
-[The MIT License](https://github.com/reo7sp/tgbot-cpp/blob/master/LICENSE).
+- [x] Bot API 5.0 ~ 5.7 (Implemented all APIs except 'Run Your Own Bot API Server') + + +## Sample + +Simple echo bot which sends everything it receives: +```cpp +#include <stdio.h> +#include <tgbot/tgbot.h> + +int main() { + TgBot::Bot bot("PLACE YOUR TOKEN HERE"); + bot.getEvents().onCommand("start", [&bot](TgBot::Message::Ptr message) { + bot.getApi().sendMessage(message->chat->id, "Hi!"); + }); + bot.getEvents().onAnyMessage([&bot](TgBot::Message::Ptr message) { + printf("User wrote %s\n", message->text.c_str()); + if (StringTools::startsWith(message->text, "/start")) { + return; + } + bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text); + }); + try { + printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str()); + TgBot::TgLongPoll longPoll(bot); + while (true) { + printf("Long poll started\n"); + longPoll.start(); + } + } catch (TgBot::TgException& e) { + printf("error: %s\n", e.what()); + } + return 0; +} +``` + +All other samples are located [here](samples). + + +## Dependencies + +Firstly you need to install some dependencies such as Boost and build tools such as CMake. On Debian-based distibutives you can do it with these commands: +```sh +sudo apt-get install g++ make binutils cmake libssl-dev libboost-system-dev zlib1g-dev +``` +If you want to use curl-based http client `CurlHttpClient`, you also need to install `libcurl4-openssl-dev` package. + +## Library installation + +If you want to install the library system-wide: +```sh +git clone https://github.com/reo7sp/tgbot-cpp +cd tgbot-cpp +cmake . +make -j4 +sudo make install +``` + +You can treat this repository as a submodule of your project, for example, see [echobot-submodule](samples/echobot-submodule/CMakeLists.txt) + +You can use Docker to build and run your bot. Set the base image of your's Dockerfile to [reo7sp/tgbot-cpp](https://hub.docker.com/r/reo7sp/tgbot-cpp/). + + +## Bot compilation + +### With CMake +[Example CMakeLists.txt](samples/echobot/CMakeLists.txt) + +### Without CMake +```sh +g++ telegram_bot.cpp -o telegram_bot --std=c++14 -I/usr/local/include -lTgBot -lboost_system -lssl -lcrypto -lpthread +``` + +### Build options +``` +-DTGBOT_DISABLE_NAGLES_ALGORITHM # Disable 'Nagle's algorithm' +-DTGBOT_CHANGE_SOCKET_BUFFER_SIZE # Socket Buffer Size Expansion +-DTGBOT_CHANGE_READ_BUFFER_SIZE # Read Buffer Size Expansion +``` + + +## Licence +[The MIT License](https://github.com/reo7sp/tgbot-cpp/blob/master/LICENSE). |