Skip to content

Commit

Permalink
fixed #168
Browse files Browse the repository at this point in the history
  • Loading branch information
windkh committed Apr 7, 2021
1 parent aba65e4 commit 7519e72
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

# [9.1.1] - 2021-04-07
# [9.2.1] - 2021-04-07
### exception in event node.
- fixed - [#168](https://github.com/windkh/node-red-contrib-telegrambot/issues/168)

# [9.1.2] - 2021-04-07
### refactored status events

# [9.0.0] - 2021-04-03
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.1.2",
"version": "9.2.1",
"description": "Telegram bot nodes for Node-RED",
"dependencies": {
"bluebird": "^3.5.1",
Expand Down
21 changes: 17 additions & 4 deletions telegrambot/99-telegrambot.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,20 @@ module.exports = function (RED) {
if (self.config.chatids === '' && self.config.usernames === '') {
isAuthorized = true;
} else {
let isAuthorizedUser = self.isAuthorizedUser(node, user);
let isAuthorizedChatId = self.isAuthorizedChat(node, chatid);
let isAuthorizedUserId = self.isAuthorizedChat(node, userid);
let isAuthorizedUser = false;
if (user !== undefined) {
isAuthorizedUser = self.isAuthorizedUser(node, user);
}

let isAuthorizedChatId = false;
if (chatid !== undefined) {
isAuthorizedChatId = self.isAuthorizedChat(node, chatid);
}

let isAuthorizedUserId = false;
if (userid !== undefined) {
isAuthorizedUserId = self.isAuthorizedChat(node, userid);
}

if (isAuthorizedUser || isAuthorizedChatId || isAuthorizedUserId) {
isAuthorized = true;
Expand Down Expand Up @@ -1140,7 +1151,9 @@ module.exports = function (RED) {
//channel
username = botMsg.chat.username;
chatid = botMsg.chat.id;
userid = botMsg.from.id;
if (botMsg.from !== undefined) {
userid = botMsg.from.id;
}
} else if (botMsg.from) {
//private, group, supergroup
chatid = botMsg.message.chat.id;
Expand Down

0 comments on commit 7519e72

Please sign in to comment.