freifunk-bot

Modular parser for the hackerspace door status with handlers for multiple services
git clone git://archive.git.mtrnord.blog/MTRNord/freifunk-bot.git
Log | Files | Refs | README | LICENSE

commit 8882b1678362f4696bc6fe968818eb87d89996fc
parent 1f8c9a6d6238680e09ca89bb7e51ed8a8c62ce36
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sun, 11 Sep 2016 20:20:59 +0200

fix command detection

Diffstat:
Mhandlers/irc.js | 7+++++--
Mhandlers/parseNodes.js | 21+++++++++++----------
2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/handlers/irc.js b/handlers/irc.js @@ -80,7 +80,7 @@ _.find(params_config["servers"], function (key) { autoConnect: false, messageSplit: 1000000, floodProtection: true, - floodProtectionDelay: 1000 + floodProtectionDelay: 200 }); clients.push(bot[key]); } @@ -301,7 +301,7 @@ module.exports = { } }, node: function (callback) { - if (S(message).contains("!node")) { + if (S(message).contains("!node") || !S(message).contains("!nodes")) { jsonfile.readFile('handlers/tmp/communities.json', 'utf8', function (err,obj) { if (err) {throw new Error(err);} var communities = obj @@ -309,6 +309,9 @@ module.exports = { var ccode = key["ccode"]; if (ccode.toLowerCase() === channel[1]) { clients.forEach(function(client) { + if (channel[2] == undefined) { + channel[2] = "NoArg" + } getNodes.NodeInfo(channel[1], channel[2].toLowerCase(), "irc", "", "", "", client, "", from) }); } diff --git a/handlers/parseNodes.js b/handlers/parseNodes.js @@ -168,16 +168,17 @@ module.exports = { } } }); - - if(handler == "telegram"){ - bot.sendMessage(TfromId, output, {"parse_mode": "HTML"}) - botan.track(Tmsg, 'node ' + ccode_func) - } - if(handler == "irc"){ - bot.say(IRCto, output); - } - if(handler == "slack"){ - slack.slackSend(Schannel, output); + if (askedNode.toLowerCase() !== "noarg") { + if(handler == "telegram"){ + bot.sendMessage(TfromId, output, {"parse_mode": "HTML"}) + botan.track(Tmsg, 'node ' + ccode_func) + } + if(handler == "irc"){ + bot.say(IRCto, output); + } + if(handler == "slack"){ + slack.slackSend(Schannel, output); + } } }else{ /**