This C++ simple header-only library implements wrapper around Telegram bot api. There are methods for sending text, images and files. No handler is implemented, only a method to get last message. The main purpose of this library is providing a simple way of communication between desktop program and user's mobile device and not creating an actual telegram bot.
To use this library just place "TelegramBotApi.hpp" in project directory.
Cpr library is required to run.
This lib is really simple and short, this one block of code explains all there is to know.
#include <iostream>
#include <string>
#include "TelegramBotApi.hpp"
std::string token = "token";
std::string chatId = "chatid";
int main(){
tba::TelegramBotApi bot(token);
// Every send method returns true or false depending if data was sent sucessfully
// You can set the chatId this way or pass it as argument everytime you send data
bot.chatId = chatId;
bot.sendText("Hello World!");
bot.sendPhotoFile("C:/users/user/desktop/img.jpg");
bot.sendPhotoUrl("https://example.com/img.jpg");
// Second way of passing chatId
bot.sendText("Hello World!", "-69420")
bot.sendFile("C:/users/user/abc.txt", "-69420");
// sending photo with caption and formatting
// formatting options: "Markdown", "MarkdownV2", "HTML" (leaving it empty results in plain text)
bot.sendPhotoUrl("https://example.com/img.jpg", "<b>Title</b>\nSmall text", "HTML");
bot.sendPhotoFile("C:/users/user/desktop/img.jpg", "caption text"); // no formatting
// Returns last message (std::string) in json format. All data like chat_id or date included
std::cout << bot.getLastMessage() << std::endl;
}