LibTgBotPP
 All Classes Namespaces Files Functions Variables Typedefs Macros
example01.cc File Reference
#include <Telegram/TelegramBot.h>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <termios.h>
#include <stdbool.h>
#include <unistd.h>

Go to the source code of this file.

Macros

#define WEBHOOK_URL   "https://<your-web-server>/cgi-bin/<binary name>"
 
#define BOT_TOKEN   "<your token>"
 
#define SSTR(x)   static_cast< std::ostringstream & >(( std::ostringstream() << std::dec << x ) ).str()
 

Functions

std::string exec (const char *cmd)
 
std::vector< std::string > explode (const std::string &delimiter, const std::string &str)
 
std::string start (Telegram::TelegramBot *tg, Telegram::TCommandLine args)
 
std::string help (Telegram::TelegramBot *tg, Telegram::TCommandLine args)
 
std::string whoami (Telegram::TelegramBot *tg, Telegram::TCommandLine args)
 
std::string loadavg (Telegram::TelegramBot *tg, Telegram::TCommandLine args)
 
std::string proc (Telegram::TelegramBot *tg, Telegram::TCommandLine args)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

#define BOT_TOKEN   "<your token>"

Definition at line 34 of file example01.cc.

#define SSTR (   x)    static_cast< std::ostringstream & >(( std::ostringstream() << std::dec << x ) ).str()

Definition at line 35 of file example01.cc.

#define WEBHOOK_URL   "https://<your-web-server>/cgi-bin/<binary name>"

This is a simple bot that can echo a message, piped to its binary and is usable as a cgi script to react on some simple commands.

Before you first use this example, change WEBHOOK_URL and BOT_TOKEN according to your needs and your web server!

Example: WEBHOK_URL: https://bot.foobar.tld/cgi-bin/bot.cgi BOT_TOKEN: Your token given by Telegram's Bot Father!

To compile do: g++ -c -o example01.o -I/usr/include/jsoncpp example01.cc g++ -o example01 example01.o -ltgbotpp

Run: echo "Your message" | ./example01 -u <your user="" id>="">

Definition at line 33 of file example01.cc.

Function Documentation

std::string exec ( const char *  cmd)

Definition at line 37 of file example01.cc.

std::vector<std::string> explode ( const std::string &  delimiter,
const std::string &  str 
)

Definition at line 54 of file example01.cc.

std::string help ( Telegram::TelegramBot tg,
Telegram::TCommandLine  args 
)

Definition at line 87 of file example01.cc.

std::string loadavg ( Telegram::TelegramBot tg,
Telegram::TCommandLine  args 
)

Definition at line 105 of file example01.cc.

int main ( int  argc,
char **  argv 
)

Definition at line 116 of file example01.cc.

std::string proc ( Telegram::TelegramBot tg,
Telegram::TCommandLine  args 
)

Definition at line 110 of file example01.cc.

std::string start ( Telegram::TelegramBot tg,
Telegram::TCommandLine  args 
)

Definition at line 82 of file example01.cc.

std::string whoami ( Telegram::TelegramBot tg,
Telegram::TCommandLine  args 
)

Definition at line 100 of file example01.cc.