#include <TelegramBot.h>
Definition at line 33 of file TelegramBot.h.
Telegram::TelegramBot::TelegramBot |
( |
| ) |
|
Telegram::TelegramBot::TelegramBot |
( |
std::string |
token | ) |
|
Constructor of bot
Sets the API URL and calls init
- Parameters
-
token | a std::string storing the bot token |
Definition at line 38 of file TelegramBot.cc.
void Telegram::TelegramBot::addCommand |
( |
TCommand |
cmd | ) |
|
Adds a callback to the command list of the bot
- Parameters
-
Definition at line 49 of file TelegramBot.cc.
void Telegram::TelegramBot::apiRequest |
( |
std::string |
method, |
|
|
std::map< std::string, std::string > |
parameters |
|
) |
| |
|
private |
A generic API request
Might be removed in future!
- Parameters
-
method | might be sendPhoto, sendMessage or any command defined by Telegram's API |
parameters | a map of further parameters, needed by the API call |
Definition at line 216 of file TelegramBot.cc.
Json::Value Telegram::TelegramBot::apiRequestFile |
( |
std::string |
filename, |
|
|
std::string |
type, |
|
|
std::string |
chat_id |
|
) |
| |
|
private |
Sending a file by InputFile object
- Parameters
-
filename | a valid file name |
type | may be photo, document, video |
chat_id | a valid chat id (might be a user or a group chat) |
- Returns
- result Json::Value
Definition at line 305 of file TelegramBot.cc.
Json::Value Telegram::TelegramBot::apiRequestJson |
( |
std::string |
method, |
|
|
std::map< std::string, std::string > |
parameters |
|
) |
| |
|
private |
An API request, posting JSON data
- Parameters
-
method | might be "sendPhoto", "sendMessage" or anything else, defined by the Telegram API |
parameters | further parameters to the API call (e.g. the text of a message) |
- Returns
- the JSON structure, sent back by Telegram's API
Definition at line 258 of file TelegramBot.cc.
getCommandMap return the complete command list of the bot
- Returns
- Map of the commands
Definition at line 192 of file TelegramBot.cc.
void Telegram::TelegramBot::init |
( |
void |
| ) |
|
|
private |
inits the bot. That is only sending a content-type to stdout in case one uses the bot by an CGI script
Definition at line 203 of file TelegramBot.cc.
std::string Telegram::TelegramBot::processCommand |
( |
std::string |
cmd | ) |
|
|
private |
processCommand gets a command by the user (e.g. /start) and processes the command. The command should be added to the command list by addCommand before, otherwise "Unknwon command" is returned
- Parameters
-
cmd | the command, defined in the command list (e.g. /start) |
- Returns
- the output of the command
Definition at line 352 of file TelegramBot.cc.
void Telegram::TelegramBot::processMessage |
( |
std::string |
message | ) |
|
Process incoming message
- Parameters
-
message | a std::string storing the message sent by the Telegram system |
Definition at line 79 of file TelegramBot.cc.
Telegram::Message * Telegram::TelegramBot::sendMessage |
( |
std::string |
message, |
|
|
Json::Int64 |
chat_id |
|
) |
| |
Send a text message to a user or group
- Parameters
-
message | The text of the message |
chat_id | the chat id |
- Returns
- A pointer to a Telegram message object
Definition at line 115 of file TelegramBot.cc.
Telegram::Message * Telegram::TelegramBot::sendMessage |
( |
std::string |
message, |
|
|
std::string |
chat_id |
|
) |
| |
sendMessage sends a simple text message to a given chat (might be a user or a group)
- Parameters
-
message | The text of the message |
chat_id | the chat id |
- Returns
- A pointer to a Telegram message object
Definition at line 128 of file TelegramBot.cc.
Telegram::Message * Telegram::TelegramBot::sendPhoto |
( |
std::string |
URL, |
|
|
Json::Int64 |
chat_id |
|
) |
| |
Sends a picture from the internet to a chat
- Parameters
-
URL | The URL of the picture |
chat_id | the chat id |
- Returns
- A pointer to a Telegram message object
Definition at line 149 of file TelegramBot.cc.
Telegram::Message * Telegram::TelegramBot::sendPhoto |
( |
std::string |
URL, |
|
|
std::string |
chat_id |
|
) |
| |
Sends a picture from the internet to a chat
- Parameters
-
URL | The URL of the picture |
chat_id | the chat id |
- Returns
- A pointer to a Telegram message object
Definition at line 162 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
-
url | a std::string with the URL of the hook |
Definition at line 65 of file TelegramBot.cc.
std::string Telegram::TelegramBot::api_url |
|
private |
Json::Int64 Telegram::TelegramBot::chat_id |
|
private |
The documentation for this class was generated from the following files: