diff options
author | Oleg Morozenkov <omorozenkov@gmail.com> | 2015-07-27 20:59:09 +0300 |
---|---|---|
committer | Oleg Morozenkov <omorozenkov@gmail.com> | 2015-07-27 20:59:09 +0300 |
commit | 3f7a10f82567a0be04a424e0ddc360a73670c9d7 (patch) | |
tree | 4abc86893bbb33298d7058b65a5f94e5d5256c83 /README.md | |
parent | e4fb7e904b8d66d502a8e00dd3c9087a98140001 (diff) |
Documentation
Diffstat (limited to 'README.md')
-rw-r--r--[-rwxr-xr-x] | README.md | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/README.md b/README.md index 2296aa7..8bbe708 100755..100644 --- a/README.md +++ b/README.md @@ -2,6 +2,57 @@ C++ library for Telegram bot API.
-It's not stable version yet. Something may not work.
+**Warning:** It's not stable version yet. Something may not work.
-Dependencies: Boost
+Documentaion is located [here](http://reo7sp.ru/proj/tgbot-cpp/doc)
+
+## Compilation
+
+Firstly you need to install some dependencies. You have to have Boost library at the runtime and CMake at the compilation step to be able to use this library. On Debian-based distibutives you can do it with these commands:
+```sh
+sudo apt-get install cmake libboost-dev
+```
+
+To compile the library execute this commands:
+```sh
+cd /path/where/you/have/cloned/the/library/repository
+cmake .
+make -j4
+```
+
+That's all. All you have to do now is just link compiled library to your project.
+
+## Samples
+
+Simple echo bot which sends everything it recieves:
+```cpp
+int main() {
+ TgBot::Bot bot("PLACE YOUR TOKEN HERE");
+ bot.getEvents().onCommand("start", [&bot](Message::Ptr message) {
+ bot.getApi().sendMessage(message->chat->id, "Hi!");
+ });
+ bot.getEvents().onAnyMessage([&bot](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 samples are located [here](samples)
+
+## Feedback
+Feel free to [create new issues on GitHub](https://github.com/reo7sp/tgbot-cpp/issues) or [contact me on Telegram](https://telegram.me/Reo_SP)
|