Sistemazioni...
This commit is contained in:
@@ -17,6 +17,7 @@ const { MsgTemplate } = require('../models/msg_template');
|
||||
|
||||
const emoji = require('node-emoji');
|
||||
|
||||
const { Flotta } = require('../models/flotta');
|
||||
|
||||
const i18n = require("i18n");
|
||||
|
||||
@@ -557,18 +558,23 @@ module.exports = {
|
||||
msg = msg.replace('{surname}', user.surname);
|
||||
if (!!user.profile.link_payment)
|
||||
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
|
||||
if (!!user.profile.revolut)
|
||||
msg = msg.replace('{revolut}', user.profile.revolut);
|
||||
if (!!user.profile.email_paypal)
|
||||
msg = msg.replace('{email_paypal}', user.profile.email_paypal);
|
||||
if (!!user.profile.note_payment)
|
||||
msg = msg.replace('{note_payment}', user.profile.note_payment);
|
||||
}
|
||||
|
||||
// const cl = getclTelegByidapp(user.idapp);
|
||||
msg = msg.replace('{link_chathelp}', tools.HELP_CHAT);
|
||||
|
||||
if (!!mydata.flotta) {
|
||||
// SOSTITUISCI LE PAROLE CHIAVI
|
||||
if (!!mydata.flotta.date_start)
|
||||
msg = msg.replace('{date_start}', tools.getstrDateLong(new Date(mydata.flotta.date_start), user.lang));
|
||||
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.getstrDateLong(new Date(mydata.flotta.date_close), user.lang));
|
||||
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)
|
||||
@@ -581,12 +587,14 @@ module.exports = {
|
||||
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));
|
||||
}
|
||||
|
||||
return { body: msg, title };
|
||||
},
|
||||
|
||||
sendMsgTelegramToNave: async function (idapp, mydata) {
|
||||
sendMsgTelegramToNave: async function (idapp, mydata, res) {
|
||||
let nummsgtosend = 0;
|
||||
let nummsgsent = 0;
|
||||
let strout = '';
|
||||
@@ -596,7 +604,9 @@ module.exports = {
|
||||
|
||||
try {
|
||||
let arrnavi = null;
|
||||
let strflotta = '';
|
||||
if (flotta) {
|
||||
strflotta = Flotta.getStrFlotta(flotta);
|
||||
arrnavi = await Nave.getusersByFlotta(idapp, flotta.riga, flotta.col_prima, flotta.col_ultima);
|
||||
|
||||
if (mydata.tipomsg === tools.TipoMsg.SEND_MSG_A_SOGNATORE) {
|
||||
@@ -673,7 +683,8 @@ module.exports = {
|
||||
mytitle = rismsg.title;
|
||||
|
||||
if (mymsgprimo === '') {
|
||||
mymsgprimo = mymsg;
|
||||
if (lang === 'it')
|
||||
mymsgprimo = mymsg;
|
||||
}
|
||||
|
||||
if (!!idteleg) {
|
||||
@@ -701,14 +712,18 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (!mydata.inviareale) {
|
||||
await this.sendMsgTelegramToTheManagers(idapp, 'TEST INVIO MESSAGGIO:\n' + mymsgprimo + '\n\n(Messaggi da Inviare: ' + nummsgtosend + ')');
|
||||
await this.sendMsgTelegram(idapp, res.req.user.username, 'TEST INVIO MESSAGGIO:\n' + mymsgprimo + '\n\n(Messaggi da Inviare: ' + nummsgtosend + ')');
|
||||
}
|
||||
|
||||
if ((nummsgsent > 1) && (mydata.inviareale)) {
|
||||
try {
|
||||
let msg = '';
|
||||
if (!!flotta) {
|
||||
msg = 'Inviato messaggio a tutta la FLOTTA DA ' + flotta.riga + '.' + flotta.col_prima + ' A ' + flotta.riga + '.' + flotta.col_ultima + ' \n' + mymsg;
|
||||
if (!!mydata.tipomsg) {
|
||||
msg = 'Flotta ' + strflotta + '): ' + tools.getStrMsgByTipoMsg(mydata.tipomsg) + '\n' + mymsg ;
|
||||
} else {
|
||||
msg = 'Inviato messaggio a tutta la FLOTTA DA ' + flotta.riga + '.' + flotta.col_prima + ' A ' + flotta.riga + '.' + flotta.col_ultima + ' \n' + mymsg;
|
||||
}
|
||||
} else {
|
||||
msg = 'Inviato messaggio a tutti i Donatori della Nave ' + mydata.navemediatore.riga + '.' + mydata.navemediatore.col + '\n' + mymsg;
|
||||
}
|
||||
@@ -1114,7 +1129,7 @@ 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.AIUTO.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'Clicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !';
|
||||
risp = 'Clicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + tools.HELP_CHAT + '\n\nI miei colleghi umani ti aiuteranno a risolvere !';
|
||||
} else if (MsgBot.SPOSAMI.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'No Grazie! Sono per la Libertà a Vita! ' + emo.JOY + '\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE;
|
||||
} else if (MsgBot.CHE_TEMPO_FA.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
@@ -1524,7 +1539,7 @@ class Telegram {
|
||||
let mystr = '';
|
||||
if (rec.user) {
|
||||
mystr += printf(tools.get__('INFO_LINK_DA_CONDIVIDERE', this.getlang(msg)), tools.getHostByIdApp(this.idapp) + '/signup/' + rec.user.username);
|
||||
mystr += tools.ACAPO + tools.ACAPO + printf(tools.get__('INFO_LINK_ZOOM', this.getlang(msg)), tools.getlinkzoom(''));
|
||||
mystr += tools.ACAPO + tools.ACAPO + printf(tools.get__('INFO_LINK_ZOOM', this.getlang(msg)), tools.getlinkzoom(null));
|
||||
await this.sendMsg(msg.chat.id, mystr);
|
||||
}
|
||||
}
|
||||
@@ -1566,16 +1581,19 @@ class Telegram {
|
||||
iniziata = (nextzoom._id.toString() === evento._id.toString());
|
||||
|
||||
|
||||
let lang = this.getlang(msg);
|
||||
|
||||
if (iniziata) {
|
||||
mystr += emo.CHECK_VERDE + ' ' + tools.get__('ZOOM_INIZIATO', this.getlang(msg)) + ' ' + emo.CHECK_VERDE + '\n';
|
||||
mystr += emo.CHECK_VERDE + ' ' + tools.get__('ZOOM_INIZIATO', lang) + ' ' + emo.CHECK_VERDE + '\n';
|
||||
}
|
||||
|
||||
mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start, this.getlang(msg))} ${emo.EYES}`;
|
||||
mystr += `\n${evento.title}\n(${evento.note})\n\n`;
|
||||
mystr += tools.getflagtelegrambyLang(evento.lang) + ` ${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start, this.getlang(msg))} ${emo.EYES}`;
|
||||
mystr += `\n${evento.title}\n(${evento.note})`;
|
||||
mystr += `\n${tools.getlinkzoom(evento)}\n\n`;
|
||||
if (nextzoom) {
|
||||
if (iniziata) {
|
||||
mystr += emo.FIRE + tools.get__('CLICCA_ENTRA', this.getlang(msg)) + ' ' + emo.FIRE + '\n';
|
||||
mystr += tools.getlinkzoom(evento.id_conf_zoom) + '\n';
|
||||
mystr += tools.getlinkzoom(evento) + '\n';
|
||||
mystr += '\n';
|
||||
//mystr += pwd + '\n\n';
|
||||
}
|
||||
@@ -1587,7 +1605,7 @@ class Telegram {
|
||||
|
||||
if (!nextzoom && index > 1) {
|
||||
mystr += "✨✨✨✨✨✨✨✨✨✨✨✨\n" +
|
||||
tools.get__('CLICCA_PER_ZOOM', this.getlang(msg)) + ':\n' + tools.getlinkzoom(listazoom[0].id_conf_zoom) + '\n' + "✨✨✨✨✨✨✨✨✨✨✨✨\n";
|
||||
tools.get__('CLICCA_PER_ZOOM', this.getlang(msg)) + '\n' + "✨✨✨✨✨✨✨✨✨✨✨✨\n";
|
||||
}
|
||||
|
||||
return mystr
|
||||
@@ -1694,7 +1712,7 @@ class Telegram {
|
||||
} else if (qualelink === 'biblio') {
|
||||
return 'https://t.me/joinchat/AAAAAFMDe8b5lB1X7vOYng';
|
||||
} else if (qualelink === 'help') {
|
||||
return 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw';
|
||||
return tools.HELP_CHAT;
|
||||
} else if (qualelink === 'faq') {
|
||||
return 'https://ayni.gifteconomy.app/faq';
|
||||
} else if (qualelink === 'empower') {
|
||||
@@ -1997,8 +2015,8 @@ class Telegram {
|
||||
// chiedisino = true;
|
||||
// rec.msgall_status = StatusMSGALL.CONFIRM;
|
||||
FormDaMostrare = this.getInlineKeyboard(lang, [
|
||||
{ text: Menu[lang].SI, callback_data: InlineCmd.VOGLIO_IMBARCARMI },
|
||||
{ text: Menu[lang].NO, callback_data: InlineCmd.NON_VOGLIO_IMBARCARMI },
|
||||
{ text: Menu[lang].SI, callback_data: { action: InlineCmd.VOGLIO_IMBARCARMI, username: utente.username } },
|
||||
{ text: Menu[lang].NO, callback_data: { action: InlineCmd.NON_VOGLIO_IMBARCARMI, username: utente.username } },
|
||||
]);
|
||||
inviaveramente = true;
|
||||
} else {
|
||||
@@ -2301,6 +2319,10 @@ class Telegram {
|
||||
if (!text)
|
||||
return 0;
|
||||
|
||||
if (process.env.LOCALE === "1") {
|
||||
id = '12429864';
|
||||
}
|
||||
|
||||
if (!!msg_id) {
|
||||
return this.modificaMsg(chat_id, msg_id, text);
|
||||
}
|
||||
@@ -2335,6 +2357,12 @@ class Telegram {
|
||||
|
||||
text = text.replace(/<br>/g, "\n");
|
||||
text = text.replace(/<div>/g, "");
|
||||
text = text.replace(/<font/g, "<pre");
|
||||
text = text.replace(/<\/font>/g, "</pre>");
|
||||
text = text.replace(/<span/g, "<pre");
|
||||
text = text.replace(/<\/span>/g, "</pre>");
|
||||
text = text.replace(/<p /g, "<pre ");
|
||||
text = text.replace(/<\/p>/g, "</pre>");
|
||||
text = text.replace(/<\/div>/g, "\n");
|
||||
text = text.replace(/ /g, " ");
|
||||
|
||||
@@ -2589,7 +2617,7 @@ if (!tools.testing()) {
|
||||
|
||||
const myclTelegram = getclTelegBytoken(bot.token);
|
||||
|
||||
const action = callbackQuery.data;
|
||||
const data = callbackQuery.data;
|
||||
const msg = callbackQuery.message;
|
||||
const opts = {
|
||||
chat_id: msg.chat.id,
|
||||
@@ -2599,22 +2627,23 @@ if (!tools.testing()) {
|
||||
const status = await myclTelegram.setInit(msg);
|
||||
|
||||
const rec = myclTelegram.getRecInMem(msg);
|
||||
const user = await User.getUserShortDataByUsername(idapp, data.username);
|
||||
if (!!rec) {
|
||||
if (!!rec.user) {
|
||||
if (action === InlineCmd.VOGLIO_IMBARCARMI) {
|
||||
if (!!user) {
|
||||
if (data.action === InlineCmd.VOGLIO_IMBARCARMI) {
|
||||
// Controlla se è qualificato!
|
||||
const mydata = tools.AddDate(rec.user.date_reg, 7);
|
||||
const mydata = tools.AddDate(user.date_reg, 7);
|
||||
|
||||
const newrecingr = await ListaIngresso.addUserInListaIngresso(rec.user.idapp, rec.user.username, rec.user.aportador_solidario, rec.user.lang, true, true, mydata);
|
||||
const newrecingr = await ListaIngresso.addUserInListaIngresso(user.idapp, user.username, user.aportador_solidario, user.lang, true, true, mydata);
|
||||
|
||||
bot.editMessageText(tools.gettranslate('ADDED_TOLISTAINGRESSO', rec.user.lang), opts);
|
||||
bot.editMessageText(tools.gettranslate('ADDED_TOLISTAINGRESSO', user.lang), opts);
|
||||
|
||||
} else if (action === InlineCmd.NON_VOGLIO_IMBARCARMI) {
|
||||
await User.NonVoglioImbarcarmi(rec.user.idapp, rec.user.username);
|
||||
} else if (data.action === InlineCmd.NON_VOGLIO_IMBARCARMI) {
|
||||
await User.NonVoglioImbarcarmi(user.idapp, user.username);
|
||||
|
||||
const msgadd = '[' + rec.user.username + '] ' + rec.user.name + ' ' + rec.user.surname + ' ha risposto che NON VUOLE IMBARCARSI !';
|
||||
const msgadd = '[' + user.username + '] ' + user.name + ' ' + user.surname + ' ha risposto che NON VUOLE IMBARCARSI !';
|
||||
|
||||
await local_sendMsgTelegramToTheManagers(rec.user.idapp, msgadd, msg, false); // Anche a STAFF
|
||||
await local_sendMsgTelegramToTheManagers(user.idapp, msgadd, msg, false); // Anche a STAFF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user