const exec = require('child_process').exec; module.exports = (robot) => { robot.hear(/^rib|G1LibreBot rib|^pubkey|G1LibreBot pubkey/i, function (msg) { username = msg.envelope.user.username 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 { msg.send(stdout) } }); }); robot.hear(/^g1 membres|G1LibreBot g1 membres|^g1 membre|G1LibreBot 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 { msg.send(stdout) } }); }); robot.hear(/^.\/silkaj|G1LibreBot .\/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 { msg.send(stdout) } }); }); } /* EXAMPLES module.exports = (robot) => { robot.respond(/hello/i, function (msg) { msg.reply('Howdy!'); }); robot.hear(/howdy/i, function (msg) { msg.send('Hola!'); }); }*/