LibTgBotPP
 All Classes Namespaces Files Functions Variables Typedefs Macros
Telegram::TelegramBot Class Reference

#include <TelegramBot.h>

Public Member Functions

 TelegramBot ()
 
 TelegramBot (std::string)
 
void addCommand (TCommand)
 
void setWebhook (std::string)
 
void processMessage (std::string)
 
void sendMessage (std::string, Json::Int64)
 
void sendMessage (std::string, std::string)
 
Telegram::MessagegetMessage ()
 
std::map< std::string, TCommandgetCommandMap ()
 

Private Member Functions

void init ()
 
void apiRequest (std::string, std::map< std::string, std::string >)
 
void apiRequestJson (std::string, std::map< std::string, std::string >)
 
std::string processCommand (std::string)
 

Private Attributes

std::string api_url
 
Telegram::Messagemsg
 
TCommandMap command_map
 
Json::Int64 chat_id
 

Detailed Description

Definition at line 32 of file TelegramBot.h.

Constructor & Destructor Documentation

Telegram::TelegramBot::TelegramBot ( )

Constructor of Bot

Definition at line 22 of file TelegramBot.cc.

Telegram::TelegramBot::TelegramBot ( std::string  token)

Constructor of bot

Parameters
tokena std::string

Definition at line 33 of file TelegramBot.cc.

Member Function Documentation

void Telegram::TelegramBot::addCommand ( TCommand  cmd)

Adds a callback to the command list of the bot

Parameters
cmda structure of type TCommand

Definition at line 44 of file TelegramBot.cc.

void Telegram::TelegramBot::apiRequest ( std::string  method,
std::map< std::string, std::string >  parameters 
)
private

A generic API request

Definition at line 123 of file TelegramBot.cc.

void Telegram::TelegramBot::apiRequestJson ( std::string  method,
std::map< std::string, std::string >  parameters 
)
private

An API request, posting JSON data

Definition at line 160 of file TelegramBot.cc.

Telegram::TCommandMap Telegram::TelegramBot::getCommandMap ( )

Definition at line 109 of file TelegramBot.cc.

Telegram::Message * Telegram::TelegramBot::getMessage ( )

Definition at line 104 of file TelegramBot.cc.

void Telegram::TelegramBot::init ( void  )
private

Definition at line 115 of file TelegramBot.cc.

std::string Telegram::TelegramBot::processCommand ( std::string  cmd)
private

Definition at line 187 of file TelegramBot.cc.

void Telegram::TelegramBot::processMessage ( std::string  message)

Process incoming message

Parameters
messagea std::string storing the message sent by the Telegram system

Definition at line 74 of file TelegramBot.cc.

void Telegram::TelegramBot::sendMessage ( std::string  message,
Json::Int64  chat_id 
)

Send a text message to a user

Definition at line 90 of file TelegramBot.cc.

void Telegram::TelegramBot::sendMessage ( std::string  message,
std::string  chat_id 
)

Definition at line 95 of file TelegramBot.cc.

void Telegram::TelegramBot::setWebhook ( std::string  url)

Set the webhook The web hook URL is like https://<your domain>="">/cgi-bin/mybot.cgi A web hook must be set before you can get any messages from the Telegram network!

Parameters
urla std::string with the URL of the hook

Definition at line 60 of file TelegramBot.cc.

Member Data Documentation

std::string Telegram::TelegramBot::api_url
private

Definition at line 48 of file TelegramBot.h.

Json::Int64 Telegram::TelegramBot::chat_id
private

Definition at line 51 of file TelegramBot.h.

TCommandMap Telegram::TelegramBot::command_map
private

Definition at line 50 of file TelegramBot.h.

Telegram::Message* Telegram::TelegramBot::msg
private

Definition at line 49 of file TelegramBot.h.


The documentation for this class was generated from the following files: