Comandi Script da BOT
This commit is contained in:
@@ -2711,6 +2711,7 @@ module.exports = {
|
||||
convertSpecialTags(user, msg) {
|
||||
try {
|
||||
if (!!user) {
|
||||
msg = msg.replace('{appname}', this.getNomeAppByIdApp(user.idapp));
|
||||
msg = msg.replace('{username}', user.username);
|
||||
msg = msg.replace('{name}', user.name ? user.name : user.username);
|
||||
msg = msg.replace('{surname}', user.surname ? user.surname : '');
|
||||
@@ -2774,4 +2775,31 @@ module.exports = {
|
||||
return strlinkreg;
|
||||
},
|
||||
|
||||
execScript: function(idapp, msg, script, testo) {
|
||||
const { exec } = require("child_process");
|
||||
const telegrambot = require('../telegram/telegrambot');
|
||||
|
||||
|
||||
const idchat = msg.chat.id;
|
||||
|
||||
console.log(testo + ' (' + script + ')');
|
||||
telegrambot.local_sendMsgTelegramByIdTelegram(idapp, idchat, testo);
|
||||
|
||||
exec(script, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
telegrambot.local_sendMsgTelegramByIdTelegram(idapp, idchat, 'ERROR: ' + error.message);
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
telegrambot.local_sendMsgTelegramByIdTelegram(idapp, idchat, 'ERROR: ' + stderr);
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log(` ... stdout: ${stdout}`);
|
||||
telegrambot.local_sendMsgTelegramByIdTelegram(idapp, idchat, stdout);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user