C++20 Library for Telegram Bot API
Bot that sends "Hello, World!" to anyone who sends him /hello command:
#include <iostream>
#include "SQBot/Bot/bot.h"
#include "SQBot/EventManager/event_manager.h"
int main() {
SQBot::Bot bot("YOUR_TOKEN_HERE");
bot.GetEventManager()->SetCallbackForMessageFirstWordIs("/hello",
[](SQBot::Bot* bot, const MessagePtr& message) {
bot->SendMessage(message->chat->id,
"Hello, World!");
});
bot.StartReceivingUpdates();
return 0;
}
You can also use your own functions instead of lambdas:
void GreetTheWorld(SQBot::Bot* bot, const MessagePtr& message) {
bot->SendMessage(message->chat->id, "Hello, World!");
}
// ...
bot.GetEventManager()->SetCallbackForMessageFirstWordIs("/hello", GreetTheWorld);
You need CURL and nlohmann json