- Nave
- Requirements - Send Msg to Passeggeri
This commit is contained in:
@@ -9,6 +9,7 @@ const printf = require('util').format;
|
||||
|
||||
const { User } = require('../models/user');
|
||||
const { CalZoom } = require('../models/calzoom');
|
||||
const { Nave } = require('../models/nave');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const emoji = require('node-emoji');
|
||||
@@ -48,6 +49,7 @@ const emo = {
|
||||
YELLOW_HEART: emoji.get('yellow_heart'),
|
||||
PURPLE_HEART: emoji.get('purple_heart'),
|
||||
GIFT_HEART: emoji.get('gift_heart'),
|
||||
GIFT: emoji.get('gift'),
|
||||
ROBOT_FACE: emoji.get('robot_face'),
|
||||
ADMIN: emoji.get('information_desk_person'),
|
||||
MALE: emoji.get('man-tipping-hand'),
|
||||
@@ -59,7 +61,9 @@ const emo = {
|
||||
|
||||
|
||||
MsgBot = {
|
||||
CIAO: ['ciao', 'ciaoo', 'hola', 'holaa', 'hey', 'salve', 'buongiorno', 'buondi'],
|
||||
MIANAVE: ['Nave'],
|
||||
|
||||
CIAO: ['ciao', 'ciaoo', 'hola', 'holaa', 'hey', 'salve', 'buongiorno', 'buondi', 'ciao ❤️'],
|
||||
CI_SEI: ['ci sei', 'c\'è qualcuno', 'c\'è nessuno'],
|
||||
CHI_SONO_IO: ['chi sono io', 'chi sono'],
|
||||
COME_STAI: ['tutto bene', 'come stai', 'come stai', 'come va', 'come butta', 'come va oggi'],
|
||||
@@ -81,7 +85,7 @@ MsgBot = {
|
||||
NON_TROO_INVITATI: ['non trovo invitati', 'non riesco a trovare invitati'],
|
||||
PAROLACCE: ['stronz', 'fanculo'],
|
||||
COME_SI_CHIAMA: ['come si chiama'],
|
||||
PROSSIMO_ZOOM: ['prossimo zoom', 'fare lo zoom', 'gli zoom', 'conferenz'],
|
||||
PROSSIMO_ZOOM: ['prossimo zoom', 'fare lo zoom', 'gli zoom', 'conferenz', 'zoom'],
|
||||
LAVAGNA: ['lavagna', 'Lavagna', 'LAVAGNA'],
|
||||
SEI_LIBERO: ['sei liber', 'sei sposat', 'sei fidanzat', 'sei single'],
|
||||
AIUTO: ['ayni help', 'help', 'aiuto', 'ho bisogno di', 'ho problemi', 'non riesco', 'mi puoi aiutare', 'mi aiuti', 'aiutami', 'posso chiederti', 'puoi aiutarmi'],
|
||||
@@ -123,9 +127,13 @@ function getemojibynumber(number) {
|
||||
return emoji.get('height')
|
||||
} else if (number === 9) {
|
||||
return emoji.get('nine')
|
||||
} else {
|
||||
return number;
|
||||
}
|
||||
}
|
||||
|
||||
strNave = "Nave";
|
||||
|
||||
|
||||
const Menu = {
|
||||
ACCEDI: emo.PERSON + ' Accedi',
|
||||
@@ -138,22 +146,36 @@ const Menu = {
|
||||
ADMIN: emoji.get('information_desk_person') + ' Admin',
|
||||
ALTRO: emoji.get('newspaper') + ' Altro',
|
||||
MSGATUTTI: emoji.get('incoming_envelope') + ' Invia a TUTTI',
|
||||
MSG_TO_NAVE: emoji.get('incoming_envelope') + 'Msg_to_Navi',
|
||||
MSG_NO_7_REQ: emoji.get('incoming_envelope') + 'No 7 Req.',
|
||||
MSG_NO_9_REQ: emoji.get('incoming_envelope') + 'No 9 Req',
|
||||
MSG_TO_USER: 'sendmsgto',
|
||||
MSG_SI_INVITATI_NO_7REQ_INVITATI: emoji.get('incoming_envelope') + 'Inv e NO 7 Req',
|
||||
MSGSTAFF: emoji.get('incoming_envelope') + ' Invia a STAFF',
|
||||
INDIETRO: emoji.get('back') + ' Indietro',
|
||||
SI: emoji.get('thumbsup') + ' SI',
|
||||
NO: emoji.get('thumbsdown') + ' NO',
|
||||
|
||||
CHAT_PERSONALE: emoji.get('female-office-worker') + emoji.get('computer'),
|
||||
ESCI_DA_CHAT: emoji.get('incoming_envelope') + ' Esci dalla Conversazione',
|
||||
EXIT_TELEGRAM: 'exittotelegram',
|
||||
MIANAVE: emo.GIFT + ' ' + strNave,
|
||||
};
|
||||
|
||||
const CONTA_SOLO = 'contasolo';
|
||||
const RICEVI_EMAIL = 'riceviemail';
|
||||
|
||||
const SendMsgCmd = [CONTA_SOLO, RICEVI_EMAIL];
|
||||
|
||||
|
||||
const MenuNoLogin = [[Menu.ACCEDI], [Menu.ASSISTENZA]];
|
||||
const MenuStandard = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.ASSISTENZA]];
|
||||
const MenuPerAdmin = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.ASSISTENZA], [Menu.ADMIN, Menu.ALTRO]];
|
||||
const MenuPerAdmin = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.ASSISTENZA], [Menu.MIANAVE, Menu.ADMIN, Menu.ALTRO]];
|
||||
const MenuYesNo = [[Menu.SI, Menu.NO]];
|
||||
|
||||
const MenuAdmin = [[Menu.LAVAGNA, Menu.ZOOM], [Menu.MSGSTAFF, Menu.MSGATUTTI, Menu.INDIETRO], ['', '']];
|
||||
const MenuAdmin = [[Menu.MSGSTAFF, Menu.MSGATUTTI, Menu.INDIETRO], [Menu.MSG_NO_7_REQ, Menu.MSG_NO_9_REQ], [Menu.MSG_TO_NAVE, Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI]];
|
||||
const MenuSend = [[CONTA_SOLO, RICEVI_EMAIL], [Menu.INDIETRO]];
|
||||
const MenuYes = [[Menu.MSGSTAFF, Menu.INDIETRO], ['', '']];
|
||||
const MenuChat = [[Menu.ESCI_DA_CHAT, Menu.INDIETRO]];
|
||||
|
||||
const Sex = {
|
||||
MALE: 1,
|
||||
@@ -168,6 +190,16 @@ const Status = {
|
||||
WAITFOR_RISPOSTA: 110,
|
||||
};
|
||||
|
||||
const Destin = {
|
||||
STAFF: 1,
|
||||
TUTTI: 2,
|
||||
NO_7_REQ: 3,
|
||||
NO_9_REQ: 4,
|
||||
SI_INVITATI_NO_7REQ_INVITATI: 5,
|
||||
A_UTENTE: 6,
|
||||
MSG_TO_NAVE: 7,
|
||||
};
|
||||
|
||||
const StatusMSGALL = {
|
||||
NONE: 0,
|
||||
ASK: 1,
|
||||
@@ -178,7 +210,7 @@ const txt = {
|
||||
MSG_SCEGLI_MENU: emoji.get('dizzy') + ' Scegli una voce di menu:' + emoji.get('dizzy'),
|
||||
MSG_ASK_USERNAME_BO: 'Scrivi nel messaggio lo username o la email con cui ti sei registrato sul sito di %s:',
|
||||
MSG_ERRORE_USERNAME: 'Attenzione! Devi inserire solo lo username (40 caratteri massimo)',
|
||||
MSG_ERRORE_USERNAME_NOT_FOUND: 'Per Completare la Verifica Telegram BOT, devi ora scrivere qui sotto nel messaggio l\'Username o la email con cui ti sei registrato sul sito di AYNI:',
|
||||
MSG_ERRORE_USERNAME_NOT_FOUND: 'Per Completare la Verifica Telegram BOT, devi ora scrivere qui sotto nel messaggio l\'Username OPPURE la email con cui ti sei registrato sul sito di AYNI:',
|
||||
MSG_ERRORE_USERNAME_ANNULLA: 'Inserimento Annullato. Riprovare',
|
||||
MSG_OPERAZ_ANNULLATA: 'Operazione Annullata',
|
||||
MSG_ERRORE_VERIFY_CODE_MAXLEN: 'Attenzione! Devi inserire solo il codice a 6 cifre',
|
||||
@@ -191,6 +223,7 @@ const txt = {
|
||||
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
|
||||
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + ' Si è appena Registrato "%s (n. %s)"\n(Invitato da %s)',
|
||||
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
||||
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
|
||||
MSG_MSG_INCORSO: emoji.get('envelope') + ' messaggi in corso... Inviati attualmente',
|
||||
};
|
||||
|
||||
@@ -206,6 +239,10 @@ module.exports = {
|
||||
REGISTRATION: 1
|
||||
},
|
||||
|
||||
getCiao: function (idapp, username, lang) {
|
||||
return tools.gettranslate('CIAO', lang) + ' ' + username + '!\n';
|
||||
},
|
||||
|
||||
notifyToTelegram: async function (phase, mylocalsconf) {
|
||||
let userdest = mylocalsconf.user.aportador_solidario;
|
||||
let NameFrom = `${mylocalsconf.user.name} ${mylocalsconf.user.surname}`;
|
||||
@@ -243,9 +280,11 @@ module.exports = {
|
||||
const usersmanagers = await User.getusersManagers(idapp);
|
||||
// console.log('usersmanagers', usersmanagers);
|
||||
|
||||
tools.writeManagersLog(text);
|
||||
|
||||
if (usersmanagers) {
|
||||
for (const rec of usersmanagers) {
|
||||
this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + '[BOT-STAFF]' + emo.ADMIN + ': ' + text)
|
||||
await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + '[BOT-STAFF]' + emo.ADMIN + ': ' + text, undefined, undefined, true);
|
||||
await tools.snooze(300)
|
||||
}
|
||||
}
|
||||
@@ -253,13 +292,74 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
getMsgByTipoMsg: function (mydata, lang, user) {
|
||||
if (!!mydata.msgextra) {
|
||||
return mydata.msgextra;
|
||||
}
|
||||
|
||||
if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) {
|
||||
return printf(tools.gettranslate('SEND_LINK_CHAT_DONATORI', lang), user.name, mydata.msgpar1);
|
||||
}
|
||||
},
|
||||
|
||||
sendMsgTelegramToNave: async function (idapp, mydata) {
|
||||
let nummsgsent = 0;
|
||||
let strout = '';
|
||||
|
||||
try {
|
||||
const arrnavi = await Nave.getusersByNave(idapp, mydata.navemediatore);
|
||||
|
||||
|
||||
// console.log('usersmanagers', usersmanagers);
|
||||
|
||||
tools.writeManagersLog('sendMsgTelegramToNave');
|
||||
|
||||
if (arrnavi) {
|
||||
for (const nave of arrnavi) {
|
||||
const user = await User.findByIndOrder(idapp, nave.ind_order);
|
||||
if (!!user) {
|
||||
const lang = user.lang;
|
||||
const idteleg = user.profile.teleg_id;
|
||||
const mymsg = this.getMsgByTipoMsg(mydata, lang, user);
|
||||
|
||||
if (!!idteleg) {
|
||||
strout += '\n' + user.name + ' ' + user.surname + ':';
|
||||
if (mydata.inviareale) {
|
||||
await this.sendMsgTelegramByIdTelegram(idapp, idteleg, mymsg, undefined, undefined, true);
|
||||
await tools.snooze(300);
|
||||
strout += ' -> MSG INVIATO';
|
||||
} else {
|
||||
strout += ' (Pronto da Inviare)';
|
||||
}
|
||||
nummsgsent++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nummsgsent > 0) {
|
||||
if (mydata.tipomsg === tools.TipoMsg.SEND_LINK_CHAT_DONATORI) {
|
||||
const fields_to_update = {
|
||||
sent_msg_howto_make_gift: true
|
||||
};
|
||||
await Nave.findOneAndUpdate({ _id: mydata.navemediatore.id }, { $set: fields_to_update }, { new: false });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return { nummsgsent, strout };
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return { nummsgsent , strout };
|
||||
}
|
||||
},
|
||||
|
||||
sendMsgTelegramToTheAdmin: async function (idapp, text) {
|
||||
const usersmanagers = await User.getusersManagers(idapp);
|
||||
|
||||
if (usersmanagers) {
|
||||
for (const rec of usersmanagers) {
|
||||
if (User.isAdmin(rec.perm)) {
|
||||
this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + '[BOT-STAFF]' + emo.ADMIN + ': ' + text)
|
||||
this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id, emo.ROBOT_FACE + '[BOT-ADMIN]' + emo.ADMIN + ': ' + text, undefined, undefined, true);
|
||||
await tools.snooze(300)
|
||||
}
|
||||
}
|
||||
@@ -280,16 +380,19 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
sendMsgTelegram: async function (idapp, username, text) {
|
||||
sendMsgTelegram: async function (idapp, username, text, alsotomanagers) {
|
||||
const teleg_id = await User.TelegIdByUsername(idapp, username);
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl && teleg_id) {
|
||||
await cl.sendMsg(teleg_id, text)
|
||||
}
|
||||
|
||||
if (alsotomanagers) {
|
||||
await this.sendMsgTelegramToTheManagers(idapp, text)
|
||||
}
|
||||
},
|
||||
|
||||
sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text, message_id, chat_id) {
|
||||
sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec) {
|
||||
if (!idtelegram)
|
||||
return;
|
||||
|
||||
@@ -297,7 +400,7 @@ module.exports = {
|
||||
if (cl && idtelegram) {
|
||||
let myform = null;
|
||||
|
||||
return await cl.sendMsg(idtelegram, text, null, null, message_id, chat_id)
|
||||
return await cl.sendMsg(idtelegram, text, null, null, message_id, chat_id, ripr_menuPrec)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -307,9 +410,16 @@ module.exports = {
|
||||
async function sendMsgTelegramToTheAdmin(idapp, text, msg) {
|
||||
const usersmanagers = await User.getusersManagers(idapp);
|
||||
|
||||
const username = msg.chat.username;
|
||||
const clorig = getclTelegByidapp(idapp);
|
||||
const rec = clorig.getRecInMem(msg);
|
||||
let username = '';
|
||||
if (!!rec) {
|
||||
username = rec.username_bo;
|
||||
} else {
|
||||
username = msg.chat.username;
|
||||
}
|
||||
|
||||
text = emo.ROBOT_FACE + '[BOT-ADMIN]' + emo.ADMIN + ': Da ' + msg.chat.first_name + ' ' + msg.chat.last_name + ' (' + username + '): \n' + text;
|
||||
text = emo.ROBOT_FACE + '[BOT-ADMIN]' + emo.ADMIN + ': Da ' + msg.chat.first_name + ' ' + msg.chat.last_name + ' [' + username + ']: \n' + text;
|
||||
tools.writeEventsLog(text);
|
||||
|
||||
if (usersmanagers) {
|
||||
@@ -328,10 +438,25 @@ async function sendMsgTelegramToTheAdmin(idapp, text, msg) {
|
||||
|
||||
}
|
||||
|
||||
async function local_sendMsgTelegramToTheManagers(idapp, text, msg) {
|
||||
function getusernameByUser(idapp, msg) {
|
||||
let username = '';
|
||||
let rec = this.getRecInMem(msg);
|
||||
if (!!rec)
|
||||
username = rec.username_bo;
|
||||
|
||||
if (username === '') {
|
||||
username = msg.chat.username;
|
||||
}
|
||||
|
||||
return username;
|
||||
}
|
||||
|
||||
async function local_sendMsgTelegramToTheManagers(idapp, text, msg, username_bo) {
|
||||
const usersmanagers = await User.getusersManagers(idapp);
|
||||
|
||||
const username = msg.chat.username;
|
||||
let username = msg.chat.username;
|
||||
if (username_bo)
|
||||
username = username_bo;
|
||||
|
||||
text = emo.ROBOT_FACE + '[BOT-STAFF]' + emo.ADMIN + ': Da ' + msg.chat.first_name + ' ' + msg.chat.last_name + ' (' + username + '): \n' + text;
|
||||
tools.writeEventsLog(text);
|
||||
@@ -341,7 +466,7 @@ async function local_sendMsgTelegramToTheManagers(idapp, text, msg) {
|
||||
const idtelegram = rec.profile.teleg_id;
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl && idtelegram) {
|
||||
await cl.sendMsg(idtelegram, text)
|
||||
await cl.sendMsg(idtelegram, text, undefined, undefined, undefined, undefined, true)
|
||||
}
|
||||
await tools.snooze(300)
|
||||
}
|
||||
@@ -489,10 +614,10 @@ class Telegram {
|
||||
contastiera = true;
|
||||
} else if (MsgBot.UGUALE.includes(testo)) {
|
||||
risp = testo;
|
||||
} else if (MsgBot.CHI_E_VISTAR.includes(testo)) {
|
||||
risp = 'Vistar è un nomade che vive in Perù tra i selvaggi, filosofeggiando e cazzeggiando qua e la... Per questo è un Fico ed è adulato dalle ragazze di tutto il Globo ' + emo.JOY + emo.JOY + emo.JOY;
|
||||
} else if (MsgBot.CHI_E_PAOLO.includes(testo)) {
|
||||
risp = 'Paolo è il Programmatore Sborone di AYNI. Anche lui Fico quanto Vistar (ma chi è Vistar) ' + emo.JOY + ' che anzichè creare la Billettera cazzeggia su AYNI BOT, trovando risposte alle domande più assurde.' + emo.JOY2 + emo.JOY2;
|
||||
// } else if (MsgBot.CHI_E_VISTAR.includes(testo)) {
|
||||
// risp = 'Vistar è un nomade che vive in Perù tra i selvaggi, filosofeggiando e cazzeggiando qua e la... Per questo è un Fico ed è adulato dalle ragazze di tutto il Globo ' + emo.JOY + emo.JOY + emo.JOY;
|
||||
// } else if (MsgBot.CHI_E_PAOLO.includes(testo)) {
|
||||
// risp = 'Paolo è il Programmatore Sborone di AYNI. Anche lui Fico quanto Vistar (ma chi è Vistar) ' + emo.JOY + ' che anzichè creare la Nave cazzeggia su AYNI BOT, trovando risposte alle domande più assurde.' + emo.JOY2 + emo.JOY2;
|
||||
} else if (MsgBot.COME_SI_CHIAMA.includes(testo)) {
|
||||
risp = 'Eh non te lo posso dire! ' + emo.JOY;
|
||||
} else if (MsgBot.GRAZIE.includes(testo.replace('!', ''))) {
|
||||
@@ -530,11 +655,11 @@ class Telegram {
|
||||
risp = 'Da te non me l\'aspettavo proprio !! ' + emo.INNOCENT + emo.CROSS_ROSSA;
|
||||
} else if (MsgBot.HAHA.find((rec) => testo.indexOf(rec) > -1) && testo.length < 8) {
|
||||
risp = emo.JOY + emo.JOY + emo.JOY;
|
||||
} else {
|
||||
} else if (testo.length > 1) {
|
||||
noanswer = true;
|
||||
risp = 'Non ti capisco... d\'altronde sono solo un Robot ' + emo.ROBOT_FACE + emo.JOY2 + '\n\n(Per AIUTO, contatta la Chat AYNI - HELP)';
|
||||
// risp += '\nClicca qui per entrare nella Chat AYNI - HELP di Supporto\n' + 'https://t.me/joinchat/C741mlVmB_RMcOUpNqWC8w' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !';
|
||||
await sendMsgTelegramToTheAdmin(this.idapp, testo, msg);
|
||||
await local_sendMsgTelegramToTheManagers(this.idapp, testo, msg, rec.username_bo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,22 +676,22 @@ class Telegram {
|
||||
}
|
||||
|
||||
if (rec.numdomande > 3 && rec.msgcodeprec === '') {
|
||||
if (rec.user) {
|
||||
const dashboard = await User.getDashboard(this.idapp, rec.user.aportador_solidario, rec.user.username, rec.user.aportador_solidario_name_surname);
|
||||
|
||||
risp += '\n\nNel frattempo ti ricordo che ';
|
||||
if (dashboard.myself.numinvitati === 1)
|
||||
risp += 'hai solo ' + dashboard.myself.numinvitati + ' invitato!';
|
||||
else if (dashboard.myself.numinvitati === 0)
|
||||
risp += 'ancora non hai portato nessun Invitato! ' + emo.LEFT_FACING_FIST;
|
||||
else if (dashboard.myself.numinvitati > 2)
|
||||
risp += 'hai ' + dashboard.myself.numinvitati + ' invitati !' + emo.STARS;
|
||||
|
||||
risp += '\n\nSei già entrato nella Chat di EMPOWER?';
|
||||
rec.msgcodeprec = MsgBot.CHAT_EMPOWER;
|
||||
rec.statusmsg = Status.WAITFOR_RISPOSTA;
|
||||
rec.numdomande = 0;
|
||||
}
|
||||
// if (rec.user) {
|
||||
// const dashboard = await User.getDashboard(this.idapp, rec.user.aportador_solidario, rec.user.username, rec.user.aportador_solidario_name_surname);
|
||||
//
|
||||
// risp += '\n\nNel frattempo ti ricordo che ';
|
||||
// if (dashboard.myself.numinvitati === 1)
|
||||
// risp += 'hai solo ' + dashboard.myself.numinvitati + ' invitato!';
|
||||
// else if (dashboard.myself.numinvitati === 0)
|
||||
// risp += 'ancora non hai portato nessun Invitato! ' + emo.LEFT_FACING_FIST;
|
||||
// else if (dashboard.myself.numinvitati > 2)
|
||||
// risp += 'hai ' + dashboard.myself.numinvitati + ' invitati !' + emo.STARS;
|
||||
//
|
||||
// risp += '\n\nSei già entrato nella Chat di EMPOWER?';
|
||||
// rec.msgcodeprec = MsgBot.CHAT_EMPOWER;
|
||||
// rec.statusmsg = Status.WAITFOR_RISPOSTA;
|
||||
// rec.numdomande = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
if (risp !== '') {
|
||||
@@ -607,8 +732,27 @@ class Telegram {
|
||||
if (msg.text === undefined)
|
||||
return;
|
||||
|
||||
const arrtext = msg.text.split(" ");
|
||||
let cmd2 = "";
|
||||
let cmd1 = arrtext[0];
|
||||
if (arrtext.length > 1)
|
||||
cmd2 = arrtext[1];
|
||||
|
||||
let oldusername = rec.msgall_username_specifico;
|
||||
|
||||
if ((msg.text === Menu.ESCI_DA_CHAT) || (msg.text === Menu.INDIETRO)) {
|
||||
rec.msgall_username_specifico = '';
|
||||
} else {
|
||||
if (rec.msgall_username_specifico !== '') {
|
||||
await this.SendMsgToUser(msg, rec, rec.msgall_username_specifico, msg.text);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.text === Menu.LAVAGNA || MsgBot.LAVAGNA.find((rec) => msg.text.indexOf(rec) > -1)) {
|
||||
await this.menuLavagna(msg)
|
||||
await this.menuLavagna(msg);
|
||||
} else if (msg.text === Menu.MIANAVE || (cmd2 === strNave) || MsgBot.MIANAVE.find((rec) => msg.text.indexOf(rec) > -1)) {
|
||||
await this.menuNave(msg)
|
||||
} else if (msg.text === Menu.ACCEDI) {
|
||||
await this.menuAccedi(msg)
|
||||
} else if (msg.text === Menu.LINK_CONDIVIDERE) {
|
||||
@@ -621,8 +765,21 @@ class Telegram {
|
||||
await this.menumsgAll(msg)
|
||||
} else if (msg.text === Menu.MSGSTAFF) {
|
||||
await this.menumsgStaff(msg)
|
||||
} else if (msg.text === Menu.MSG_NO_7_REQ) {
|
||||
await this.menumsg_No_7_Req(msg)
|
||||
} else if (msg.text === Menu.MSG_NO_9_REQ) {
|
||||
await this.menumsg_No_9_Req(msg)
|
||||
} else if (cmd1 === Menu.MSG_TO_NAVE) {
|
||||
await this.menumsg_to_Nave(msg, cmd2)
|
||||
} else if (msg.text === Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI) {
|
||||
await this.menumsg_Si_Invitati_No_7Req(msg)
|
||||
} else if (cmd1.toLowerCase() === Menu.MSG_TO_USER) {
|
||||
await this.menumsg_A_Utente(msg)
|
||||
} else if (msg.text === Menu.INDIETRO) {
|
||||
await this.msgScegliMenu(msg);
|
||||
} else if (msg.text === Menu.ESCI_DA_CHAT) {
|
||||
await this.sendMsg(msg.chat.id, 'Uscito dalla Chat con ' + oldusername);
|
||||
rec.msgall_username_specifico = '';
|
||||
} else {
|
||||
await this.isMenuNotVerified(rec, msg);
|
||||
}
|
||||
@@ -747,16 +904,16 @@ class Telegram {
|
||||
}
|
||||
|
||||
|
||||
if (dashboard.downnotreg) {
|
||||
if (dashboard.downnotreg.length > 0) {
|
||||
mystr += '\n' + emo.QUESTION_MARK + ' ' + tools.get__('NONREG', msg) + ':' + emo.QUESTION_MARK + '\n';
|
||||
let index = 1;
|
||||
dashboard.downnotreg.forEach((user) => {
|
||||
mystr += ` - ${index}°: ${user.name} ${user.surname} (tel: ${user.cell_complete})\n`;
|
||||
index++;
|
||||
});
|
||||
}
|
||||
}
|
||||
// if (dashboard.downnotreg) {
|
||||
// if (dashboard.downnotreg.length > 0) {
|
||||
// mystr += '\n' + emo.QUESTION_MARK + ' ' + tools.get__('NONREG', msg) + ':' + emo.QUESTION_MARK + '\n';
|
||||
// let index = 1;
|
||||
// dashboard.downnotreg.forEach((user) => {
|
||||
// mystr += ` - ${index}°: ${user.name} ${user.surname} (tel: ${user.cell_complete})\n`;
|
||||
// index++;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
if (tuttie9)
|
||||
mystr += '\n' + printf(tools.get__('INFO_LAVAGNA_SITO', msg));
|
||||
@@ -768,7 +925,6 @@ class Telegram {
|
||||
|
||||
async menuLavagna(msg) {
|
||||
const rec = this.getRecInMem(msg);
|
||||
// console.log('rec', rec);
|
||||
let mystr = '';
|
||||
if (rec.user) {
|
||||
mystr = await this.getLavagnaByUser(rec.user, msg)
|
||||
@@ -778,6 +934,30 @@ class Telegram {
|
||||
await this.sendMsg(msg.chat.id, mystr);
|
||||
}
|
||||
|
||||
async menuNave(msg) {
|
||||
const rec = this.getRecInMem(msg);
|
||||
let mystr = '';
|
||||
if (!rec.user)
|
||||
return "";
|
||||
|
||||
let ind_order_to_check = rec.user.ind_order;
|
||||
let arrstringa = msg.text.split(" ");
|
||||
|
||||
if (!!arrstringa) {
|
||||
if (arrstringa.length > 1) {
|
||||
let last = arrstringa.slice(-1)[0];
|
||||
if (!isNaN(last)) {
|
||||
ind_order_to_check = last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mystr = await Nave.getNaveByUser(this.idapp, ind_order_to_check, rec.user.lang, true);
|
||||
|
||||
if (!!mystr)
|
||||
await this.sendMsg(msg.chat.id, mystr);
|
||||
}
|
||||
|
||||
|
||||
async menuLinkCondividere(msg) {
|
||||
const rec = this.getRecInMem(msg);
|
||||
@@ -823,7 +1003,7 @@ class Telegram {
|
||||
|
||||
|
||||
if (iniziata) {
|
||||
mystr += emo.CHECK_VERDE + ' ' + tools.get__('ZOOM_INIZIATO') + ' ' + emo.CHECK_VERDE + '\n';
|
||||
mystr += emo.CHECK_VERDE + ' ' + tools.get__('ZOOM_INIZIATO') + ' ' + emo.CHECK_VERDE + '\n';
|
||||
}
|
||||
|
||||
mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start)} ${emo.EYES}`;
|
||||
@@ -859,23 +1039,71 @@ class Telegram {
|
||||
this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
}
|
||||
|
||||
async menumsgAll(msg) {
|
||||
const rec = this.getRecInMem(msg);
|
||||
if (rec.user) {
|
||||
const mystr = 'Scrivi qui un Messaggio da inviare a TUTTI:';
|
||||
rec.msgall_status = StatusMSGALL.ASK;
|
||||
rec.msgall_staff = false;
|
||||
await this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
getDestinStr(msg, destin, rec) {
|
||||
if (destin === Destin.TUTTI)
|
||||
return 'TUTTI';
|
||||
else if (destin === Destin.STAFF)
|
||||
return 'STAFF';
|
||||
else if (destin === Destin.NO_7_REQ)
|
||||
return 'No 7 Requisiti';
|
||||
else if (destin === Destin.NO_9_REQ)
|
||||
return 'No 9 Requisiti';
|
||||
else if (destin === Destin.SI_INVITATI_NO_7REQ_INVITATI)
|
||||
return '2 Invitati ma NO Requisiti';
|
||||
else if (destin === Destin.MSG_TO_NAVE)
|
||||
return 'Nave ' + rec.extraparam;
|
||||
else if (destin === Destin.A_UTENTE) {
|
||||
const rec = this.getRecInMem(msg);
|
||||
return rec.msgall_username_specifico
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async menumsgAll(msg) {
|
||||
await this.menumsgGenerico(msg, Destin.TUTTI);
|
||||
}
|
||||
|
||||
async menumsgStaff(msg) {
|
||||
await this.menumsgGenerico(msg, Destin.STAFF);
|
||||
}
|
||||
|
||||
async menumsg_No_7_Req(msg) {
|
||||
await this.menumsgGenerico(msg, Destin.NO_7_REQ);
|
||||
}
|
||||
|
||||
async menumsg_No_9_Req(msg) {
|
||||
await this.menumsgGenerico(msg, Destin.NO_9_REQ);
|
||||
}
|
||||
|
||||
async menumsg_to_Nave(msg, nave) {
|
||||
await this.menumsgGenerico(msg, Destin.MSG_TO_NAVE, undefined, nave);
|
||||
}
|
||||
|
||||
async menumsg_Si_Invitati_No_7Req(msg) {
|
||||
await this.menumsgGenerico(msg, Destin.SI_INVITATI_NO_7REQ_INVITATI);
|
||||
}
|
||||
|
||||
async menumsg_A_Utente(msg) {
|
||||
const arr = msg.text.split(' ');
|
||||
if (!!arr && arr.length > 1) {
|
||||
const username = arr[1];
|
||||
const rec = this.getRecInMem(msg);
|
||||
rec.msg_wait = true;
|
||||
await this.SendMsgToUser(msg, rec, username, msg.text);
|
||||
}
|
||||
}
|
||||
|
||||
async menumsgGenerico(msg, dest, username, extraparam) {
|
||||
const rec = this.getRecInMem(msg);
|
||||
if (rec.user) {
|
||||
const mystr = 'Scrivi qui un Messaggio da inviare allo STAFF:';
|
||||
rec.msgall_status = StatusMSGALL.ASK;
|
||||
rec.msgall_staff = true;
|
||||
await this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
rec.msgall_achi = dest;
|
||||
rec.extraparam = extraparam;
|
||||
if (!!username) {
|
||||
rec.msgall_username_specifico = username;
|
||||
}
|
||||
const mystr = 'Scrivi qui un Messaggio da inviare a' + ' [' + this.getDestinStr(msg, dest, rec) + ']:';
|
||||
await this.sendMsg(msg.chat.id, mystr, MenuSend);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -918,6 +1146,14 @@ class Telegram {
|
||||
return this.arrUsers.find((rec) => rec.id === id);
|
||||
}
|
||||
|
||||
getRecByUsername(username) {
|
||||
return this.arrUsers.find((rec) => rec.username_bo === username);
|
||||
}
|
||||
|
||||
getRecInMemById(id) {
|
||||
return this.arrUsers.find((rec) => rec.id === id);
|
||||
}
|
||||
|
||||
deleteRecInMem(msg) {
|
||||
this.arrUsers = this.arrUsers.filter((rec) => rec.id !== msg.from.id);
|
||||
}
|
||||
@@ -925,7 +1161,8 @@ class Telegram {
|
||||
async getUser(msg, rec, conmsg) {
|
||||
let myid = 0;
|
||||
let ok = false;
|
||||
const user = await User.findByUsername(this.idapp, msg.text.trim(), true);
|
||||
let mystruser = tools.getFirstWord(msg.text.trim());
|
||||
const user = await User.findByUsername(this.idapp, mystruser, true);
|
||||
if (!user) {
|
||||
if (conmsg) {
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND, MenuNoLogin);
|
||||
@@ -1029,54 +1266,143 @@ class Telegram {
|
||||
}
|
||||
}
|
||||
|
||||
async sendMsgToAll(rec, msg, texttosend, solostaff) {
|
||||
if (texttosend.length < 3) {
|
||||
} else {
|
||||
const usersall = await User.getUsersTelegALL(rec.user.idapp);
|
||||
|
||||
let nummsgsent = 0;
|
||||
|
||||
let textdainviare = "";
|
||||
|
||||
if (texttosend === Menu.ZOOM) {
|
||||
texttosend = await this.getNextZoom()
|
||||
async sistemaRecDest(rec, msg) {
|
||||
let recdest = this.getRecByUsername(rec.msgall_username_specifico);
|
||||
if (!recdest) {
|
||||
const userdest = await User.findByUsername(this.idapp, rec.msgall_username_specifico);
|
||||
if (!!userdest) {
|
||||
let msgdest = msg;
|
||||
msgdest.from.id = userdest.profile.teleg_id;
|
||||
await this.createIfNotExist(msgdest);
|
||||
recdest = this.getRecByUsername(rec.msgall_username_specifico);
|
||||
}
|
||||
|
||||
if (usersall) {
|
||||
if (solostaff)
|
||||
tools.writeEventsLog('[MSG_A_STAFF]: ' + texttosend);
|
||||
else
|
||||
tools.writeEventsLog('[MSG_A_TUTTI]: ' + texttosend);
|
||||
|
||||
for (const utente of usersall) {
|
||||
|
||||
if (texttosend === Menu.LAVAGNA) {
|
||||
textdainviare = await this.getLavagnaByUser(utente, msg);
|
||||
} else {
|
||||
textdainviare = texttosend;
|
||||
}
|
||||
let invia = true;
|
||||
if (solostaff) {
|
||||
invia = User.isManager(utente.perm)
|
||||
}
|
||||
if (invia) {
|
||||
await this.sendMsg(utente.profile.teleg_id, textdainviare);
|
||||
nummsgsent++;
|
||||
await tools.snooze(300)
|
||||
}
|
||||
|
||||
if ((nummsgsent % 100) === 0)
|
||||
myid = await this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_INCORSO), null, { message_id: myid });
|
||||
|
||||
// ++Todo: SLEEP ??? sleep(0.03)
|
||||
}
|
||||
}
|
||||
|
||||
await this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_SENT));
|
||||
}
|
||||
rec.start_write_msgall = false;
|
||||
if (!!recdest) {
|
||||
recdest.msgall_username_specifico = rec.username_bo;
|
||||
} else {
|
||||
rec.msgall_username_specifico = '';
|
||||
}
|
||||
|
||||
return recdest
|
||||
}
|
||||
|
||||
|
||||
async sendMsgToAll(rec, msg, texttosend, destin) {
|
||||
try {
|
||||
if ((texttosend.length < 3) && (destin !== Destin.A_UTENTE)) {
|
||||
} else {
|
||||
|
||||
let usersall = null;
|
||||
if (destin === Destin.A_UTENTE)
|
||||
usersall = await User.getUsersTelegALL(rec.user.idapp, rec.msgall_username_specifico);
|
||||
else
|
||||
usersall = await User.getUsersTelegALL(rec.user.idapp);
|
||||
|
||||
let nummsgsent = 0;
|
||||
|
||||
let textdainviare = "";
|
||||
let preparatesto = '';
|
||||
let myid = '';
|
||||
|
||||
if (texttosend === Menu.ZOOM) {
|
||||
texttosend = await this.getNextZoom()
|
||||
}
|
||||
|
||||
const cmd = texttosend.toLowerCase();
|
||||
|
||||
if (usersall) {
|
||||
if (cmd === Menu.INDIETRO) {
|
||||
rec.msgall_status = StatusMSGALL.NONE;
|
||||
return
|
||||
}
|
||||
|
||||
tools.writeEventsLog(this.getDestinStr(msg, destin, rec) + ':\n' + texttosend);
|
||||
|
||||
for (const utente of usersall) {
|
||||
|
||||
if (texttosend === Menu.LAVAGNA) {
|
||||
textdainviare = await this.getLavagnaByUser(utente, msg);
|
||||
} else if (destin === Destin.A_UTENTE) {
|
||||
textdainviare = texttosend;
|
||||
} else {
|
||||
textdainviare = texttosend;
|
||||
}
|
||||
|
||||
let invia = false;
|
||||
if (destin === Destin.STAFF) {
|
||||
invia = User.isManager(utente.perm);
|
||||
} else if (destin === Destin.TUTTI) {
|
||||
invia = true;
|
||||
} else if (destin === Destin.A_UTENTE) {
|
||||
invia = utente.username === rec.msgall_username_specifico;
|
||||
} else if (destin === Destin.NO_7_REQ) {
|
||||
invia = !await User.isUserQualified7(this.idapp, utente.username);
|
||||
} else if (destin === Destin.NO_9_REQ) {
|
||||
invia = !await User.isUserQualified9(this.idapp, utente.username);
|
||||
} else if (destin === Destin.MSG_TO_NAVE) {
|
||||
invia = !await Nave.findDonatoreByNave(this.idapp, rec.extraparam);
|
||||
} else if (destin === Destin.SI_INVITATI_NO_7REQ_INVITATI) {
|
||||
const numinvitati = await User.getnumInvitati(this.idapp, utente.username);
|
||||
const numinvitatiattivi = await User.getnumInvitatiAttivi(this.idapp, utente.username);
|
||||
invia = (numinvitati >= 2) && (numinvitatiattivi < 2);
|
||||
}
|
||||
if (invia) {
|
||||
if (cmd === RICEVI_EMAIL) {
|
||||
preparatesto += utente.email + ', ';
|
||||
} else if (cmd === CONTA_SOLO) {
|
||||
// Niente
|
||||
} else {
|
||||
if (destin === Destin.A_UTENTE) {
|
||||
await this.sistemaRecDest(rec, msg);
|
||||
await this.sendMsg(utente.profile.teleg_id, '[' + rec.username_bo + ' ti scrive]:\n' + textdainviare, MenuChat);
|
||||
} else {
|
||||
await this.sendMsg(utente.profile.teleg_id, textdainviare);
|
||||
}
|
||||
await tools.snooze(300)
|
||||
}
|
||||
nummsgsent++;
|
||||
|
||||
if (!SendMsgCmd.includes(cmd)) {
|
||||
if ((nummsgsent % 50) === 0) {
|
||||
myid = await this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_INCORSO), null, { message_id: myid });
|
||||
await tools.snooze(300)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let msgris = "";
|
||||
if (cmd === CONTA_SOLO) {
|
||||
msgris = nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_TOSENT);
|
||||
} else if (cmd === RICEVI_EMAIL) {
|
||||
msgris = nummsgsent + ' ' + 'Email';
|
||||
await this.sendMsg(msg.chat.id, msgris);
|
||||
msgris = preparatesto;
|
||||
} else {
|
||||
msgris = nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_SENT);
|
||||
}
|
||||
|
||||
if (destin === Destin.A_UTENTE) {
|
||||
const recdest = await this.sistemaRecDest(rec);
|
||||
if (!!recdest) {
|
||||
await this.sendMsg(msg.chat.id, 'Conversazione Iniziata con ' + rec.msgall_username_specifico + ' !', MenuChat);
|
||||
} else {
|
||||
await this.sendMsg(msg.chat.id, 'Utente ' + rec.msgall_username_specifico + ' non presente sul BOT !');
|
||||
}
|
||||
} else {
|
||||
tools.writeEventsLog(msgris);
|
||||
await this.sendMsg(msg.chat.id, msgris);
|
||||
}
|
||||
|
||||
}
|
||||
rec.start_write_msgall = false;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
selectMenuHelp(msg) {
|
||||
return ((msg.text === Menu.INFO) || (msg.text === Menu.ASSISTENZA))
|
||||
}
|
||||
@@ -1106,8 +1432,7 @@ class Telegram {
|
||||
if (rec.msgall_status === StatusMSGALL.CONFIRM) {
|
||||
if (msg.text === Menu.SI) {
|
||||
// Take msg to send to ALL
|
||||
await
|
||||
this.sendMsgToAll(rec, msg, rec.msgtosent, rec.msgall_staff)
|
||||
await this.sendMsgToAll(rec, msg, rec.msgtosent, rec.msgall_achi)
|
||||
} else {
|
||||
this.sendMsg(msg.chat.id, txt.MSG_OPERAZ_ANNULLATA);
|
||||
}
|
||||
@@ -1117,10 +1442,20 @@ class Telegram {
|
||||
if (msg.text !== Menu.INDIETRO) {
|
||||
rec.msgtosent = msg.text;
|
||||
rec.msgall_status = StatusMSGALL.CONFIRM;
|
||||
let achi = "TUTTI";
|
||||
if (rec.msgall_staff)
|
||||
achi = "STAFF";
|
||||
const domanda = 'Confermi d\'Inviare questo messaggio a ' + achi + ' ?\n' + rec.msgtosent;
|
||||
const cmd = rec.msgtosent.toLowerCase();
|
||||
let achi = this.getDestinStr(msg, rec.msgall_achi, rec);
|
||||
let domanda = '';
|
||||
if (cmd === CONTA_SOLO)
|
||||
domanda = 'Confermi di vedere a quante persone arriverebbe questo messaggio, a ' + achi + ' ?\n' + rec.msgtosent;
|
||||
else if (cmd === RICEVI_EMAIL)
|
||||
domanda = 'Confermi di vedere la lista delle email di ' + achi + '?';
|
||||
else {
|
||||
if (rec.msgall_achi === Destin.A_UTENTE)
|
||||
domanda = 'Confermi d\'Iniziare una Chat messaggi con ' + achi + ' ?\n' + rec.msgtosent;
|
||||
else
|
||||
domanda = 'Confermi d\'Inviare questo messaggio a ' + achi + ' ?\n' + rec.msgtosent;
|
||||
}
|
||||
|
||||
this.ChiediSINO(msg, domanda);
|
||||
} else {
|
||||
rec.msgall_status = StatusMSGALL.NONE;
|
||||
@@ -1157,8 +1492,7 @@ class Telegram {
|
||||
|
||||
async setUser(msg) {
|
||||
const id = msg.from.id;
|
||||
const user = await
|
||||
User.UserByIdTelegram(this.idapp, id);
|
||||
const user = await User.UserByIdTelegram(this.idapp, id);
|
||||
let rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
|
||||
if (user && rec) {
|
||||
rec.user = user;
|
||||
@@ -1166,6 +1500,15 @@ class Telegram {
|
||||
|
||||
}
|
||||
|
||||
async setUserbyUsername(username) {
|
||||
const user = await User.findByUsername(this.idapp, username);
|
||||
let rec = this.arrUsers.find((rec) => rec.username_bo === username);
|
||||
if (user && rec) {
|
||||
rec.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async alreadyExist(msg) {
|
||||
const id = msg.from.id;
|
||||
let rec = null;
|
||||
@@ -1204,7 +1547,12 @@ class Telegram {
|
||||
retry: 0,
|
||||
username_bo: '',
|
||||
msgall_status: StatusMSGALL.NONE,
|
||||
msgall_achi: 0,
|
||||
msgall_username_specifico: '',
|
||||
extraparam: '',
|
||||
msgtosent: '',
|
||||
msg_wait: false,
|
||||
lastmenu: null,
|
||||
};
|
||||
|
||||
this.arrUsers.push(rec);
|
||||
@@ -1222,9 +1570,8 @@ class Telegram {
|
||||
async getKeyboard(id, menu) {
|
||||
let keyb = MenuStandard;
|
||||
// Check if you are Admin
|
||||
const ismanager = await
|
||||
User.isAdminByIdTeleg(this.idapp, id);
|
||||
if (ismanager)
|
||||
const ismanager = await User.isAdminByIdTeleg(this.idapp, id);
|
||||
if (ismanager && menu !== MenuChat)
|
||||
keyb = MenuPerAdmin;
|
||||
if (menu) {
|
||||
keyb = menu
|
||||
@@ -1247,7 +1594,7 @@ class Telegram {
|
||||
|
||||
}
|
||||
|
||||
async _inviaMsg(id, text, form, menu, msg_id, chat_id) {
|
||||
async _inviaMsg(id, text, form, menu, msg_id, chat_id, ripr_menuPrec) {
|
||||
if (!text)
|
||||
return 0;
|
||||
|
||||
@@ -1255,6 +1602,26 @@ class Telegram {
|
||||
return this.modificaMsg(chat_id, msg_id, text);
|
||||
}
|
||||
|
||||
const recmem = this.getRecInMemById(id);
|
||||
|
||||
if (!menu) {
|
||||
if (recmem) {
|
||||
if (recmem.msgall_username_specifico !== '') {
|
||||
menu = MenuChat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (recmem) {
|
||||
recmem.lastmenu = menu
|
||||
}
|
||||
|
||||
if (ripr_menuPrec) {
|
||||
if (recmem && !!recmem.lastmenu) {
|
||||
menu = recmem.lastmenu
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!form) {
|
||||
form = {
|
||||
@@ -1286,9 +1653,27 @@ class Telegram {
|
||||
}
|
||||
}
|
||||
|
||||
async sendMsg(id, text, menu, form, msg_id, chat_id) {
|
||||
async SendMsgToUser(msg, rec, username, text) {
|
||||
if (rec.msg_wait) {
|
||||
await this.menumsgGenerico(msg, Destin.A_UTENTE, username);
|
||||
rec.msg_wait = false;
|
||||
} else {
|
||||
const telegid = await User.TelegIdByUsername(this.idapp, username);
|
||||
if (telegid > 0) {
|
||||
await this.sistemaRecDest(rec, msg);
|
||||
// await this.sendMsg(msg.chat.id, '[Msg inviato a ' + username + ']: ');
|
||||
await this.sendMsg(telegid, Menu.CHAT_PERSONALE + '[' + rec.username_bo + ' ti scrive]:\n' + text, MenuChat);
|
||||
} else {
|
||||
await this.sendMsg(msg.chat.id, 'Username non valido');
|
||||
rec.msgall_username_specifico = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this._inviaMsg(id, text, form, menu, msg_id, chat_id);
|
||||
|
||||
async sendMsg(id, text, menu, form, msg_id, chat_id, ripr_menuPrec) {
|
||||
|
||||
return this._inviaMsg(id, text, form, menu, msg_id, chat_id, ripr_menuPrec);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user