telegram-bot-bash/DIST/telegram-bot-bash/html/6_reference.html
Kay Marquardt (Gnadelwartz) 405276bbbc fix misspellings
2019-05-30 12:14:23 +02:00

454 lines
40 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title>Bashobot Documentation - doc/6_reference.html</title>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>
</head>
<body>
<div id="header">
<h1 class="title">Bashobot Documentation - doc/6_reference.html</h1>
</div>
<h4 id="home"><a href="../README.html">Home</a></h4>
<h2 id="bashbot-function-reference">Bashbot function reference</h2>
<h3 id="send-forward-delete-messages">Send, forward, delete messages</h3>
<h5 id="send_action">send_action</h5>
<p><code>send_action</code> shows users what your bot is currently doing.</p>
<p><em>usage:</em> send_action “${CHAT[ID]}” “action”</p>
<p><em>“action”:</em> <code>typing</code>, <code>upload_photo</code>, <code>record_video</code>, <code>upload_video</code>, <code>record_audio</code>, <code>upload_audio</code>, <code>upload_document</code>, <code>find_location</code>.</p>
<p><em>alias:</em> _action “action”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">send_action</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;typing&quot;</span>
<span class="ex">send_action</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;record_audio&quot;</span></code></pre></div>
<h5 id="send_normal_message">send_normal_message</h5>
<p><code>send_normal_message</code> sends text only messages to the given chat.</p>
<p><em>usage:</em> send_normal_message “${CHAT[ID]}” “message”</p>
<p><em>alias:</em> _normal_message “message”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;this is a text message&quot;</span></code></pre></div>
<h5 id="send_markdown_message">send_markdown_message</h5>
<p><code>send_markdown_message</code> sends markdown style messages to the given chat. Telegram supports a <a href="https://core.telegram.org/bots/api#markdown-style">reduced set of Markdown</a> only</p>
<p><em>usage:</em> send_markdown_message “${CHAT[ID]}” “markdown message”</p>
<p><em>alias:</em> _markdown “message”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">send_markdown_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;this is a markdown message, next word is *bold*&quot;</span>
<span class="ex">send_markdown_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;*bold* _italic_ [text](link)&quot;</span></code></pre></div>
<h5 id="send_html_message">send_html_message</h5>
<p><code>send_html_message</code> sends HTML style messages to the given chat. Telegram supports a <a href="https://core.telegram.org/bots/api#html-style">reduced set of HTML</a> only</p>
<p><em>usage:</em> send_html_message “${CHAT[ID]}” “html message”</p>
<p><em>alias:</em> _html_message “message”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;this is a markdown message, next word is &lt;b&gt;bold&lt;/b&gt;&quot;</span>
<span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;&lt;b&gt;bold&lt;/b&gt; &lt;i&gt;italic&gt;&lt;i&gt; &lt;em&gt;italic&gt;/em&gt; &lt;a href=&quot;</span>link<span class="st">&quot;&gt;Text&lt;/a&gt;&quot;</span></code></pre></div>
<h5 id="forward_message">forward_message</h5>
<p><code>forward_mesage</code> forwards a messsage to the given chat.</p>
<p><em>usage:</em> forward_message “chat_to” “chat_from” “${MESSAGE[ID]}”</p>
<p><em>old call:</em> forward “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>FROMCHAT” “${MESSAGE[ID]}”</p>
<p><em>alias:</em> _forward “<span class="math inline">$FROMCHAT&quot; &quot;$</span>{MESSAGE[ID]}”</p>
<p>See also <a href="https://core.telegram.org/bots/api#formatting-options">Text formating options</a></p>
<hr />
<h5 id="delete_message">delete_message</h5>
<p>If your Bot is admin of a Chat he can delete every message, if not he can delete only his messages.</p>
<p><em>usage:</em> delete_message “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{MESSAGE[ID]}”</p>
<p><em>alias:</em> _del_message “${MESSAGE[ID]}”</p>
<p>See also <a href="https://core.telegram.org/bots/api#deletemessage">deleteMessage limitations</a></p>
<hr />
<h5 id="send_message">send_message</h5>
<p><code>send_message</code> sends any type of message to the given chat. Type of output is steered by keywords within the message.</p>
<p>The main use case for send_message is to process the output of interactive chats and background jobs. <strong>For regular Bot commands I recommend using of the dedicated send_xxx_message() functions from above.</strong></p>
<p><em>usage:</em> send_message “${CHAT[ID]}” “message”</p>
<p><em>example:</em> - see <a href="2_usage.md#send_message">Usage</a> and <a href="3_advanced.html">Advanced Usage</a></p>
<hr />
<h3 id="file-location-venue-keyboard">File, Location, Venue, Keyboard</h3>
<h5 id="send_file">send_file</h5>
<p>send_file allows you to send different types of files, e.g. photos, stickers, audio, media, etc. <a href="https://core.telegram.org/bots/api#sending-files">see more</a></p>
<p>Starting with version 0.80 send_file implements the following rules:</p>
<ul>
<li>file names must not contain “..”</li>
<li>file names must not start with “.”</li>
<li>file names not starting wit “/” are realtive to $TMPDIR, e.g. ./data-bot-bash</li>
<li>abolute filenames must match $FILE_REGEX</li>
</ul>
<p><em>usage:</em> send_file “${CHAT[ID]}” “file” “caption”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">send_file</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;/home/user/doge.jpg&quot;</span> <span class="st">&quot;Lool&quot;</span>
<span class="ex">send_file</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;https://www.domain,com/something.gif&quot;</span> <span class="st">&quot;Something&quot;</span></code></pre></div>
<h5 id="send_location">send_location</h5>
<p><em>usage:</em> send_location “${CHAT[ID]}” “Latitude” “Longitude”</p>
<h5 id="send_venue">send_venue</h5>
<p><em>usage:</em> send_venue “${CHAT[ID]}” “Latitude” “Longitude” “Title” “Address” “foursquare id (optional)”</p>
<hr />
<h5 id="send_keyboard">send_keyboard</h5>
<p>Note: since version 0.6 send_keyboard was changed to use native “JSON Array” notation as used from Telegram. Example Keybord Array definitions:</p>
<ul>
<li>yes no in two rows:
<ul>
<li>OLD format: yes no (two strings)</li>
<li>NEW format: [ “yes” ] , [ “no” ] (two arrays with a string)</li>
</ul></li>
<li>new layouts made easy with NEW format:
<ul>
<li>Yes No in one row: [ “yes” , “no” ]</li>
<li>Yes No plus Maybe in 2.row: [ “yes” , “no” ] , [ “maybe” ]</li>
<li>numpad style keyboard: [ “1” , “2” , “3” ] , [ “4” , “5” , “6” ] , [ “7” , “8” , “9” ] , [ “0” ]</li>
</ul></li>
</ul>
<p><em>usage:</em> send_keyboard “chat-id” “message” “keyboard”</p>
<p><em>alias:</em> _keyboard “message” “keyboard”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">send_keyboard</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;Say yes or no&quot;</span> <span class="st">&quot;[ </span><span class="dt">\\</span><span class="st">&quot;</span>yes<span class="dt">\&quot;</span> , <span class="dt">\\</span><span class="st">&quot;no</span><span class="dt">\&quot;</span><span class="st"> ]&quot;&quot;</span>
<span class="st">send_keyboard &quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot; &quot;</span>Say yes or no<span class="st">&quot; &quot;</span>[ <span class="dt">\\</span><span class="st">&quot;yes</span><span class="dt">\\</span><span class="st">&quot;</span> ] , [ <span class="dt">\\</span><span class="st">&quot;no</span><span class="dt">\\</span><span class="st">&quot;</span> ]<span class="st">&quot;</span>
<span class="st">send_keyboard &quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot; &quot;</span>Enter digit<span class="st">&quot; &quot;</span>[ <span class="dt">\\</span><span class="st">&quot;1</span><span class="dt">\\</span><span class="st">&quot;</span> , <span class="dt">\\</span><span class="st">&quot;2</span><span class="dt">\\</span><span class="st">&quot;</span> , <span class="dt">\\</span><span class="st">&quot;3</span><span class="dt">\\</span><span class="st">&quot;</span> ] , [ <span class="dt">\\</span><span class="st">&quot;4</span><span class="dt">\\</span><span class="st">&quot;</span> , <span class="dt">\\</span><span class="st">&quot;5</span><span class="dt">\\</span><span class="st">&quot;</span> , <span class="dt">\\</span><span class="st">&quot;6</span><span class="dt">\\</span><span class="st">&quot;</span> ] , [ <span class="dt">\\</span><span class="st">&quot;7</span><span class="dt">\\</span><span class="st">&quot;</span> , <span class="dt">\\</span><span class="st">&quot;8</span><span class="dt">\\</span><span class="st">&quot;</span> , <span class="dt">\\</span><span class="st">&quot;9</span><span class="dt">\\</span><span class="st">&quot;</span> ] , [ <span class="dt">\\</span><span class="st">&quot;0</span><span class="dt">\\</span><span class="st">&quot;</span> ]<span class="st">&quot;</span></code></pre></div>
<h5 id="remove_keyboard">remove_keyboard</h5>
<p><em>usage:</em> remove_keybord “$CHAT[ID]” “message”</p>
<p><em>alias:</em> _del_keyboard “message”</p>
<p><em>See also: <a href="https://core.telegram.org/bots/api/#replykeyboardmarkup">Keyboard Markup</a></em></p>
<hr />
<h5 id="send_button">send_button</h5>
<p><em>usage:</em> send_button “chat-id” “message” “text” “URL”</p>
<p><em>alias:</em> _button “text” “URL”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">send_button</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;MAKE MONEY FAST!!!&quot;</span> <span class="st">&quot;Visit my Shop&quot;</span> <span class="st">&quot;https://dealz.rrr.de&quot;</span></code></pre></div>
<h5 id="send_inline_keyboard">send_inline_keyboard</h5>
<p>This allows to place multiple inline buttons in a row. The inline buttons must specified as a JSON array in the following format:</p>
<p><code>[ {&quot;text&quot;:&quot;text1&quot;, &quot;url&quot;:&quot;url1&quot;}, ... {&quot;text&quot;:&quot;textN&quot;, &quot;url&quot;:&quot;urlN&quot;} ]</code></p>
<p>Each button consists of a pair of text and URL values, sourrounded by { }, multiple buttons are seperated by <strong>,</strong> and everthing is wrapped in [ ].</p>
<p><em>usage:</em> send_inline_keyboard “chat-id” “message” “[ {“text”:“text”, “url”:“url”} …]”</p>
<p><em>alias:</em> _inline_keyboard “[{“text”:“text”, “url”:“url”} …]”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">send_inline_keyboard</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;MAKE MONEY FAST!!!&quot;</span> <span class="st">&#39;[{&quot;text&quot;:&quot;Visit my Shop&quot;, url&quot;&quot;:&quot;https://dealz.rrr.de&quot;}]&#39;</span>
<span class="ex">send_inline_keyboard</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;&quot;</span> <span class="st">&#39;[{&quot;text&quot;:&quot;button 1&quot;, url&quot;&quot;:&quot;url 1&quot;}, {&quot;text&quot;:&quot;button 2&quot;, url&quot;&quot;:&quot;url 2&quot;} ]&#39;</span>
<span class="ex">send_inline_keyboard</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;&quot;</span> <span class="st">&#39;[{&quot;text&quot;:&quot;b 1&quot;, url&quot;&quot;:&quot;u 1&quot;}, {&quot;text&quot;:&quot;b 2&quot;, url&quot;&quot;:&quot;u 2&quot;}, {&quot;text&quot;:&quot;b 2&quot;, url&quot;&quot;:&quot;u 2&quot;} ]&#39;</span></code></pre></div>
<p><em>See also <a href="https://core.telegram.org/bots/api/#inlinekeyboardmarkup">Inline keyboard markup</a></em></p>
<hr />
<h3 id="user-access-control">User Access Control</h3>
<h5 id="kick_chat_member">kick_chat_member</h5>
<p>If your Bot is a chat admin he can kick and ban a user.</p>
<p><em>usage:</em> kick_chat_member “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{USER[ID]}”</p>
<p><em>alias:</em> _kick_user “${USER[ID]}”</p>
<h5 id="unban_chat_member">unban_chat_member</h5>
<p>If your Bot is a chat admine can unban a kicked user.</p>
<p><em>usage:</em> unban_chat_member “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{USER[ID]}”</p>
<p><em>alias:</em> _unban “${USER[ID]}”</p>
<h5 id="leave_chat">leave_chat</h5>
<p>Your Bot will leave the chat.</p>
<p><em>usage:</em> leave_chat “${CHAT[ID]}”</p>
<p><em>alias:</em> _leave</p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">if</span> <span class="ex">_is_admin</span> <span class="kw">;</span> <span class="kw">then</span>
<span class="ex">send_markdown_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;*LEAVING CHAT...*&quot;</span>
<span class="ex">leave_chat</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span>
<span class="kw">fi</span></code></pre></div>
<p>See also <a href="https://core.telegram.org/bots/api/#kickchatmember">kick Chat Member</a>*</p>
<hr />
<h5 id="user_is_botadmin">user_is_botadmin</h5>
<p>Return true (0) if user is admin of bot, user id if botadmin is read from file ./botadmin.</p>
<p><em>usage:</em> user_is_botadmin “${USER[ID]}”</p>
<p><em>alias:</em> _is_botadmin</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"> <span class="ex">_is_botadmin</span> <span class="kw">&amp;&amp;</span> <span class="ex">send_markdown_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;You are *BOTADMIN*.&quot;</span></code></pre></div>
<h5 id="user_is_creator">user_is_creator</h5>
<p>Return true (0) if user is creator of given chat or chat is a private chat.</p>
<p><em>usage:</em> user_is_creator “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{USER[ID]}”</p>
<p><em>alias:</em> _is_creator</p>
<h5 id="user_is_admin">user_is_admin</h5>
<p>Return true (0) if user is admin or creator of given chat.</p>
<p><em>usage:</em> user_is_admin “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{USER[ID]}”</p>
<p><em>alias:</em> _is_admin</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">if</span> <span class="ex">_is_admin</span> <span class="kw">;</span> <span class="kw">then</span>
<span class="ex">send_markdown_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;*LEAVING CHAT...*&quot;</span>
<span class="ex">leave_chat</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span>
<span class="kw">fi</span></code></pre></div>
<p><em>See also <a href="https://core.telegram.org/bots/api/#chatmember">Chat Member</a></em></p>
<h5 id="user_is_allowed">user_is_allowed</h5>
<p>Bahsbot supports User Access Control, see <a href="3_advanced.html">Advanced Usage</a></p>
<p><em>usage:</em> user_is_allowed “<span class="math inline">${USER[ID]}&quot; &quot;what&quot; &quot;$</span>{CHAT[ID]}”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">if</span> ! <span class="ex">user_is_allowed</span> <span class="st">&quot;</span><span class="va">${USER[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;start&quot;</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="kw">;</span> <span class="kw">then</span>
<span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;You are not allowed to start Bot.&quot;</span>
<span class="kw">fi</span></code></pre></div>
<hr />
<h3 id="inline-queries---answer-direct-queries-to-bot">Inline Queries - answer direct queries to bot</h3>
<p>You must include <code>source modules/inline.sh</code> in commands.sh to have the following functions availible.</p>
<p>Inline Queries allows users to interact with your bot directly without sending extra commands. As an answer to an inline query you can send back one or more results to the Telegram client. The Telegram client will then show the results to the user and let him select one.</p>
<h5 id="answer_inline_query">answer_inline_query</h5>
<p>answer_inline_query is provided for backward compatibility with older versions of bashbot. It send back only one response to an inline query.</p>
<p><em>usage:</em> answer_inline_query “$i{QUERY[ID]}” “type” “type arg 1” … “type arg n”</p>
<p><em>example:</em> - see <a href="3_advanced.html">Advanced Usage</a></p>
<h5 id="answer_inline_multi">answer_inline_multi</h5>
<p>anser_inline_multi allows you to send back a list of responses. responses must be seperated by ,.</p>
<p><em>usage:</em> answer_inline_multi “${iQUERY[ID]}” “res, res, … res”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="co"># note the starting &quot; and ending &quot; !!</span>
<span class="ex">answer_inline_multi</span> <span class="st">&quot;</span><span class="va">${iQUERY[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;</span>
<span class="st"> </span><span class="va">$(</span><span class="ex">inline_query_compose</span> <span class="st">&quot;1&quot;</span> <span class="st">&quot;photo&quot;</span> <span class="st">&quot;https://avatars0.githubusercontent.com/u/13046303&quot;</span><span class="va">)</span><span class="st"> ,</span>
<span class="st"> ...</span>
<span class="st"> </span><span class="va">$(</span><span class="ex">inline_query_compose</span> <span class="st">&quot;n&quot;</span> <span class="st">&quot;photo&quot;</span> <span class="st">&quot;https://avatars1.githubusercontent.com/u/4593242&quot;</span><span class="va">)</span>
<span class="st"> &quot;</span></code></pre></div>
<h4 id="inline_query_compose">inline_query_compose</h4>
<p>inline_query_compose composes one response element to to send back.</p>
<p><em>usage:</em> inline_query_compose ID type args ….</p>
<pre><code> ID = unique ID for this response, 1-64 byte long
type = type of answer, e.g. article, photo, video, location ...
args = mandatory arguments in the order they are described in telegram documentation</code></pre>
<p>Currently the following types and arguments are implemented (optional arguments in parenthesis)</p>
<pre><code> &quot;article&quot;|&quot;message&quot; title message (markup description)
&quot;photo&quot; photo_URL (thumb_URL title description caption)
&quot;gif&quot; photo_URL (thumb_URL title caption)
&quot;mpeg4_gif&quot; mpeg_URL (thumb_URL title caption)
&quot;video&quot; video_URL mime_type thumb_URL title (caption)
&quot;audio&quot; audio_URL title (caption)
&quot;voice&quot; voice_URL title (caption)
&quot;document&quot; title document_URL mime_type (caption description)
&quot;location&quot; latitude longitude title
&quot;venue&quot; latitude longitude title (adress foursquare)
&quot;contact&quot; phone first (last thumb)
&quot;cached_photo&quot; file (title description caption)
&quot;cached_gif&quot; file (title caption)
&quot;cached_mpeg4_gif&quot; file (title caption)
&quot;cached_sticker&quot; file
&quot;cached_document&quot; title file (description caption)
&quot;cached_video&quot; file title (description caption)
&quot;cached_voice&quot; file title (caption)
&quot;cached_audio&quot; file title (caption)</code></pre>
<p>see <a href="https://core.telegram.org/bots/api#inlinequeryresult">InlineQueryResult for more information</a> about response types and their arguments.</p>
<hr />
<h3 id="background-and-interactive-jobs">Background and Interactive jobs</h3>
<p>You must include <code>source modules/background.sh</code> in commands.sh to have the following functions availible.</p>
<h5 id="start_proc">start_proc</h5>
<p><code>startproc</code> starts a script, the output of the script is sent to the user or chat, user input will be sent back to the script. see <a href="3_advanced.html">Advanced Usage</a></p>
<p><em>usage:</em> start_proc “${CHAT[ID]}” “script”</p>
<p><em>alias:</em> startproc “script”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">startproc</span> <span class="st">&#39;examples/calc.sh&#39;</span></code></pre></div>
<h5 id="check_proc">check_proc</h5>
<p>Return true (0) if an interactive script is running in the chat.</p>
<p><em>usage:</em> check_prog “${CHAT[ID]}”</p>
<p><em>alias:</em> checkprog</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">if</span> ! <span class="ex">check_proc</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="kw">;</span> <span class="kw">then</span>
<span class="ex">startproc</span> <span class="st">&quot;examples/calc.sh&quot;</span>
<span class="kw">else</span>
<span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;Calc already running ...&quot;</span>
<span class="kw">fi</span></code></pre></div>
<h5 id="kill_proc">kill_proc</h5>
<p>Kill the interactive script running in the chat</p>
<p><em>usage:</em> kill_proc “${CHAT[ID]}”</p>
<p><em>alias:</em> killproc</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">if</span> <span class="ex">check_proc</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="kw">;</span> <span class="kw">then</span>
<span class="ex">killproc</span> <span class="kw">&amp;&amp;</span> <span class="ex">send_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;Command canceled.&quot;</span>
<span class="kw">else</span>
<span class="ex">send_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;Command is not running.&quot;</span>
<span class="kw">fi</span></code></pre></div>
<hr />
<h5 id="start_back">start_back</h5>
<p>Starts a script as a background job and attaches a jobname to it. All output from a background job is sent to the associated chat.</p>
<p>In contrast to interactive chats, background jobs do not recieve user input and can run forever. In addition you can suspend and restart running jobs, e.g. after reboot.</p>
<p><em>usage:</em> start_back “${CHAT[ID]}” “script” “jobname”</p>
<p><em>alias:</em> background “script” “jobname”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">background</span> <span class="st">&quot;examples/notify.sh&quot;</span> <span class="st">&quot;notify&quot;</span></code></pre></div>
<h5 id="check_back">check_back</h5>
<p>Return true (0) if an background job is active in the given chat.</p>
<p><em>usage:</em> check_back “${CHAT[ID]}” “jobname”</p>
<p><em>alias:</em> checkback “jobname”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="kw">if</span> ! <span class="ex">checkback</span> <span class="st">&quot;notify&quot;</span> <span class="kw">;</span> <span class="kw">then</span>
<span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;Start notify&quot;</span>
<span class="ex">background</span> <span class="st">&quot;examples/notify.sh&quot;</span> <span class="st">&quot;notify&quot;</span>
<span class="kw">else</span>
<span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;Process notify already running.&quot;</span>
<span class="kw">fi</span></code></pre></div>
<h5 id="kill_back">kill_back</h5>
<p><em>usage:</em> kill_back “${CHAT[ID]}” “jobname”</p>
<p><em>alias:</em> killback “jobname”</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">checkback</span> <span class="st">&quot;notify&quot;</span>
<span class="kw">if</span><span class="bu"> [</span> <span class="st">&quot;</span><span class="va">$res</span><span class="st">&quot;</span> <span class="ot">-eq</span> 0<span class="bu"> ]</span> ; <span class="kw">then</span>
<span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;Kill notify&quot;</span>
<span class="ex">killback</span> <span class="st">&quot;notify&quot;</span>
<span class="kw">else</span>
<span class="ex">send_normal_message</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;Process notify not run.&quot;</span>
<span class="kw">fi</span></code></pre></div>
<hr />
<h5 id="send_interactive">send_interactive</h5>
<p>Form version 0.80 on forward_message is used to forward messages to interactive job. It replaces the old inproc commands used for TMUX. Usually message is automatically forwarded in commands.sh, but you can forward messages wihle processing also or send your own messages.</p>
<p><em>usage:</em> send_interactive “${CHAT[ID]}” “message”</p>
<p><em>replaces:</em> incproc</p>
<h3 id="aliases---shortcuts-for-often-used-funtions">Aliases - shortcuts for often used funtions</h3>
<p>You must include <code>source modules/aliases.sh</code> in commands.sh to have the following functions availible.</p>
<h5 id="is_botadmin">_is_botadmin</h5>
<p><em>usage:</em> _is_botadmin</p>
<p><em>alias for:</em> user_is_botadmin “${USER[ID]}”</p>
<h5 id="is_admin">_is_admin</h5>
<p><em>usage:</em> _is_admin</p>
<p><em>alias for:</em> user_is_admin “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{USER[ID]}”</p>
<h5 id="is_allowed">_is_allowed</h5>
<p><em>usage:</em> _is_allowed “what”</p>
<p><em>alias for:</em> user_is_allowed “<span class="math inline">${USER[ID]}&quot; &quot;what&quot; &quot;$</span>{CHAT[ID]}”</p>
<hr />
<h5 id="kick_user">_kick_user</h5>
<p><em>usage:</em> _kick_user “${USER[ID]}”</p>
<p><em>alias for:</em> kick_chat_member “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{USER[ID]}”</p>
<h5 id="unban">_unban</h5>
<p><em>usage:</em> _unban “${USER[ID]}”</p>
<p><em>alias for:</em> unban_chat_member “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{USER[ID]}”</p>
<h5 id="leave">_leave</h5>
<p><em>usage:</em> _leave</p>
<p><em>alias for:</em> leave_chat “${CHAT[ID]}”</p>
<hr />
<h5 id="message">_message</h5>
<p><em>usage:</em> _message “message”</p>
<p><em>alias for:</em> send_normal_message “${CHAT[ID]}” “message”</p>
<h5 id="normal_message">_normal_message</h5>
<p><em>usage:</em> _normal_message “message”</p>
<p><em>alias for:</em> send_normal_message “${CHAT[ID]}” “message”</p>
<h5 id="html_message">_html_message</h5>
<p><em>usage:</em> _html_message “message”</p>
<p><em>alias for:</em> send_html_message “${CHAT[ID]}” “message”</p>
<h5 id="markdown_message">_markdown_message</h5>
<p><em>usage:</em> _markdown_message “message”</p>
<p><em>alias for:</em> send_markdown_message “${CHAT[ID]}” “message”</p>
<hr />
<h4 id="inline_button-usage-_inline_button-1-2">_inline_button <em>usage:</em> _inline_button “<span class="math inline">${1}&quot; &quot;$</span>{2}”</h4>
<p><em>alias for:</em> send_inline_button “<span class="math inline">${CHAT[ID]}&quot; &quot;&quot; &quot;$</span>{1}” “${2}”</p>
<h4 id="inline_keyboard-usage-_inline_keyboard-1">_inline_keyboard <em>usage:</em> _inline_keyboard “${1}”</h4>
<p><em>alias for:</em> _inline_keyboard “<span class="math inline">${CHAT[ID]}&quot; &quot;&quot; &quot;$</span>{1}”</p>
<h4 id="keyboard_numpad-usage-_keyboard_numpad">_keyboard_numpad <em>usage:</em> _keyboard_numpad</h4>
<p><em>alias for:</em> send_keyboard “${CHAT[ID]}” “” [“1”,“2”,“3”],[“4”,“5”,“6”],[“7”,“8”,“9”],[“-”,“0”,“.”] “yes”</p>
<h4 id="keyboard_yesno-usage-_keyboard_yesno">_keyboard_yesno <em>usage:</em> _keyboard_yesno</h4>
<p><em>alias for:</em> send_keyboard [“yes”,“no”]</p>
<h4 id="del_keyboard-usage-_del_keyboard">_del_keyboard <em>usage:</em> _del_keyboard</h4>
<p><em>alias for:</em> remove_keyboard “${CHAT[ID]}” “”</p>
<h3 id="helper-functions">Helper functions</h3>
<h5 id="download">download</h5>
<p>Download the fiven URL ans returns the final filename in TMPDIR. If the given filename exists,the filename is prefixed with a random number. filename is not allowed to contain / or ...</p>
<p><em>usage:</em> download URL filename</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="va">file=</span><span class="st">&quot;</span><span class="va">$(</span><span class="ex">download</span> <span class="st">&quot;https://avatars.githubusercontent.com/u/13046303&quot;</span> <span class="st">&quot;avatar.jpg&quot;</span><span class="va">)</span><span class="st">&quot;</span>
<span class="bu">echo</span> <span class="st">&quot;</span><span class="va">$file</span><span class="st">&quot;</span> -<span class="op">&gt;</span> ./data-bot-bash/avatar.jpg
<span class="va">file=</span><span class="st">&quot;</span><span class="va">$(</span><span class="ex">download</span> <span class="st">&quot;https://avatars.githubusercontent.com/u/13046303&quot;</span> <span class="st">&quot;avatar.jpg&quot;</span><span class="va">)</span><span class="st">&quot;</span>
<span class="bu">echo</span> <span class="st">&quot;</span><span class="va">$file</span><span class="st">&quot;</span> -<span class="op">&gt;</span> ./data-bot-bash/12345-avatar.jpg</code></pre></div>
<h5 id="exists-returns-true-if-the-given-function-exist-can-be-used-to-check-if-a-module-is-loaded.">_exists Returns true if the given function exist, can be used to check if a module is loaded.</h5>
<p><em>usage</em> _exists command</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">_exists</span> <span class="st">&quot;curl&quot;</span> <span class="kw">&amp;&amp;</span> <span class="ex">_message</span> <span class="st">&quot;Command curl is not installed!&quot;</span></code></pre></div>
<h5 id="is_function-returns-true-if-the-given-function-exist-can-be-used-to-check-if-a-module-is-loaded.">_is_function Returns true if the given function exist, can be used to check if a module is loaded.</h5>
<p><em>usage</em> _is_function function</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">_is_function</span> <span class="st">&quot;background&quot;</span> <span class="kw">&amp;&amp;</span> <span class="ex">_message</span> <span class="st">&quot;you can run background jobs!&quot;</span></code></pre></div>
<hr />
<h3 id="bashbot-internal-functions">Bashbot internal functions</h3>
<p>These functions are for internal use only and must not used in your bot commands.</p>
<h5 id="procname">procname</h5>
<p>Returns PrefixBotname_Postfix</p>
<p><em>usage:</em> procname postfix prefix</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="co"># returns botname, if already set</span>
<span class="ex">procname</span>
<span class="co"># returns unique identifier for everthing related to chat</span>
<span class="ex">procname</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span>
<span class="co"># returns unique identifier for job, regardless of chat</span>
<span class="ex">procname</span> <span class="st">&quot;&quot;</span> <span class="st">&quot;back-jobname-&quot;</span>
<span class="co"># returns unique identifier for a job related to a chat</span>
<span class="co"># e.g. fifo, cmd and logfile name</span>
<span class="ex">procname</span> <span class="st">&quot;</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span> <span class="st">&quot;back-jobname-&quot;</span></code></pre></div>
<h5 id="proclist">proclist</h5>
<p>Returns process IDs of current bot processes containing string pattern in name or argument.</p>
<p><em>usage:</em> proclist pattern</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="co"># list PIDs of all background processes</span>
<span class="ex">proclist</span> <span class="st">&quot;back-&quot;</span>
<span class="co"># list PIDs of all processes of a job</span>
<span class="ex">proclist</span> <span class="st">&quot;back-jobname-&quot;</span>
<span class="co"># list PIDs of all processes for a chat</span>
<span class="ex">proclist</span> <span class="st">&quot;_</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span>
<span class="co"># list PIDs of all bot processes</span>
<span class="ex">proclist</span> </code></pre></div>
<h5 id="killallproc">killallproc</h5>
<p>kill all current bot processes containing string pattern in name or argument</p>
<p><em>usage:</em> killallproc pattern</p>
<p><em>example:</em></p>
<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="co"># kill all background processes</span>
<span class="ex">killallproc</span> <span class="st">&quot;back-&quot;</span>
<span class="co"># kill all processes for a chat</span>
<span class="ex">killallproc</span> <span class="st">&quot;_</span><span class="va">${CHAT[ID]}</span><span class="st">&quot;</span>
<span class="co"># kill all bot processes, including YOURSELF!</span>
<span class="ex">killallproc</span> </code></pre></div>
<h5 id="get_file">get_file</h5>
<p><em>usage:</em> url=“<span class="math inline">$(get_file &quot;$</span>{CHAT[ID]}” “message”)&quot;</p>
<hr />
<h5 id="send_text">send_text</h5>
<p><em>usage:</em> send_text “${CHAT[ID]}” “message”</p>
<hr />
<h5 id="jsondecode">JsonDecode</h5>
<p>Outputs decoded string to STDOUT</p>
<p><em>usage:</em> JsonDecode “string”</p>
<h5 id="jsongetstring">JsonGetString</h5>
<p>Reads JSON fro STDIN and Outputs found String to STDOUT</p>
<p><em>usage:</em> JsonGetString <code>&quot;path&quot;,&quot;to&quot;,&quot;string&quot;</code></p>
<h5 id="jsongetvalue">JsonGetValue</h5>
<p>Reads JSON fro STDIN and Outputs found Value to STDOUT</p>
<p><em>usage:</em> JsonGetValue <code>&quot;path&quot;,&quot;to&quot;,&quot;value&quot;</code></p>
<hr />
<h5 id="get_chat_member_status">get_chat_member_status</h5>
<p><em>usage:</em> get_chat_member_status “<span class="math inline">${CHAT[ID]}&quot; &quot;$</span>{USER[ID]}”</p>
<p>this may get an official function …</p>
<hr />
<h5 id="process_client">process_client</h5>
<p>Every Message sent to your Bot is processd by this function. It parse the send JSON and assign the found Values to bash variables.</p>
<h5 id="process_updates">process_updates</h5>
<p>If new updates are availible, this functions gets the JSON from Telegram and dispatch it.</p>
<hr />
<h5 id="getbotname">getBotName</h5>
<p>The name of your bot is availible as bash variable “$ME”, there is no need to call this function if Bot is running.</p>
<p><em>usage:</em> ME=“$(getBotNiname)”</p>
<h4 id="prev-best-practice"><a href="5_practice.html">Prev Best Practice</a></h4>
<h4 id="next-notes-for-developers"><a href="7_develop.html">Next Notes for Developers</a></h4>
<h4 id="version-v0.90-dev2-0-gec85636"><br /><span class="math display"><em>V</em><em>E</em><em>R</em><em>S</em><em>I</em><em>O</em><em>N</em></span><br /> v0.90-dev2-0-gec85636</h4>
</body>
</html>