Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.08 KB

README.md

File metadata and controls

39 lines (30 loc) · 1.08 KB

CI Checks

SQBot

C++20 Library for Telegram Bot API

Hello, World!

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);

Dependencies

You need CURL and nlohmann json