vvlad1973-telegram-framework
Version:
Current version: *7.9.5*
120 lines (93 loc) • 3.38 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: bot_commands.js</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">Source: bot_commands.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>'use strict'
/**
* @module bot_commands
*/
/**
* @typedef {Object} module:bot_commands.BotCommand
* @property {string} command
* @property {string} description
*/
/**
* @class Implements structure for operations with Telegram bot's commands
* @extends {Array}
*/
class BotCommandsArray extends Array {
/**
* @returns {module:bot_commands.BotCommand[]}
*/
constructor() {
super();
}
/**
* Method which adds command to bot's commands array
*
* @param {string} command
* @param {string} description
*
* @returns {number|boolean} - If success - length of commands array,
* if fail - false
*/
addCommand(command, description) {
if (!this.isExistsCommand(command)) {
this.push({ command: command, description: description });
return this.length;
} else {
return false;
}
}
/**
* Method which checks exist some command in commands' array
*
* @param {string} command
* @returns {boolean}
*/
isExistsCommand(command) {
return this.find(item => item.command === command);
}
/**
* Method which deletes some command from command's array
*
* @param {string} command
*/
deleteCommand(command) {
this.filter((item, index, array) => {
if (item.command === command) {
array.splice(index, 1);
}
})
}
}
export default BotCommandsArray;
</code></pre>
</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>