|
|
- #include <stdio.h>
- #include <iostream>
- #include <tgbot/tgbot.h>
- #include <string>
- #include <vector>
-
- #include <boost/algorithm/string/classification.hpp> // Include boost::for is_any_of
- #include <boost/algorithm/string/split.hpp> // Include for boost::split
-
-
- #define OWNER 129755859
- int main() {
- std::string token(getenv("TOKEN"));
- TgBot::Bot bot(token);
- bot.getEvents().onCommand("start", [&bot](TgBot::Message::Ptr message) {
- bot.getApi().sendMessage(message->chat->id, "Hi!");
- });
-
-
- bot.getEvents().onAnyMessage([&bot](TgBot::Message::Ptr message)
- {
-
- 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;
- }
|