Skip to content

sn0wyQ/SQBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages