Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
})
this.receive(new TextMessage(user, text, message.message.message_id))
// Join event
} else if (message.new_chat_member) {
user = this.createUser(message.new_chat_member, message.chat)
this.robot.logger.info(`User ${user.id} joined chat ${message.chat.id}`)
this.receive(new EnterMessage(user, null, message.message_id))
// Exit event
} else if (message.left_chat_member) {
user = this.createUser(message.left_chat_member, message.chat)
this.robot.logger.info(`User ${user.id} left chat ${message.chat.id}`)
this.receive(new LeaveMessage(user, null, message.message_id))
// Chat topic event
} else if (message.new_chat_title) {
user = this.createUser(message.from, message.chat)
this.robot.logger.info(`User ${user.id} changed chat ${message.chat.id} title: ${message.new_chat_title}`)
this.receive(new TopicMessage(user, message.new_chat_title, message.message_id))
} else {
message.user = this.createUser(message.from, message.chat)
this.receive(new CatchAllMessage(message))
}
}
userRemoved(msg) {
// update channels when this bot is removed from a channel
if (msg.broadcast.user_id === this.self.id) {
this.client.loadChannels();
}
try {
const mmUser = this.client.getUserByID(msg.data.user_id);
const user = this.robot.brain.userForId(mmUser.id);
user.room = msg.broadcast.channel_id;
this.receive(new LeaveMessage(user));
return true;
} catch (error) {
return false;
}
}
return new Promise(resolve => {
userParams.room = this.name;
const user = new Hubot.User(userName, userParams);
this.robot.receive(new Hubot.LeaveMessage(user), resolve);
});
}