BoG/scripts/g1-info.js

72 lines
2.0 KiB
JavaScript

const exec = require('child_process').exec;
module.exports = (robot) => {
robot.hear(/^rib|bog rib|^pubkey|bog pubkey/i, function (msg) {
username = msg.envelope.user.name
cmd = msg.envelope.message.text
process.env.hb_cmd = cmd
process.env.hb_username = username
exec("scripts/shell/g1-infos.sh pubkey $hb_username $hb_cmd", function(err, stdout, stderr) {
if (err) {
msg.send("Une erreur est survenu ...")
} else {
if (stdout) { msg.send(stdout); }
}
});
});
robot.hear(/^pseudo|bog pseudo/i, function (msg) {
cmd = msg.envelope.message.text
process.env.hb_cmd = cmd
exec("scripts/shell/g1-infos.sh pseudo $hb_cmd", function(err, stdout, stderr) {
if (err) {
msg.send("Une erreur est survenu ...")
} else {
if (stdout) { msg.send(stdout); }
}
});
});
robot.hear(/^g1 membres$|bog g1 membres$|^g1 membre$|bog g1 membre$/i, function (msg) {
exec("scripts/shell/g1-infos.sh membres", function(err, stdout, stderr) {
if (err) {
msg.send("Une erreur est survenu ...")
} else {
if (stdout) { msg.send(stdout); }
}
});
});
robot.hear(/^.\/silkaj|bog .\/silkaj/i, function (msg) {
cmd = msg.envelope.message.text
process.env.hb_cmd = cmd
exec("scripts/shell/g1-infos.sh silkaj $hb_cmd", function(err, stdout, stderr) {
if (err) {
msg.send("Une erreur est survenu ...")
} else {
if (stdout) { msg.send(stdout); }
}
});
});
robot.hear(/debug conc/i, function (msg) {
cmd = msg.envelope.message.text
process.env.hb_cmd = cmd
setTimeout(() => { msg.send("coucou " + cmd); }, 2000);
});
}
/* EXAMPLES
module.exports = (robot) => {
robot.respond(/hello/i, function (msg) {
msg.reply('Howdy!');
});
robot.hear(/howdy/i, function (msg) {
msg.send('Hola!');
});
}*/