Aggiornamenti
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const appTelegram = [tools.AYNI];
|
||||
const appTelegram = [tools.AYNI, tools.SIP];
|
||||
|
||||
const appTelegramFinti = ['2'];
|
||||
const appTelegramDest = [tools.AYNI];
|
||||
@@ -363,7 +363,7 @@ const txt_es = {
|
||||
|
||||
const txt_fr = {
|
||||
MSG_SCEGLI_MENU: emoji.get('dizzy') + 'Choisissez un élément de menu:' + emoji.get('dizzy'),
|
||||
MSG_ASK_USERNAME_BO: 'Écrivez dans le message l\'username ou l\'e-mail avec lequel vous vous êtes enregistré sur le site de% s: ',
|
||||
MSG_ASK_USERNAME_BO: 'Écrivez dans le message l\'username ou l\'e-mail avec lequel vous vous êtes enregistré sur le site de %s: ',
|
||||
MSG_ERRORE_USERNAME: 'Attention! Vous devez insérer seulement l’username (40 caractères maximum)',
|
||||
MSG_ERRORE_USERNAME_NOT_FOUND: 'Pour Compléter la Vérification Telegram BOT, vous devez maintenant écrire dans le message ci-dessous l\'Username ou l\'adresse e-mail avec lequel vous vous êtes inscrit sur le site AYNI: ',
|
||||
MSG_ERRORE_USERNAME_ANNULLA: 'Saisie des données Annullée.Essayez à nouveau ',
|
||||
@@ -383,15 +383,15 @@ const txt_fr = {
|
||||
|
||||
const txt_si = {
|
||||
MSG_SCEGLI_MENU: emoji.get('dizzy') + 'Izbirni meni:' + emoji.get('dizzy'),
|
||||
MSG_ASK_USERNAME_BO: 'Vpiši svoje uporabniško ime in e-naslov s katerimi si se registriral na spletni strani % s: ',
|
||||
MSG_ASK_USERNAME_BO: 'Vpiši svoje uporabniško ime in e-naslov s katerimi si se registriral na spletni strani %s: ',
|
||||
MSG_ERRORE_USERNAME: 'Pozor! Vpiši samo uporabniško ime (40 znakov) maksimalno',
|
||||
MSG_ERRORE_USERNAME_NOT_FOUND: 'Ponovno preverite telegram BOT Uporabniško ime ali e-poštno sporočilo, s katerim ste registrirali na spletni strani AYNI: ',
|
||||
MSG_ERRORE_USERNAME_ANNULLA: 'Preklic. Poskusi ponovno ',
|
||||
MSG_OPERAZ_ANNULLATA: 'Operacija preklicana',
|
||||
MSG_ERRORE_VERIFY_CODE_MAXLEN: 'Pozor! Vstavi D mestno kodo',
|
||||
MSG_VERIFY_CODE: '1. Vrni se na spletno strani AYNI: \n%s\n2. Kopiraj kodo Authenticazione (6 mestno) ki jo najdeš zgoraj zapisano\n3. Napiši (ali prilepi) tu spodaj kot sporočilo: ',
|
||||
MSG_ERR_VERIFY_CODE: 'Napačna koda za preverjanje!' + emo.EXCLAMATION_MARK + '\nPreveri na strani% s in ponovno napiši 6 mestno kodo.',
|
||||
MSG_VERIFY_OK: emoji.get('grinning') + 'Dobrodošel% s! Pravilno ste se preveriliz AYNI BOT. ' + ' \nsem tvoj virtualni asisten.\n ' +
|
||||
MSG_ERR_VERIFY_CODE: 'Napačna koda za preverjanje!' + emo.EXCLAMATION_MARK + '\nPreveri na strani %s in ponovno napiši 6 mestno kodo.',
|
||||
MSG_VERIFY_OK: emoji.get('grinning') + 'Dobrodošel %s! Pravilno ste se preveriliz AYNI BOT. ' + ' \nsem tvoj virtualni asisten.\n ' +
|
||||
'Vodenje se nadeljuje z vodenimi koraki, ko se vrneš na spletno stran AYNI. \n\nTa klepet ti bo služil za hitri pregled tvoje table in za sprejemanje pomembnih obvestil glede poteka tvojega potovanja. \n\nUporabite meni tu spodaj, da lahko kontrolirate svojo situacijo. ' + emo.GREEN_HEART,
|
||||
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Napaka strežnika.Poskusi kasneje ',
|
||||
MSG_EXIT_TELEGRAM: 'Račun se nahaja v programu Telegram BOT.',
|
||||
@@ -723,7 +723,7 @@ async function local_sendMsgTelegramToTheManagers(idapp, text, msg, username_bo)
|
||||
}
|
||||
|
||||
|
||||
function getstr(lang, key) {
|
||||
function getstr(lang, key, param1) {
|
||||
|
||||
let mystr = '';
|
||||
|
||||
@@ -760,9 +760,13 @@ function getstr(lang, key) {
|
||||
}
|
||||
|
||||
if (mystr === '')
|
||||
return txt[key];
|
||||
else
|
||||
return mystr;
|
||||
mystr = txt[key];
|
||||
|
||||
if (!!param1) {
|
||||
mystr = printf(mystr, param1);
|
||||
}
|
||||
|
||||
return mystr;
|
||||
}
|
||||
|
||||
class Telegram {
|
||||
@@ -804,6 +808,7 @@ class Telegram {
|
||||
rec.status = Status.VERIFIED
|
||||
} else {
|
||||
let prova = 1;
|
||||
// await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), 'MSG_ASK_USERNAME_BO', tools.getNomeAppByIdApp(this.idapp)), MenuNoLogin);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1045,7 +1050,7 @@ class Telegram {
|
||||
try {
|
||||
let miomenu2 = Menu['it'][key];
|
||||
trovato = (miomenu2 === menuselect);
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1323,7 +1328,8 @@ class Telegram {
|
||||
const rec = this.getRecInMem(msg);
|
||||
let mystr = '';
|
||||
if (rec.user) {
|
||||
mystr += printf(tools.get__('INFO_LINK_DA_CONDIVIDERE', this.getlang(msg)), tools.getHostByIdApp(this.idapp) + '/signup/' + rec.user.username, tools.getlinkzoom(''));
|
||||
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(''));
|
||||
await this.sendMsg(msg.chat.id, mystr);
|
||||
}
|
||||
}
|
||||
@@ -1567,7 +1573,9 @@ class Telegram {
|
||||
rec.user = ris.user;
|
||||
await User.SetTelegramCheckCode(this.idapp, ris.myid.toString(), rec.code);
|
||||
rec.status = Status.WAITFOR_VERIFY_CODE;
|
||||
await this.sendMsg(msg.from.id, printf(getstr(rec.user.lang, 'MSG_VERIFY_CODE'), tools.getHostByIdApp(this.idapp)), MenuNoLogin)
|
||||
await this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_VERIFY_CODE', tools.getHostByIdApp(this.idapp)), MenuNoLogin)
|
||||
} else {
|
||||
await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), 'MSG_ASK_USERNAME_BO', tools.getNomeAppByIdApp(this.idapp)), MenuNoLogin);
|
||||
}
|
||||
}
|
||||
} else if (text.length === 0) {
|
||||
@@ -1585,52 +1593,54 @@ class Telegram {
|
||||
|
||||
async setVerifyCode(msg) {
|
||||
try {
|
||||
const code = msg.text.toString().trim();
|
||||
const rec = this.getRecInMem(msg);
|
||||
const user = await User.findByUsername(this.idapp, rec.username_bo, true);
|
||||
let telegcode = 0;
|
||||
if (user) {
|
||||
telegcode = user.profile.teleg_checkcode.toString();
|
||||
} else {
|
||||
await
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_NOT_FOUND'), MenuNoLogin);
|
||||
return
|
||||
}
|
||||
if (code.length < 7) {
|
||||
if (rec) {
|
||||
if (code === telegcode) {
|
||||
// let ris = await this.getUser(msg, rec, false);
|
||||
rec.status = Status.VERIFIED;
|
||||
await User.SetTelegramIdSuccess(this.idapp, user._id, msg.from.id).then((recuser) => {
|
||||
if (recuser) {
|
||||
let name = recuser.name;
|
||||
this.sendMsg(msg.from.id, printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), name));
|
||||
local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' +recuser.lang + ')' + emo.STARS, msg);
|
||||
} else {
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERR_UNKNOWN_VERIFY_CODE'));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (rec.retry < 2) {
|
||||
rec.retry++;
|
||||
await
|
||||
this.sendMsg(msg.from.id, printf(getstr(this.getlang(msg), 'MSG_ERR_VERIFY_CODE'), tools.getHostByIdApp(this.idapp)));
|
||||
if (!!msg.text) {
|
||||
const code = msg.text.toString().trim();
|
||||
const rec = this.getRecInMem(msg);
|
||||
const user = await User.findByUsername(this.idapp, rec.username_bo, true);
|
||||
let telegcode = 0;
|
||||
if (user) {
|
||||
telegcode = user.profile.teleg_checkcode.toString();
|
||||
} else {
|
||||
await
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_NOT_FOUND'), MenuNoLogin);
|
||||
return
|
||||
}
|
||||
if (code.length < 7) {
|
||||
if (rec) {
|
||||
if (code === telegcode) {
|
||||
// let ris = await this.getUser(msg, rec, false);
|
||||
rec.status = Status.VERIFIED;
|
||||
await User.SetTelegramIdSuccess(this.idapp, user._id, msg.from.id).then((recuser) => {
|
||||
if (recuser) {
|
||||
let name = recuser.name;
|
||||
this.sendMsg(msg.from.id, printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), name));
|
||||
local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg);
|
||||
} else {
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERR_UNKNOWN_VERIFY_CODE'));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
rec.status = Status.NONE;
|
||||
await
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_ANNULLA'));
|
||||
this.deleteRecInMem(msg);
|
||||
if (rec.retry < 2) {
|
||||
rec.retry++;
|
||||
await
|
||||
this.sendMsg(msg.from.id, printf(getstr(this.getlang(msg), 'MSG_ERR_VERIFY_CODE'), tools.getHostByIdApp(this.idapp)));
|
||||
} else {
|
||||
rec.status = Status.NONE;
|
||||
await
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_ANNULLA'));
|
||||
this.deleteRecInMem(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (msg.text.length === 0) {
|
||||
if (rec)
|
||||
rec.status = Status.NONE;
|
||||
await
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_ANNULLA'))
|
||||
} else {
|
||||
await
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_VERIFY_CODE_MAXLEN'))
|
||||
}
|
||||
} else if (msg.text.length === 0) {
|
||||
if (rec)
|
||||
rec.status = Status.NONE;
|
||||
await
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_USERNAME_ANNULLA'))
|
||||
} else {
|
||||
await
|
||||
this.sendMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_ERRORE_VERIFY_CODE_MAXLEN'))
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error setVerifyCode', e);
|
||||
@@ -1690,54 +1700,55 @@ class Telegram {
|
||||
tools.writeEventsLog(this.getDestinStr(msg, destin, rec) + ':\n' + texttosend);
|
||||
|
||||
for (const utente of usersall) {
|
||||
|
||||
if (this.isSelMenu(msg, texttosend === '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
|
||||
if (!utente.deleted && !utente.sospeso) {
|
||||
if (this.isSelMenu(msg, texttosend === 'LAVAGNA')) {
|
||||
textdainviare = await this.getLavagnaByUser(utente, msg);
|
||||
} else if (destin === Destin.A_UTENTE) {
|
||||
textdainviare = texttosend;
|
||||
} 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)
|
||||
textdainviare = texttosend;
|
||||
}
|
||||
nummsgsent++;
|
||||
|
||||
if (!SendMsgCmd.includes(cmd)) {
|
||||
if ((nummsgsent % 50) === 0) {
|
||||
myid = await this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(this.getlang(msg), 'MSG_MSG_INCORSO'), null, { message_id: myid });
|
||||
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(this.getlang(msg), 'MSG_MSG_INCORSO'), null, { message_id: myid });
|
||||
await tools.snooze(300)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1779,7 +1790,7 @@ class Telegram {
|
||||
|
||||
selectMenuLang(msg) {
|
||||
return ((msg.text === Menu.LANG) || (msg.text === Menu.LANG_EN) || (msg.text === Menu.LANG_IT) || (msg.text === Menu.LANG_ES)
|
||||
|| (msg.text === Menu.LANG_FR) || (msg.text === Menu.LANG_SI) || (msg.text === Menu.LANG_PT) )
|
||||
|| (msg.text === Menu.LANG_FR) || (msg.text === Menu.LANG_SI) || (msg.text === Menu.LANG_PT))
|
||||
}
|
||||
|
||||
async receiveMsg(msg) {
|
||||
@@ -1857,7 +1868,7 @@ class Telegram {
|
||||
await this.addUser(msg);
|
||||
|
||||
// await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), printf(txt.MSG_ASK_USERNAME_BO, tools.getHostByIdApp(this.idapp))));
|
||||
await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), printf('MSG_ASK_USERNAME_BO', tools.getNomeAppByIdApp(this.idapp))), MenuNoLogin);
|
||||
await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), 'MSG_ASK_USERNAME_BO', tools.getNomeAppByIdApp(this.idapp)), MenuNoLogin);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -2108,8 +2119,7 @@ class Telegram {
|
||||
"resize_keyboard": true,
|
||||
"keyboard": await this.getKeyboard(msg.from.id, undefined, this.getlang(msg))
|
||||
}
|
||||
})
|
||||
;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user