You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

429 lines
22 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>LibTgBotPP: example01.cc File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">LibTgBotPP
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&#160;List</span></a></li>
<li><a href="globals.html"><span>File&#160;Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('example01_8cc.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Macros</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">example01.cc File Reference</div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;<a class="el" href="TelegramBot_8h_source.html">Telegram/TelegramBot.h</a>&gt;</code><br/>
<code>#include &lt;map&gt;</code><br/>
<code>#include &lt;sstream&gt;</code><br/>
<code>#include &lt;string&gt;</code><br/>
<code>#include &lt;vector&gt;</code><br/>
<code>#include &lt;termios.h&gt;</code><br/>
<code>#include &lt;stdbool.h&gt;</code><br/>
<code>#include &lt;unistd.h&gt;</code><br/>
</div>
<p><a href="example01_8cc_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a879c9d54cce72d602eb541ccdadb0ea6"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#a879c9d54cce72d602eb541ccdadb0ea6">WEBHOOK_URL</a>&#160;&#160;&#160;&quot;https://&lt;your-web-server&gt;/cgi-bin/&lt;binary name&gt;&quot;</td></tr>
<tr class="separator:a879c9d54cce72d602eb541ccdadb0ea6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a46ae855efe2974950d236ddeb7a7118a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#a46ae855efe2974950d236ddeb7a7118a">BOT_TOKEN</a>&#160;&#160;&#160;&quot;&lt;your token&gt;&quot;</td></tr>
<tr class="separator:a46ae855efe2974950d236ddeb7a7118a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0d2f37137ee1fd6ff4a0ef803849dd63"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#a0d2f37137ee1fd6ff4a0ef803849dd63">SSTR</a>(x)&#160;&#160;&#160;static_cast&lt; std::ostringstream &amp; &gt;(( std::ostringstream() &lt;&lt; std::dec &lt;&lt; x ) ).str()</td></tr>
<tr class="separator:a0d2f37137ee1fd6ff4a0ef803849dd63"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a43b669bccb8bce8ea862a58a9dc116bd"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#a43b669bccb8bce8ea862a58a9dc116bd">exec</a> (const char *cmd)</td></tr>
<tr class="separator:a43b669bccb8bce8ea862a58a9dc116bd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a316c9e2b99ca29094112ea9f4f131b85"><td class="memItemLeft" align="right" valign="top">std::vector&lt; std::string &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#a316c9e2b99ca29094112ea9f4f131b85">explode</a> (const std::string &amp;delimiter, const std::string &amp;str)</td></tr>
<tr class="separator:a316c9e2b99ca29094112ea9f4f131b85"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a62e688e1f7e24b74a53a2bf7da93e5c1"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#a62e688e1f7e24b74a53a2bf7da93e5c1">start</a> (<a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *tg, <a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a> args)</td></tr>
<tr class="separator:a62e688e1f7e24b74a53a2bf7da93e5c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad80d7c455c0c87f879a92658ad28329d"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#ad80d7c455c0c87f879a92658ad28329d">help</a> (<a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *tg, <a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a> args)</td></tr>
<tr class="separator:ad80d7c455c0c87f879a92658ad28329d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a127652392bff79b07e87fc7cfa88508c"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#a127652392bff79b07e87fc7cfa88508c">whoami</a> (<a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *tg, <a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a> args)</td></tr>
<tr class="separator:a127652392bff79b07e87fc7cfa88508c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa93e480f3e6a877724767a4058c57ec5"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#aa93e480f3e6a877724767a4058c57ec5">loadavg</a> (<a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *tg, <a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a> args)</td></tr>
<tr class="separator:aa93e480f3e6a877724767a4058c57ec5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aecdda2b4770f85617b26cf01e056354b"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#aecdda2b4770f85617b26cf01e056354b">proc</a> (<a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *tg, <a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a> args)</td></tr>
<tr class="separator:aecdda2b4770f85617b26cf01e056354b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3c04138a5bfe5d72780bb7e82a18e627"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="example01_8cc.html#a3c04138a5bfe5d72780bb7e82a18e627">main</a> (int argc, char **argv)</td></tr>
<tr class="separator:a3c04138a5bfe5d72780bb7e82a18e627"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a46ae855efe2974950d236ddeb7a7118a"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define BOT_TOKEN&#160;&#160;&#160;&quot;&lt;your token&gt;&quot;</td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00034">34</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="a0d2f37137ee1fd6ff4a0ef803849dd63"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define SSTR</td>
<td>(</td>
<td class="paramtype">&#160;</td>
<td class="paramname">x</td><td>)</td>
<td>&#160;&#160;&#160;static_cast&lt; std::ostringstream &amp; &gt;(( std::ostringstream() &lt;&lt; std::dec &lt;&lt; x ) ).str()</td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00035">35</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="a879c9d54cce72d602eb541ccdadb0ea6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define WEBHOOK_URL&#160;&#160;&#160;&quot;https://&lt;your-web-server&gt;/cgi-bin/&lt;binary name&gt;&quot;</td>
</tr>
</table>
</div><div class="memdoc">
<p>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.</p>
<p>Before you first use this example, change WEBHOOK_URL and BOT_TOKEN according to your needs and your web server!</p>
<p>Example: WEBHOK_URL: <a href="https://bot.foobar.tld/cgi-bin/bot.cgi">https://bot.foobar.tld/cgi-bin/bot.cgi</a> BOT_TOKEN: Your token given by <a class="el" href="namespaceTelegram.html">Telegram</a>'s Bot Father!</p>
<p>To compile do: g++ -c -o example01.o -I/usr/include/jsoncpp <a class="el" href="example01_8cc.html">example01.cc</a> g++ -o example01 example01.o -ltgbotpp</p>
<p>Run: echo "Your message" | ./example01 -u &lt;your user="" id&gt;=""&gt; </p>
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00033">33</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a43b669bccb8bce8ea862a58a9dc116bd"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string exec </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>cmd</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00037">37</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="a316c9e2b99ca29094112ea9f4f131b85"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::vector&lt;std::string&gt; explode </td>
<td>(</td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>delimiter</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>str</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00054">54</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="ad80d7c455c0c87f879a92658ad28329d"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string help </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *&#160;</td>
<td class="paramname"><em>tg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a>&#160;</td>
<td class="paramname"><em>args</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00087">87</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="aa93e480f3e6a877724767a4058c57ec5"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string loadavg </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *&#160;</td>
<td class="paramname"><em>tg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a>&#160;</td>
<td class="paramname"><em>args</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00105">105</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="a3c04138a5bfe5d72780bb7e82a18e627"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int main </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>argc</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char **&#160;</td>
<td class="paramname"><em>argv</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00116">116</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="aecdda2b4770f85617b26cf01e056354b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string proc </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *&#160;</td>
<td class="paramname"><em>tg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a>&#160;</td>
<td class="paramname"><em>args</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00110">110</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="a62e688e1f7e24b74a53a2bf7da93e5c1"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string start </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *&#160;</td>
<td class="paramname"><em>tg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a>&#160;</td>
<td class="paramname"><em>args</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00082">82</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
<a class="anchor" id="a127652392bff79b07e87fc7cfa88508c"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::string whoami </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classTelegram_1_1TelegramBot.html">Telegram::TelegramBot</a> *&#160;</td>
<td class="paramname"><em>tg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="namespaceTelegram.html#a97c1241696e3250bf462adae6b65a563">Telegram::TCommandLine</a>&#160;</td>
<td class="paramname"><em>args</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="example01_8cc_source.html#l00100">100</a> of file <a class="el" href="example01_8cc_source.html">example01.cc</a>.</p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_c1e5849d565b56fca2010f6d30d9464c.html">examples</a></li><li class="navelem"><a class="el" href="example01_8cc.html">example01.cc</a></li>
<li class="footer">Generated on Sun Jun 4 2017 13:31:53 for LibTgBotPP by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
</ul>
</div>
</body>
</html>