diff options
author | Oleg Morozenkov <omorozenkov@gmail.com> | 2015-09-15 18:18:49 +0300 |
---|---|---|
committer | Oleg Morozenkov <omorozenkov@gmail.com> | 2015-09-15 18:18:49 +0300 |
commit | 6a3c8387da208ac2ffa4757dfafe1600a693b24f (patch) | |
tree | a8cfbfd46643784ede5ddfc0ce6dcd5f39d533d2 /samples | |
parent | 370df9853702bf9666b8dfa2e4254b9e236b2789 (diff) |
Fix formatting + some minor improvements
Diffstat (limited to 'samples')
-rw-r--r-- | samples/echobot/src/main.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/samples/echobot/src/main.cpp b/samples/echobot/src/main.cpp index f4a1a31..05806d2 100644 --- a/samples/echobot/src/main.cpp +++ b/samples/echobot/src/main.cpp @@ -32,34 +32,34 @@ using namespace TgBot; bool sigintGot = false; int main() { - signal(SIGINT, [](int s) { - printf("SIGINT got"); - sigintGot = true; - }); + signal(SIGINT, [](int s) { + printf("SIGINT got"); + sigintGot = true; + }); - 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); - }); + 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()); + try { + printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str()); - TgLongPoll longPoll(bot); - while (!sigintGot) { - printf("Long poll started\n"); - longPoll.start(); - } - } catch (exception& e) { - printf("error: %s\n", e.what()); - } + TgLongPoll longPoll(bot); + while (!sigintGot) { + printf("Long poll started\n"); + longPoll.start(); + } + } catch (exception& e) { + printf("error: %s\n", e.what()); + } - return 0; + return 0; } |