Skip to content

Commit

Permalink
fixed #192
Browse files Browse the repository at this point in the history
  • Loading branch information
windkh committed Jul 24, 2021
1 parent 1ccfa3d commit 98044e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 11 additions & 4 deletions telegrambot/99-telegrambot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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' });
Expand Down

0 comments on commit 98044e6

Please sign in to comment.