commit 607d859cbe8e7d2eb21ef1c7a2fa3baf5586e789
parent 2b00c7439447e04e576511c8f92e713efa502023
Author: Marcel Radzio <marcel@radzio-sh.de>
Date: Wed, 30 Dec 2015 01:08:02 +0100
fix bad commit
Diffstat:
4 files changed, 71 insertions(+), 52 deletions(-)
diff --git a/configs/commands.json b/configs/commands.json
@@ -85,6 +85,12 @@
"message": "- Add ability to do multiple server connections\n- Add SSH Admin Control Server for editing the bot easily",
"argument": "0",
"target": "from"
+ },
+ {
+ "keyword": "xmas",
+ "message": "Der NordlabBot wünscht euch allen eine frohe und besinliche Weihnachtszeit :)",
+ "argument": "0",
+ "target": "to"
}
]
}
diff --git a/configs/params.json b/configs/params.json
@@ -9,7 +9,7 @@
"main_channel": "#hackerspace",
"nickserv_pass": "NordlabBotPass",
"active": 1,
- "debug": 1
+ "debug": 0
}
]
}
\ No newline at end of file
diff --git a/handlers/irc.js b/handlers/irc.js
@@ -25,6 +25,7 @@ for (var key in params_config["servers"]) {
}
*/
+
for (var key in params_config["servers"]) {
if (params_config["servers"].hasOwnProperty(key)) {
var serveraddress = params_config["servers"][key]["serveraddress"];
@@ -36,11 +37,15 @@ for (var key in params_config["servers"]) {
}else{
var debug = false;
}
+ if (debug == false) {
+ console = console || {};
+ console.log = function(){};
+ }
if (active == 1) {
var bot = new irc.Client(serveraddress, botname, {
debug: debug,
- channels: [main_channel],
- autoRejoin: false,
+ channels: [main_channel, "#freifunk-flensburg"],
+ autoRejoin: true,
autoConnect: false,
messageSplit: 1000000
});
@@ -55,7 +60,7 @@ module.exports = {
ircPreload: function () {
bot.addListener('error', function(message) {
setTimeout(function() {
- // console.log("wait 7sek");
+ console.log("wait 7sek");
}, 7000);
bot.send('nick', botname);
@@ -67,7 +72,7 @@ module.exports = {
}
});
setTimeout(function() {
- // console.log("wait 7sek");
+ console.log("wait 7sek");
}, 7000);
bot.connect(10, function() {
bot.send('nick', botname);
@@ -79,7 +84,7 @@ module.exports = {
bot.join(main_channel);
}
}
- //bot.say('#hackerspace', 'Door Bot is starting to watch on the Door Status');
+ bot.say('#hackerspace', 'Door Bot is starting to watch on the Door Status');
})
},
ircSend: function (door_status) {
@@ -87,10 +92,11 @@ module.exports = {
if (params_config["servers"].hasOwnProperty(key)) {
var main_channel = params_config["servers"][key]["main_channel"];
bot.say(main_channel, 'Door Status changed to: ' + door_status);
+ bot.say("#freifunk-flensburg", 'Door Status changed to: ' + door_status);
}
}
- // bot.send('topic','#hackerspace "Hackerspace Flensburg - Treffen jeden Montag 18:00 Uhr im Offenen Kanal Flensburg! - Tür Status"' + door_status);
- // console.log("IRC Door Status Chnaged");
+ bot.send('topic','#hackerspace "Hackerspace Flensburg - Treffen jeden Montag 18:00 Uhr im Offenen Kanal Flensburg! - Tür Status"' + door_status);
+ console.log("IRC Door Status Chnaged");
},
ircStopp: function() {
bot.disconnect(disconnect_meassage);
@@ -111,7 +117,7 @@ module.exports = {
message = message.toLowerCase();
for (var key in command_config["commands"]) {
if (command_config["commands"].hasOwnProperty(key)) {
- // console.log("!" + JSON.stringify(command_config["commands"][key]["keyword"]));
+ console.log("!" + JSON.stringify(command_config["commands"][key]["keyword"]));
if (message == ("!" + command_config["commands"][key]["keyword"])) {
if (command_config["commands"][key]["before"] == "from") {
if (command_config["commands"][key]["target"] == "from") {
@@ -150,63 +156,70 @@ module.exports = {
request.get('http://www.nordlab-ev.de/doorstate/status.txt', function (error, response, body) {
if (!error && response.statusCode == 200) {
door_status = body;
- //console.log(body);
+ console.log(body);
} else {
door_status = error;
- //console.log(error);
- }
- if (door_status == "geschlossen") {
- door_status = "closed";
- } else {
- door_status = "open";
+ console.log(error);
}
- // console.log(from + ' => ' + to + ': ' + message);
- bot.say(from, "DoorStatus is: " + door_status);
+ if (!error && response.statusCode == 200) {
+ if (door_status == "geschlossen") {
+ door_status = "closed";
+ } else {
+ door_status = "open";
+ }
+ console.log(from + ' => ' + to + ': ' + message);
+ bot.say(from, "DoorStatus is: " + door_status);
+ }else{
+ bot.say(from, "DoorStatus is not availible at this time");
+ }
}).setMaxListeners(0);
}
if (channel[0] + " " + channel[1] == "!doorstatus this") {
request.get('http://www.nordlab-ev.de/doorstate/status.txt', function (error, response, body) {
if (!error && response.statusCode == 200) {
door_status = body;
- //console.log(body);
+ console.log(body);
} else {
door_status = error;
- //console.log(error);
- }
- if (door_status == "geschlossen") {
- door_status = "closed";
- } else {
- door_status = "open";
+ console.log(error);
}
- // console.log(message);
- bot.list();
- // console.log(channel[(channel.length-(channel.length-1))+1]);
- // console.log(channel.length);
- if (channel[1] !== "this") {
- if (channel[1] !== " ") {
- bot.addListener('channellist', function (channel_list) {
- for (var key in channel_list) {
- if (channel_list.hasOwnProperty(key)) {
- if (channel_list[key]["name"] == channel[1]) {
- // console.log("1");
- bot.join(channel[1]);
- bot.say(channel[1], "DoorStatus is: " + door_status);
- }
- }
- }
- });
- } else {
- bot.say(from, "DoorStatus is: " + door_status);
- }
- } else {
- bot.join(to);
- bot.say(to, "DoorStatus is: " + door_status);
- }
+ if (!error && response.statusCode == 200) {
+ if (door_status == "geschlossen") {
+ door_status = "closed";
+ } else {
+ door_status = "open";
+ }
+ console.log(message);
+ bot.list();
+ console.log(channel[(channel.length-(channel.length-1))+1]);
+ console.log(channel.length);
+ if (channel[1] !== "this") {
+ if (channel[1] !== " ") {
+ bot.addListener('channellist', function (channel_list) {
+ for (var key in channel_list) {
+ if (channel_list.hasOwnProperty(key)) {
+ if (channel_list[key]["name"] == channel[1]) {
+ bot.join(channel[1]);
+ bot.say(channel[1], "DoorStatus is: " + door_status);
+ }
+ }
+ }
+ });
+ } else {
+ bot.say(from, "DoorStatus is: " + door_status);
+ }
+ } else {
+ bot.join(to);
+ bot.say(to, "DoorStatus is: " + door_status);
+ }
+ }else{
+ bot.say(from, "DoorStatus is not availible at this time");
+ }
}).setMaxListeners(0);
}
if (message == "!kill") {
if ((from == "DasNordlicht") || (from == "MTRNord")) {
- // console.log(from + ' => ' + to + ': ' + message);
+ console.log(from + ' => ' + to + ': ' + message);
if (process.platform === "win32") {
var rl = require("readline").createInterface({
input: process.stdin,
diff --git a/main.js b/main.js
@@ -66,7 +66,7 @@ request.get('http://www.nordlab-ev.de/doorstate/status.txt', function (error, re
}
irc.ircBotCommands();
if (!argv.noupdate && autoupdate == 1) {
- var j = schedule.scheduleJob('59 2 * * *', function(){
+ var j = schedule.scheduleJob('59 3 * * *', function(){
git.pull("origin", "master", function(err, update) {
if(update && update.summary.changes) {
console.log('Start Update!');
@@ -79,7 +79,7 @@ if (!argv.noupdate && autoupdate == 1) {
});
}
if ((argv.noupdate) || (autoupdate == 0)) {
- var k = schedule.scheduleJob('59 2 * * *', function(){
+ var k = schedule.scheduleJob('59 3 * * *', function(){
console.log('Daily restart!');
irc.ircEndCustom('Daily restart! Coming back in a few Seconds!');
require('child_process').exec('npm restart');