vvlad1973-telegram-framework
Version:
Current version: *7.9.5*
2,042 lines (665 loc) • 38.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: BaseTelegramBot</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: BaseTelegramBot</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="module-base_telegram_bot.html">base_telegram_bot</a>.</span>BaseTelegramBot<span class="signature">(token, options<span class="signature-attributes">opt</span>, defaultParseMode<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="module-base_telegram_bot.BaseTelegramBot.html">module:base_telegram_bot.BaseTelegramBot</a>}</span></h2>
<div class="class-description">Implements Interface to Telegram Bot API</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="BaseTelegramBot"><span class="type-signature"></span>new BaseTelegramBot<span class="signature">(token, options<span class="signature-attributes">opt</span>, defaultParseMode<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="module-base_telegram_bot.BaseTelegramBot.html">module:base_telegram_bot.BaseTelegramBot</a>}</span></h4>
<div class="description">
This object provide access to methods to communicate with
the Telegram
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>token</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">Each bot is given a unique authentication token
when it is created. The token looks something like
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">some optional parameters to pass to
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">HTTPS URL to send updates to. Use an
empty string to remove webhook integration</td>
</tr>
<tr>
<td class="name"><code>secretToken</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">A secret token to be sent in a
header “X-Telegram-Bot-Api-Secret-Token” in every webhook request,
1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed.
The header is useful to ensure that the request comes from a webhook
set by you</td>
</tr>
<tr>
<td class="name"><code>maxConnections</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The maximum allowed number of
simultaneous HTTPS connections to the webhook for update delivery,
1-100. Defaults to 40. Use lower values to limit the load on your
bot's server, and higher values to increase your bot's throughput</td>
</tr>
<tr>
<td class="name"><code>sendByQueue</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">If True the bot will send data to
Telegram by using sending queue of messages</td>
</tr>
<tr>
<td class="name"><code>certificate</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Upload your public key certificate so
that the root certificate in use can be checked. See our self-signed
guide for details
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>file</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">Frilename of the certificate</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>allowedUpdates</code></td>
<td class="type">
<span class="param-type">Array.<string></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">A JSON-serialized list of the
update types you want your bot to receive. For example, specify
[“message”, “edited_channel_post”, “callback_query”] to only receive
updates of these types. See Update for a complete list of available
update types. Specify an empty list to receive all update types except
chat_member (default). If not specified, the previous setting will be
used.
Please note that this parameter doesn't affect updates created before
the call to the setWebhook, so unwanted updates may be received for a
short period of time</td>
</tr>
<tr>
<td class="name"><code>dropPendingUpdates</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Pass True to drop all pending
updates</td>
</tr>
<tr>
<td class="name"><code>ipAddress</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The fixed IP address which will be used
to send webhook requests instead of the IP address resolved through DNS</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>defaultParseMode</code></td>
<td class="type">
<span class="param-type"><a href="module-enums.html#.ParseModes">module:enums.ParseModes</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Default value mode
for parsing messages wchich send by the bot</td>
</tr>
<tr>
<td class="name"><code>options.sender</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Params for the bot's sender which will send
data to Telegram by using sending queue of messages
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>capacityLimit</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Limit of amount of messages
to send during one interval of time. Default value is 30</td>
</tr>
<tr>
<td class="name"><code>capacityInterval</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Duration of one time
interval in milliseconds for message flow control. Default value is 1000</td>
</tr>
<tr>
<td class="name"><code>queueSize</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Limit of size of message queue.
Default value is 10 000</td>
</tr>
<tr>
<td class="name"><code>logger</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Object implemented multilevel logging
routines. If not specified, will use default logger</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<h5 class="subsection-title">Properties:</h5>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="attributes">
</td>
<td class="description last">Read only. Unique identifier for this user or bot. This number
may have more than 32 significant bits and some programming languages
may have difficulty/silent defects in interpreting it. But it has at
most 52 significant bits, so a 64-bit integer or double-precision float
type are safe for storing this identifier</td>
</tr>
<tr>
<td class="name"><code>firstName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">Read only. User's or bot's first name</td>
</tr>
<tr>
<td class="name"><code>username</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Read only. User's or bot's username</td>
</tr>
<tr>
<td class="name"><code>lastName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Read only. User's or bot's last name</td>
</tr>
<tr>
<td class="name"><code>languageCode</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Read only. ETF language tag of the user's language</td>
</tr>
<tr>
<td class="name"><code>canJoinGroups</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Read only. True, if the bot can be invited to
groups</td>
</tr>
<tr>
<td class="name"><code>canReadAllGroupMessages</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Read only. True, if privacy mode is
disabled for the bot</td>
</tr>
<tr>
<td class="name"><code>supportsInlineQueries</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Read only. True, if the bot supports
inline queries</td>
</tr>
<tr>
<td class="name"><code>defaultParseMode</code></td>
<td class="type">
<span class="param-type"><a href="module-enums.html#.ParseModes">module:enums.ParseModes</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Default value mode
for parsing messages wchich send by the bot</td>
</tr>
<tr>
<td class="name"><code>logger</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Object implemented multilevel logging routines. If not
specified, will use default logger</td>
</tr>
<tr>
<td class="name"><code>sender</code></td>
<td class="type">
<span class="param-type">Worker</span>
</td>
<td class="attributes">
</td>
<td class="description last">Read only. The bot's sender which will send data to
Telegram by using sending queue of messages</td>
</tr>
<tr>
<td class="name"><code>sendByQueue</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">If True the bot will send data to
Telegram by using sending queue of messages</td>
</tr>
<tr>
<td class="name"><code>lastMessageId</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="attributes">
</td>
<td class="description last">Read only. ID of the last sent message</td>
</tr>
<tr>
<td class="name"><code>maxConnections</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The maximum allowed number of
simultaneous HTTPS connections to the webhook for update delivery, 1-100.
Defaults to 40. Use lower values to limit the load on your bot's server,
and higher values to increase your bot's throughput</td>
</tr>
<tr>
<td class="name"><code>secretToken</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">A secret token to be sent in a header
“X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256
characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The
header is useful to ensure that the request comes from a webhook set
by you</td>
</tr>
<tr>
<td class="name"><code>certificate</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Upload your public key certificate so
that the root certificate in use can be checked. See our self-signed
guide for details
<h6>Properties</h6>
<table class="props">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>file</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Filename of the certificate</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>allowedUpdates</code></td>
<td class="type">
<span class="param-type">Array.<string></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">A JSON-serialized list of the
update types you want your bot to receive. For example, specify
[“message”, “edited_channel_post”, “callback_query”] to only receive
updates of these types. See Update for a complete list of available
update types. Specify an empty list to receive all update types except
chat_member (default). If not specified, the previous setting will be
used.
Please note that this parameter doesn't affect updates created before
the call to the setWebhook, so unwanted updates may be received for a
short period of time</td>
</tr>
<tr>
<td class="name"><code>dropPendingUpdates</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Pass True to drop all pending
updates</td>
</tr>
<tr>
<td class="name"><code>ipAddress</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The fixed IP address which will be used
to send webhook requests instead of the IP address resolved through DNS</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="base_telegram_bot_base_telegram_bot.js.html">base_telegram_bot/base_telegram_bot.js</a>, <a href="base_telegram_bot_base_telegram_bot.js.html#line118">line 118</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Instance of the
BaseTelegramBot class
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="module-base_telegram_bot.BaseTelegramBot.html">module:base_telegram_bot.BaseTelegramBot</a></span>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="setWebhook"><span class="type-signature"></span>setWebhook<span class="signature">(url<span class="signature-attributes">opt</span>, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
<div class="description">
Use this method to specify a URL and receive incoming updates via an
outgoing webhook. Whenever there is an update for the bot, we will send
an HTTPS POST request to the specified URL, containing a JSON-serialized
Update. In case of an unsuccessful request, we will give up after a
reasonable amount of attempts. Returns True on success.
If you'd like to make sure that the webhook was set by you, you can
specify secret data in the parameter secret_token. If specified, the
request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the
secret token as content
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>url</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">HTTPS URL to send updates to. Use an
empty string to remove webhook integration. Default value is empty
string</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">some optional parameters to pass to
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>secretToken</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">A secret token to be sent in a
header “X-Telegram-Bot-Api-Secret-Token” in every webhook request,
1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed.
The header is useful to ensure that the request comes from a webhook
set by you</td>
</tr>
<tr>
<td class="name"><code>maxConnections</code></td>
<td class="type">
<span class="param-type">integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The maximum allowed number of
simultaneous HTTPS connections to the webhook for update delivery,
1-100. Defaults to 40. Use lower values to limit the load on your
bot's server, and higher values to increase your bot's throughput</td>
</tr>
<tr>
<td class="name"><code>sendByQueue</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">If True the bot will send data to
Telegram by using sending queue of messages</td>
</tr>
<tr>
<td class="name"><code>certificate</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Upload your public key certificate so
that the root certificate in use can be checked. See our self-signed
guide for details
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>file</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">Frilename of the certificate</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>allowedUpdates</code></td>
<td class="type">
<span class="param-type">Array.<string></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">A JSON-serialized list of the
update types you want your bot to receive. For example, specify
[“message”, “edited_channel_post”, “callback_query”] to only receive
updates of these types. See Update for a complete list of available
update types. Specify an empty list to receive all update types except
chat_member (default). If not specified, the previous setting will be
used.
Please note that this parameter doesn't affect updates created before
the call to the setWebhook, so unwanted updates may be received for a
short period of time</td>
</tr>
<tr>
<td class="name"><code>dropPendingUpdates</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Pass True to drop all pending
updates</td>
</tr>
<tr>
<td class="name"><code>ipAddress</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The fixed IP address which will be used
to send webhook requests instead of the IP address resolved through DNS</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="base_telegram_bot_base_telegram_bot.js.html">base_telegram_bot/base_telegram_bot.js</a>, <a href="base_telegram_bot_base_telegram_bot.js.html#line945">line 945</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Response with method executing result
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-base_telegram_bot.html">base_telegram_bot</a></li><li><a href="module-bot_commands.html">bot_commands</a></li><li><a href="module-enums.html">enums</a></li><li><a href="module-inline_keyboard_markup.html">inline_keyboard_markup</a></li><li><a href="module-reply_keyboard_markup.html">reply_keyboard_markup</a></li><li><a href="module-sender.html">sender</a></li></ul><h3>Classes</h3><ul><li><a href="module-base_telegram_bot.BaseTelegramBot.html">BaseTelegramBot</a></li><li><a href="module-bot_commands-BotCommandsArray.html">BotCommandsArray</a></li><li><a href="module-inline_keyboard_markup.InlineKeyboardMarkup.html">InlineKeyboardMarkup</a></li><li><a href="module-reply_keyboard_markup.ReplyKeyboardMarkup.html">ReplyKeyboardMarkup</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Sun Mar 26 2023 20:28:31 GMT+0300 (Москва, стандартное время)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>