commit 38a0ec68bb584105f78597ea7e095ff4107707fa
parent 323fa933e9ce44c8de923e8495c72dbc6ebd4a5f
Author: MTRNord <mtrnord1@gmail.com>
Date: Sun, 11 Sep 2016 10:50:37 +0200
Make it pretty for Codeclimate
Diffstat:
5 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
@@ -1,3 +1,4 @@
+[](https://codeclimate.com/github/MTRNord/nordlab-hackerspace-door)
Nordlab Bot
===========
Modular parser for the hackerspace door status with handlers for multiple services and IRC Bot for the Nordlab e.V.
diff --git a/handlers/getNodes.js b/handlers/getNodes.js
@@ -23,7 +23,7 @@ module.exports = {
saveNodes: function () {
request.get('https://cdn.rawgit.com/MTRNord/gluon-web-remote/5d0c3a2c49b79d2971b8b3cc24398d45833ad1c6/configs/communities.json', function (err, res, body) {
- if (!err && res.statusCode == 200) {
+ if (!err && res.statusCode === 200) {
/**
* Content of communities
*
@@ -65,7 +65,7 @@ module.exports = {
var nodesFile_link = key["nodesURL"];
var name = key["name"];
request.get(nodesFile_link, function (err, res, body) {
- if (!err && res.statusCode == 200) {
+ if (!err && res.statusCode === 200) {
/**
* Content of communities
*
@@ -79,12 +79,12 @@ module.exports = {
nodes = JSON.parse(body)
_.find(nodes.nodes, function (key) {
if (key.hasOwnProperty('flags')) {
- if (key["flags"]["online"] == true) {
+ if (key["flags"]["online"] === true) {
count++;
}
}
if (key.hasOwnProperty('status')) {
- if (key["status"]["online"] == true) {
+ if (key["status"]["online"] === true) {
count++;
}
}
diff --git a/handlers/irc.js b/handlers/irc.js
@@ -291,6 +291,7 @@ module.exports = {
nodes: function (callback) {
if (S(message).contains("!nodes")) {
jsonfile.readFile('handlers/tmp/communities.json', 'utf8', function (err,obj) {
+ if (err) {console.log(err)}
var communities = obj
_.find(communities.communities, function (key) {
var ccode = key["ccode"];
@@ -306,6 +307,7 @@ module.exports = {
communities: function (callback) {
if (S(message).contains("!communities")) {
jsonfile.readFile('handlers/tmp/communities.json', 'utf8', function (err,obj) {
+ if (err) {console.log(err)}
var communities = obj
var communities_list = ""
_.find(communities.communities, function (key) {
diff --git a/handlers/slack.js b/handlers/slack.js
@@ -85,11 +85,11 @@ bot.on('message', function(data) {
var textmessage = data["text"];
var channel = data["channel"];
var subtype = data["subtype"];
- if (textmessage != null){
+ if (textmessage === null){}else{
textmessage = textmessage.toLowerCase();
}
_.find(command_config["commands"], function (key) {
- if (subtype != "bot_message"){
+ if (subtype !== "bot_message"){
if (S(textmessage).contains("!" + key["keyword"])) {
bot.postMessage(channel, key["message"], params);
}else {
diff --git a/handlers/telegram.js b/handlers/telegram.js
@@ -1,9 +1,9 @@
var telegram_token = process.env.telegram_api
-if (typeof telegram_token == 'undefined' && !telegram_token) {
+if (typeof telegram_token === 'undefined' && !telegram_token) {
console.log("No Telegram token defined")
}
var botan_token = process.env.botan_api
-if (typeof botan_token == 'undefined' && !botan_token) {
+if (typeof botan_token === 'undefined' && !botan_token) {
console.log("No Botan token defined")
}
var TelegramBot = require('node-telegram-bot-api');
@@ -26,6 +26,7 @@ module.exports = {
var resp = match[1];
bot.sendChatAction(fromId, "typing")
jsonfile.readFile('handlers/tmp/communities.json', 'utf8', function (err,obj) {
+ if (err) {console.log(err)}
var communities = obj
_.find(communities.communities, function (key) {
var ccode = key["ccode"];
@@ -43,6 +44,7 @@ module.exports = {
var resp = match[1];
bot.sendChatAction(fromId, "typing")
jsonfile.readFile('handlers/tmp/communities.json', 'utf8', function (err,obj) {
+ if (err) {console.log(err)}
var communities = obj
var communities_list = ""
_.find(communities.communities, function (key) {