|
|
|
|
@@ -5,7 +5,7 @@ const appTelegram = [tools.FREEPLANET, tools.RISO];
|
|
|
|
|
const appTelegram_TEST = [tools.FREEPLANET, tools.RISO];
|
|
|
|
|
const appTelegram_DEVELOP = [tools.RISO];
|
|
|
|
|
|
|
|
|
|
const appTelegramFinti = ['2', tools.CNM, tools.ARCADEI];
|
|
|
|
|
const appTelegramFinti = ['2', tools.CNM];
|
|
|
|
|
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
|
|
|
|
|
|
|
|
|
const printf = require('util').format;
|
|
|
|
|
@@ -143,6 +143,7 @@ MsgBot = {
|
|
|
|
|
'grazie 😘',
|
|
|
|
|
'grazie😘'],
|
|
|
|
|
PRINCIPE_AZZURRO: ['principe azzurro'],
|
|
|
|
|
START_INV: ['/start inv'],
|
|
|
|
|
COSE_COVID: [
|
|
|
|
|
'cos\'è il covid',
|
|
|
|
|
'cosa è il covid',
|
|
|
|
|
@@ -709,7 +710,7 @@ const MyTelegramBot = {
|
|
|
|
|
MyForm = null) {
|
|
|
|
|
|
|
|
|
|
if (!idtelegram)
|
|
|
|
|
return {text: ''};
|
|
|
|
|
return { text: '' };
|
|
|
|
|
|
|
|
|
|
const cl = getclTelegByidapp(idapp);
|
|
|
|
|
if (cl && idtelegram) {
|
|
|
|
|
@@ -718,7 +719,7 @@ const MyTelegramBot = {
|
|
|
|
|
chat_id, ripr_menuPrec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {text: ''};
|
|
|
|
|
return { text: '' };
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
@@ -1035,270 +1036,268 @@ const MyTelegramBot = {
|
|
|
|
|
sendMsgTelegramToTheAdminsOfCircuit: async function (
|
|
|
|
|
idapp, circuitpath, text, onlyintofile = false, MyForm = null, nottousername = '') {
|
|
|
|
|
|
|
|
|
|
tools.writeManagersLog(text);
|
|
|
|
|
let teleg_id = 0;
|
|
|
|
|
tools.writeManagersLog(text);
|
|
|
|
|
let teleg_id = 0;
|
|
|
|
|
|
|
|
|
|
if (!onlyintofile) {
|
|
|
|
|
const usersmanagers = await Circuit.getListAdminsByCircuitPath(idapp, circuitpath);
|
|
|
|
|
if (usersmanagers) {
|
|
|
|
|
for (const rec of usersmanagers) {
|
|
|
|
|
if (rec.username !== nottousername) {
|
|
|
|
|
teleg_id = await User.TelegIdByUsername(idapp, rec.username);
|
|
|
|
|
if (teleg_id) {
|
|
|
|
|
await this.sendMsgTelegramByIdTelegram(idapp, teleg_id,
|
|
|
|
|
emo.ROBOT_FACE + ': ' + text, undefined, undefined, true,
|
|
|
|
|
MyForm);
|
|
|
|
|
await tools.snooze(100);
|
|
|
|
|
if (!onlyintofile) {
|
|
|
|
|
const usersmanagers = await Circuit.getListAdminsByCircuitPath(idapp, circuitpath);
|
|
|
|
|
if (usersmanagers) {
|
|
|
|
|
for (const rec of usersmanagers) {
|
|
|
|
|
if (rec.username !== nottousername) {
|
|
|
|
|
teleg_id = await User.TelegIdByUsername(idapp, rec.username);
|
|
|
|
|
if (teleg_id) {
|
|
|
|
|
await this.sendMsgTelegramByIdTelegram(idapp, teleg_id,
|
|
|
|
|
emo.ROBOT_FACE + ': ' + text, undefined, undefined, true,
|
|
|
|
|
MyForm);
|
|
|
|
|
await tools.snooze(100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMsgTelegramToTheManagersAndZoomeri: async function (
|
|
|
|
|
idapp, text, onlyintofile, MyForm = null) {
|
|
|
|
|
sendMsgTelegramToTheManagersAndZoomeri: async function (
|
|
|
|
|
idapp, text, onlyintofile, MyForm = null) {
|
|
|
|
|
|
|
|
|
|
tools.writeManagersLog(text);
|
|
|
|
|
tools.writeManagersLog(text);
|
|
|
|
|
|
|
|
|
|
if (!onlyintofile) {
|
|
|
|
|
// const usersmanagers = await User.getusersManagersAndZoomeri(idapp);
|
|
|
|
|
const usersmanagers = await User.getusersManagers(idapp);
|
|
|
|
|
if (usersmanagers) {
|
|
|
|
|
for (const rec of usersmanagers) {
|
|
|
|
|
await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id,
|
|
|
|
|
emo.ROBOT_FACE + ': ' + text, undefined, undefined, true, MyForm);
|
|
|
|
|
await tools.snooze(100);
|
|
|
|
|
if (!onlyintofile) {
|
|
|
|
|
// const usersmanagers = await User.getusersManagersAndZoomeri(idapp);
|
|
|
|
|
const usersmanagers = await User.getusersManagers(idapp);
|
|
|
|
|
if (usersmanagers) {
|
|
|
|
|
for (const rec of usersmanagers) {
|
|
|
|
|
await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id,
|
|
|
|
|
emo.ROBOT_FACE + ': ' + text, undefined, undefined, true, MyForm);
|
|
|
|
|
await tools.snooze(100);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
getMsgByTipoMsg: async function (mydata, lang, user, sonosognatore) {
|
|
|
|
|
if (!!mydata.msgextra) {
|
|
|
|
|
return { body: mydata.msgextra, title: '' };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let title = '';
|
|
|
|
|
let msg = '';
|
|
|
|
|
|
|
|
|
|
if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) {
|
|
|
|
|
if (sonosognatore)
|
|
|
|
|
msg = printf(tools.gettranslate('SEND_LINK_CHAT_SOGNATORE', lang),
|
|
|
|
|
user.name,
|
|
|
|
|
mydata.navemediatore.riga + '.' + mydata.navemediatore.col,
|
|
|
|
|
mydata.msgpar1);
|
|
|
|
|
else
|
|
|
|
|
msg = printf(tools.gettranslate('SEND_LINK_CHAT_DONATORI', lang),
|
|
|
|
|
user.name,
|
|
|
|
|
mydata.navemediatore.riga + '.' + mydata.navemediatore.col,
|
|
|
|
|
mydata.msgpar1);
|
|
|
|
|
} else if (mydata.tipomsg === tools.TipoMsg.SEND_MSG || mydata.tipomsg ===
|
|
|
|
|
tools.TipoMsg.SEND_MSG_SINGOLO) {
|
|
|
|
|
if (!!mydata.username_mitt) {
|
|
|
|
|
msg = '[' + tools.gettranslate('MSG_SEND_FROM', lang) + ' ' +
|
|
|
|
|
mydata.username_mitt + ']:' + tools.ACAPO;
|
|
|
|
|
},
|
|
|
|
|
getMsgByTipoMsg: async function (mydata, lang, user, sonosognatore) {
|
|
|
|
|
if (!!mydata.msgextra) {
|
|
|
|
|
return { body: mydata.msgextra, title: '' };
|
|
|
|
|
}
|
|
|
|
|
msg += mydata.msgpar1;
|
|
|
|
|
} else if (mydata.tipomsg >= 1000) {
|
|
|
|
|
const ris = await MsgTemplate.getMsgByLang(user.idapp, user, mydata.tipomsg,
|
|
|
|
|
lang);
|
|
|
|
|
msg = ris.body;
|
|
|
|
|
title = ris.title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cl = getclTelegByidapp(user.idapp);
|
|
|
|
|
if (cl) {
|
|
|
|
|
msg = await tools.convertSpecialTags(rec.user, msg);
|
|
|
|
|
}
|
|
|
|
|
let title = '';
|
|
|
|
|
let msg = '';
|
|
|
|
|
|
|
|
|
|
if (!!mydata.flotta) {
|
|
|
|
|
// SOSTITUISCI LE PAROLE CHIAVI
|
|
|
|
|
if (!!mydata.flotta.date_start)
|
|
|
|
|
msg = msg.replace('{date_start}',
|
|
|
|
|
tools.getstrDateLongTot(new Date(mydata.flotta.date_start),
|
|
|
|
|
user.lang));
|
|
|
|
|
if (!!mydata.flotta.date_close)
|
|
|
|
|
msg = msg.replace('{date_close}',
|
|
|
|
|
tools.getstrDateLongTot(new Date(mydata.flotta.date_close),
|
|
|
|
|
user.lang));
|
|
|
|
|
if (!!mydata.flotta.link_superchat)
|
|
|
|
|
msg = msg.replace('{link_superchat}', mydata.flotta.link_superchat);
|
|
|
|
|
if (!!mydata.flotta.tutor1)
|
|
|
|
|
msg = msg.replace('{tutor1}', mydata.flotta.tutor1);
|
|
|
|
|
if (!!mydata.flotta.tutor2)
|
|
|
|
|
msg = msg.replace('{tutor2}', mydata.flotta.tutor2);
|
|
|
|
|
if (!!mydata.flotta.tutor3)
|
|
|
|
|
msg = msg.replace('{tutor3}', mydata.flotta.tutor3);
|
|
|
|
|
if (!!mydata.flotta.tutorslo)
|
|
|
|
|
msg = msg.replace('{tutorslo}', mydata.flotta.tutorslo);
|
|
|
|
|
if (!!mydata.flotta.sognatore_nomecognome)
|
|
|
|
|
msg = msg.replace('{sognatore}', mydata.flotta.sognatore_nomecognome);
|
|
|
|
|
if (!!mydata.flotta.sognatore_nomecognome)
|
|
|
|
|
msg = msg.replace('{flotta}',
|
|
|
|
|
mydata.flotta.riga + '.' + Math.ceil(mydata.flotta.col_prima / 8) +
|
|
|
|
|
' - ' + mydata.flotta.riga + '.' +
|
|
|
|
|
Math.ceil(mydata.flotta.col_ultima / 8));
|
|
|
|
|
}
|
|
|
|
|
if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) {
|
|
|
|
|
if (sonosognatore)
|
|
|
|
|
msg = printf(tools.gettranslate('SEND_LINK_CHAT_SOGNATORE', lang),
|
|
|
|
|
user.name,
|
|
|
|
|
mydata.navemediatore.riga + '.' + mydata.navemediatore.col,
|
|
|
|
|
mydata.msgpar1);
|
|
|
|
|
else
|
|
|
|
|
msg = printf(tools.gettranslate('SEND_LINK_CHAT_DONATORI', lang),
|
|
|
|
|
user.name,
|
|
|
|
|
mydata.navemediatore.riga + '.' + mydata.navemediatore.col,
|
|
|
|
|
mydata.msgpar1);
|
|
|
|
|
} else if (mydata.tipomsg === tools.TipoMsg.SEND_MSG || mydata.tipomsg ===
|
|
|
|
|
tools.TipoMsg.SEND_MSG_SINGOLO) {
|
|
|
|
|
if (!!mydata.username_mitt) {
|
|
|
|
|
msg = '[' + tools.gettranslate('MSG_SEND_FROM', lang) + ' ' +
|
|
|
|
|
mydata.username_mitt + ']:' + tools.ACAPO;
|
|
|
|
|
}
|
|
|
|
|
msg += mydata.msgpar1;
|
|
|
|
|
} else if (mydata.tipomsg >= 1000) {
|
|
|
|
|
const ris = await MsgTemplate.getMsgByLang(user.idapp, user, mydata.tipomsg,
|
|
|
|
|
lang);
|
|
|
|
|
msg = ris.body;
|
|
|
|
|
title = ris.title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { body: msg, title };
|
|
|
|
|
},
|
|
|
|
|
const cl = getclTelegByidapp(user.idapp);
|
|
|
|
|
if (cl) {
|
|
|
|
|
msg = await tools.convertSpecialTags(rec.user, msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendMsgTelegramToTheAdminAllSites: async function (text, senzaintestazione) {
|
|
|
|
|
for (const idapp of this.getAppTelegram()) {
|
|
|
|
|
text = text.replace('{appname}', tools.getNomeAppByIdApp(idapp));
|
|
|
|
|
await this.sendMsgTelegramToTheAdmin(idapp, text, senzaintestazione);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
if (!!mydata.flotta) {
|
|
|
|
|
// SOSTITUISCI LE PAROLE CHIAVI
|
|
|
|
|
if (!!mydata.flotta.date_start)
|
|
|
|
|
msg = msg.replace('{date_start}',
|
|
|
|
|
tools.getstrDateLongTot(new Date(mydata.flotta.date_start),
|
|
|
|
|
user.lang));
|
|
|
|
|
if (!!mydata.flotta.date_close)
|
|
|
|
|
msg = msg.replace('{date_close}',
|
|
|
|
|
tools.getstrDateLongTot(new Date(mydata.flotta.date_close),
|
|
|
|
|
user.lang));
|
|
|
|
|
if (!!mydata.flotta.link_superchat)
|
|
|
|
|
msg = msg.replace('{link_superchat}', mydata.flotta.link_superchat);
|
|
|
|
|
if (!!mydata.flotta.tutor1)
|
|
|
|
|
msg = msg.replace('{tutor1}', mydata.flotta.tutor1);
|
|
|
|
|
if (!!mydata.flotta.tutor2)
|
|
|
|
|
msg = msg.replace('{tutor2}', mydata.flotta.tutor2);
|
|
|
|
|
if (!!mydata.flotta.tutor3)
|
|
|
|
|
msg = msg.replace('{tutor3}', mydata.flotta.tutor3);
|
|
|
|
|
if (!!mydata.flotta.tutorslo)
|
|
|
|
|
msg = msg.replace('{tutorslo}', mydata.flotta.tutorslo);
|
|
|
|
|
if (!!mydata.flotta.sognatore_nomecognome)
|
|
|
|
|
msg = msg.replace('{sognatore}', mydata.flotta.sognatore_nomecognome);
|
|
|
|
|
if (!!mydata.flotta.sognatore_nomecognome)
|
|
|
|
|
msg = msg.replace('{flotta}',
|
|
|
|
|
mydata.flotta.riga + '.' + Math.ceil(mydata.flotta.col_prima / 8) +
|
|
|
|
|
' - ' + mydata.flotta.riga + '.' +
|
|
|
|
|
Math.ceil(mydata.flotta.col_ultima / 8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendMsgTelegramToTheAdmin: async function (idapp, text, senzaintestazione) {
|
|
|
|
|
const usersmanagers = await User.getusersAdmin(idapp);
|
|
|
|
|
return { body: msg, title };
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
let intestaz = emo.ROBOT_FACE + '[BOT-ADMIN]' + emo.ADMIN + ': ';
|
|
|
|
|
if (senzaintestazione)
|
|
|
|
|
intestaz = '';
|
|
|
|
|
sendMsgTelegramToTheAdminAllSites: async function (text, senzaintestazione) {
|
|
|
|
|
for (const idapp of this.getAppTelegram()) {
|
|
|
|
|
text = text.replace('{appname}', tools.getNomeAppByIdApp(idapp));
|
|
|
|
|
await this.sendMsgTelegramToTheAdmin(idapp, text, senzaintestazione);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
if (usersmanagers) {
|
|
|
|
|
for (const rec of usersmanagers) {
|
|
|
|
|
if (User.isAdmin(rec.perm)) {
|
|
|
|
|
this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id,
|
|
|
|
|
intestaz + text, undefined, undefined, true);
|
|
|
|
|
sendMsgTelegramToTheAdmin: async function (idapp, text, senzaintestazione) {
|
|
|
|
|
const usersmanagers = await User.getusersAdmin(idapp);
|
|
|
|
|
|
|
|
|
|
let intestaz = emo.ROBOT_FACE + '[BOT-ADMIN]' + emo.ADMIN + ': ';
|
|
|
|
|
if (senzaintestazione)
|
|
|
|
|
intestaz = '';
|
|
|
|
|
|
|
|
|
|
if (usersmanagers) {
|
|
|
|
|
for (const rec of usersmanagers) {
|
|
|
|
|
if (User.isAdmin(rec.perm)) {
|
|
|
|
|
this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id,
|
|
|
|
|
intestaz + text, undefined, undefined, true);
|
|
|
|
|
await tools.snooze(300);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMsgTelegramToALL: async function (idapp, text) {
|
|
|
|
|
const usersall = await User.getUsersTelegALL(idapp);
|
|
|
|
|
|
|
|
|
|
if (usersall) {
|
|
|
|
|
for (const rec of usersall) {
|
|
|
|
|
this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, text);
|
|
|
|
|
await tools.snooze(300);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMsgTelegramToALL: async function (idapp, text) {
|
|
|
|
|
const usersall = await User.getUsersTelegALL(idapp);
|
|
|
|
|
sendMsgTelegram: async function (
|
|
|
|
|
idapp, username, text, alsotomanagers = false, username_mitt = '') {
|
|
|
|
|
const { User } = require('../models/user');
|
|
|
|
|
|
|
|
|
|
if (usersall) {
|
|
|
|
|
for (const rec of usersall) {
|
|
|
|
|
this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, text);
|
|
|
|
|
await tools.snooze(300);
|
|
|
|
|
const teleg_id = await User.TelegIdByUsername(idapp, username);
|
|
|
|
|
const cl = getclTelegByidapp(idapp);
|
|
|
|
|
let ris = null;
|
|
|
|
|
if (cl && teleg_id) {
|
|
|
|
|
ris = await cl.sendMsg(teleg_id, text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMsgTelegram: async function (
|
|
|
|
|
idapp, username, text, alsotomanagers = false, username_mitt = '') {
|
|
|
|
|
const { User } = require('../models/user');
|
|
|
|
|
|
|
|
|
|
const teleg_id = await User.TelegIdByUsername(idapp, username);
|
|
|
|
|
const cl = getclTelegByidapp(idapp);
|
|
|
|
|
let ris = null;
|
|
|
|
|
if (cl && teleg_id) {
|
|
|
|
|
ris = await cl.sendMsg(teleg_id, text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cl && teleg_id) {
|
|
|
|
|
if (alsotomanagers) {
|
|
|
|
|
await this.sendMsgTelegramToTheManagers(idapp, text);
|
|
|
|
|
}
|
|
|
|
|
if (!!username_mitt) {
|
|
|
|
|
const rec = cl.getRecByUsername(username);
|
|
|
|
|
if (rec) {
|
|
|
|
|
rec.msgall_username_specifico = username_mitt;
|
|
|
|
|
if (cl && teleg_id) {
|
|
|
|
|
if (alsotomanagers) {
|
|
|
|
|
await this.sendMsgTelegramToTheManagers(idapp, text);
|
|
|
|
|
}
|
|
|
|
|
if (!!username_mitt) {
|
|
|
|
|
const rec = cl.getRecByUsername(username);
|
|
|
|
|
if (rec) {
|
|
|
|
|
rec.msgall_username_specifico = username_mitt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ris;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMsgTelegramByIdTelegram: async function (
|
|
|
|
|
idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec,
|
|
|
|
|
MyForm = null) {
|
|
|
|
|
|
|
|
|
|
console.log('sendMsgTelegramByIdTelegram', text);
|
|
|
|
|
|
|
|
|
|
if (!idtelegram)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const cl = getclTelegByidapp(idapp);
|
|
|
|
|
if (cl && idtelegram) {
|
|
|
|
|
let myform = null;
|
|
|
|
|
|
|
|
|
|
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id,
|
|
|
|
|
chat_id, ripr_menuPrec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reloadMenuBot: async function (idapp) {
|
|
|
|
|
|
|
|
|
|
const cl = getclTelegByidapp(idapp);
|
|
|
|
|
if (cl) {
|
|
|
|
|
return cl.updateMenuBot();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reloadSites: async function () {
|
|
|
|
|
|
|
|
|
|
tools.loadApps();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMsgFromSite: async function (idapp, user, params) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
let ris = {
|
|
|
|
|
numrec: 0,
|
|
|
|
|
nummsgsent: 0,
|
|
|
|
|
text: '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let invia = false;
|
|
|
|
|
let content = '';
|
|
|
|
|
|
|
|
|
|
let tipomsgtempl = 0;
|
|
|
|
|
|
|
|
|
|
params.sendreally = true;
|
|
|
|
|
|
|
|
|
|
if (params.typemsg === shared_consts.TypeMsg.SEND_TO_MYSELF) {
|
|
|
|
|
params.usernameDest = user.username;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (params.cmd === shared_consts.MsgTeleg.SHARE_MSGREG) {
|
|
|
|
|
tipomsgtempl = shared_consts.TypeMsgTemplate.MS_SHARE_LINK;
|
|
|
|
|
invia = true;
|
|
|
|
|
} else if (params.cmd === shared_consts.MsgTeleg.SHARE_TEXT) {
|
|
|
|
|
invia = !!params.content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tipomsgtempl > 0) {
|
|
|
|
|
const rismsg = await MsgTemplate.getMsgByLang(idapp, user, tipomsgtempl, user.lang);
|
|
|
|
|
params.content = rismsg.body;
|
|
|
|
|
params.title = rismsg.title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (invia) {
|
|
|
|
|
ris = await globalTables.SendMsgToParam(idapp, params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ris;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('sendMsgFromSite', e);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
sendMsgTelegramByIdTelegram: async function (
|
|
|
|
|
idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec,
|
|
|
|
|
MyForm = null) {
|
|
|
|
|
|
|
|
|
|
sendMsgFromSiteToBotTelegram: async function (idapp, user, params) {
|
|
|
|
|
if (!idtelegram)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!params.typesend) {
|
|
|
|
|
params.typesend = shared_consts.TypeSend.TELEGRAM;
|
|
|
|
|
}
|
|
|
|
|
const cl = getclTelegByidapp(idapp);
|
|
|
|
|
if (cl && idtelegram) {
|
|
|
|
|
let myform = null;
|
|
|
|
|
|
|
|
|
|
return this.sendMsgFromSite(idapp, user, params);
|
|
|
|
|
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id,
|
|
|
|
|
chat_id, ripr_menuPrec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reloadMenuBot: async function (idapp) {
|
|
|
|
|
|
|
|
|
|
const cl = getclTelegByidapp(idapp);
|
|
|
|
|
if (cl) {
|
|
|
|
|
return cl.updateMenuBot();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reloadSites: async function () {
|
|
|
|
|
|
|
|
|
|
tools.loadApps();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMsgFromSite: async function (idapp, user, params) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
let ris = {
|
|
|
|
|
numrec: 0,
|
|
|
|
|
nummsgsent: 0,
|
|
|
|
|
text: '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let invia = false;
|
|
|
|
|
let content = '';
|
|
|
|
|
|
|
|
|
|
let tipomsgtempl = 0;
|
|
|
|
|
|
|
|
|
|
params.sendreally = true;
|
|
|
|
|
|
|
|
|
|
if (params.typemsg === shared_consts.TypeMsg.SEND_TO_MYSELF) {
|
|
|
|
|
params.usernameDest = user.username;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (params.cmd === shared_consts.MsgTeleg.SHARE_MSGREG) {
|
|
|
|
|
tipomsgtempl = shared_consts.TypeMsgTemplate.MS_SHARE_LINK;
|
|
|
|
|
invia = true;
|
|
|
|
|
} else if (params.cmd === shared_consts.MsgTeleg.SHARE_TEXT) {
|
|
|
|
|
invia = !!params.content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tipomsgtempl > 0) {
|
|
|
|
|
const rismsg = await MsgTemplate.getMsgByLang(idapp, user, tipomsgtempl, user.lang);
|
|
|
|
|
params.content = rismsg.body;
|
|
|
|
|
params.title = rismsg.title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (invia) {
|
|
|
|
|
ris = await globalTables.SendMsgToParam(idapp, params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ris;
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('sendMsgFromSite', e);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMsgFromSiteToBotTelegram: async function (idapp, user, params) {
|
|
|
|
|
|
|
|
|
|
if (!params.typesend) {
|
|
|
|
|
params.typesend = shared_consts.TypeSend.TELEGRAM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.sendMsgFromSite(idapp, user, params);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -1676,6 +1675,9 @@ class Telegram {
|
|
|
|
|
} else if (MsgBot.PRINCIPE_AZZURRO.find(
|
|
|
|
|
(rec) => testo.indexOf(rec) > -1)) {
|
|
|
|
|
risp = 'Chissà... Forse si!\nAnche se meglio averne un altro di scorta, nel caso il Principe non sia disponibile.';
|
|
|
|
|
} else if (MsgBot.START_INV.find(
|
|
|
|
|
(rec) => testo.indexOf(rec) > -1)) {
|
|
|
|
|
risp = 'Sei già registrato a RISO. Per accedere alla App, aprila dall\'icona sul tuo schermo, oppure vai su https://riso.app ed installa la App.\n\nSe hai dimenticato la password: \n clicca sul menu in basso su "⚒ Strumenti" e poi "🔑 Cambio Password"'
|
|
|
|
|
} else if (MsgBot.COSE_COVID.find(
|
|
|
|
|
(rec) => testo.indexOf(rec) > -1)) {
|
|
|
|
|
risp = 'Un \'influenza più "grave", dovuta a paure e a fattori interiori di evoluzione, oltre ad una pulizia del corpo. ';
|
|
|
|
|
@@ -3090,7 +3092,7 @@ class Telegram {
|
|
|
|
|
status = this.getstatus(rec);
|
|
|
|
|
if (testo === Menu.EXIT_TELEGRAM) {
|
|
|
|
|
await this.menuExitToTelegram(msg);
|
|
|
|
|
}else if (status === Status.WAITFOR_USERNAME_TELEGRAM && !this.selectMenuHelp(msg) && !this.selectMenuLang(msg)) {
|
|
|
|
|
} else if (status === Status.WAITFOR_USERNAME_TELEGRAM && !this.selectMenuHelp(msg) && !this.selectMenuLang(msg)) {
|
|
|
|
|
// await this.setUsernameBo(msg);
|
|
|
|
|
await this.settotheDatabase(msg);
|
|
|
|
|
} else if (status === Status.WAITFOR_USERNAME_INVITANTE && !this.selectMenuHelp(msg) && !this.selectMenuLang(msg)) {
|
|
|
|
|
@@ -3530,8 +3532,10 @@ class Telegram {
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (process.env.LOCALE === '1') {
|
|
|
|
|
if (id !== ADMIN_IDTELEGRAM_TEST)
|
|
|
|
|
if (id !== ADMIN_IDTELEGRAM_TEST) {
|
|
|
|
|
text = '[Msg da inviare ipoteticamente a : ' + id + ']' + '\n' + text;
|
|
|
|
|
id = '12429864';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!!msg_id) {
|
|
|
|
|
@@ -3565,7 +3569,7 @@ class Telegram {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
console.log('<<< SEND MSG TELEGRAM: >>> ', text.substring(0, 100));
|
|
|
|
|
console.log('<<< SEND MSG TELEGRAM: >>> [id=', id, ']', text.substring(0, 100));
|
|
|
|
|
text = text.replace(/<br>/g, '\n');
|
|
|
|
|
text = text.replace(/<br\/>/g, '\n');
|
|
|
|
|
text = text.replace(/<div>/g, '');
|
|
|
|
|
@@ -3656,7 +3660,10 @@ class Telegram {
|
|
|
|
|
async sendMsgLog(id, text, menu, form, msg_id, chat_id, ripr_menuPrec) {
|
|
|
|
|
|
|
|
|
|
const rec = this.getRecInMemById(id);
|
|
|
|
|
const username = rec ? rec.username_bo : '';
|
|
|
|
|
let username = rec ? rec.username_bo : '';
|
|
|
|
|
if (!username) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('Msg inviato a ', username, '(', id, ')', text);
|
|
|
|
|
return await this.sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec);
|
|
|
|
|
|