diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b168db..fbe8da4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +# [9.6.1] - 2021-07-24 +### fixed setMyCommands +- fix - [#192](https://github.com/windkh/node-red-contrib-telegrambot/issues/192) + # [9.6.0] - 2021-07-21 ### you can choose a language for your command registration now. - new - [#189](https://github.com/windkh/node-red-contrib-telegrambot/issues/189) diff --git a/package.json b/package.json index adb9dab..1417121 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-telegrambot", - "version": "9.6.0", + "version": "9.6.1", "description": "Telegram bot nodes for Node-RED", "dependencies": { "bluebird": "^3.5.1", diff --git a/telegrambot/99-telegrambot.js b/telegrambot/99-telegrambot.js index 6104734..8fcb020 100644 --- a/telegrambot/99-telegrambot.js +++ b/telegrambot/99-telegrambot.js @@ -536,10 +536,12 @@ module.exports = function (RED) { }; self.commands.push(commandInfo); - if (!self.commandsByLanguage[language]) { - self.commandsByLanguage[language] = []; + if (language !== undefined) { + if (!self.commandsByLanguage[language]) { + self.commandsByLanguage[language] = []; + } + self.commandsByLanguage[language].push(commandInfo); } - self.commandsByLanguage[language].push(commandInfo); }; this.isCommandRegistered = function (command) { @@ -969,9 +971,9 @@ module.exports = function (RED) { RED.nodes.createNode(this, config); let node = this; let command = config.command; - let description = config.description; let registerCommand = config.registercommand; + let description = config.description || ''; let language = config.language || ''; let scope = config.scope || 'default'; @@ -999,6 +1001,11 @@ module.exports = function (RED) { this.config = RED.nodes.getNode(this.bot); if (this.config) { + // If the command should not be registered, then we invalidate the language. + if (!registerCommand) { + language = undefined; + } + this.config.registerCommand(command, description, language, scope, registerCommand); node.status({ fill: 'red', shape: 'ring', text: 'not connected' });