Settore se compariva "Tutti", veniva selezionato erroneamente di default -100

Risolto caricamento immagini
Cliccando sull'immagine del profilo, nella Card, non si apre il Profilo
Aggiunto "Estero" e "On Line" sul campo Comune.
Orientamento dell'Immagine. viene storta una volta ridimensionata.
Al momento della registrazione, dal BOT, in automatico viene presa l'immagine di Telegram e salvata sul proprio profilo della APP.
This commit is contained in:
paoloar77
2022-03-01 23:50:58 +01:00
parent adf4918224
commit 310eefba14
11 changed files with 346 additions and 88 deletions

View File

@@ -133,12 +133,12 @@ MsgBot = {
'grazie😘'],
PRINCIPE_AZZURRO: ['principe azzurro'],
COSE_COVID: [
'cos\'è il covid',
'cosa è il covid',
],
'cos\'è il covid',
'cosa è il covid',
],
COVID: [
'covid',
],
'covid',
],
SPOSAMI: [
'sposami',
'vuoi sposar',
@@ -149,7 +149,11 @@ MsgBot = {
'mi sposi'],
CHE_TEMPO_FA: ['che tempo'],
NON_TROO_INVITATI: ['non trovo invitati', 'non riesco a trovare invitati'],
TROVAMI_UN_UOMO_DONNA: ['trovami un uomo', 'trovami una donna', 'esiste una donna per me', 'esiste un uomo per me'],
TROVAMI_UN_UOMO_DONNA: [
'trovami un uomo',
'trovami una donna',
'esiste una donna per me',
'esiste un uomo per me'],
PAROLACCE: [
'stronz',
'fanculo',
@@ -242,6 +246,7 @@ const Menu = {
MSG_TO_USER: 'sendmsgto',
ADMIN: emoji.get('information_desk_person') + ' Admin',
ALTRO: emoji.get('newspaper') + ' Altro',
SETPICPROFILE: '🖼 SetPicProfile',
// 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',
@@ -464,9 +469,9 @@ const txt = {
'Ti sei correttamente verificato con il BOT. ' +
'\nSono il tuo assistente virtuale (BOT).\n\n' +
'Questa chat ti servirà per interagire con la Piattaforma e per ricevere delle notifiche Personali.\n' +
''+
'' +
'(🆘 Per Aiuti, guarda il menu qui sotto)\n\n' +
''+
'' +
'😍😍😍 Ora sei pronto per Entrare nella APP!\n' +
'👉🏻 Clicca qui: %s',
MSG_SET_USERNAME: '✨✨✨✨✨✨✨✨✨✨\n' +
@@ -484,11 +489,12 @@ const txt = {
'Ora puoi proseguire sulla APP.',
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Errore durante il salvataggio sul Server. Riprovare piú tardi',
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + ' Si è appena Registrato "%s" (n. %s)\nInvitato da %s',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
' Si è appena Registrato "%s" (n. %s)\nInvitato da %s',
MSG_APORTADOR_ASK_CONFIRM: '🆕💥 🧍‍♂️ Abilita Nuova Registrazione: %s',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Abilitato correttamente!',
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei stato Abilitato correttamente da %s!\n' +
'Vai sulla App oppure clicca qui per entrare\n👉🏻 %s',
'Vai sulla App oppure clicca qui per entrare\n👉🏻 %s',
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
@@ -514,7 +520,8 @@ const txt_es = {
emo.EXCLAMATION_MARK +
'\nComprueba en el sitio %s y reescribe el nuevo código de 6 dígitos.',
MSG_VERIFY_OK: emoji.get('grinning') +
' Bienvenido %s! Ha verificado correctamente con el BOT. ' + emo.GREEN_HEART,
' Bienvenido %s! Ha verificado correctamente con el BOT. ' +
emo.GREEN_HEART,
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Error al guardar en el servidor. Inténtalo de nuevo más tarde.',
MSG_EXIT_TELEGRAM: 'La cuenta ha sido desconectada de Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emo.FIRE +
@@ -728,13 +735,16 @@ module.exports = {
aportador = ` (${userdest})`;
NameFrom += aportador;
} else {
aportador = mylocalsconf.user.aportador_solidario_nome_completo ? mylocalsconf.user.aportador_solidario_nome_completo : mylocalsconf.user.aportador_solidario;
aportador = mylocalsconf.user.aportador_solidario_nome_completo
? mylocalsconf.user.aportador_solidario_nome_completo
: mylocalsconf.user.aportador_solidario;
}
let text = '';
if (phase === this.phase.REGISTRATION) {
if (tools.getConfSiteOptionEnabledByIdApp(mylocalsconf.idapp, shared_consts.ConfSite.Notif_Reg_Bot_ToManagers)) {
if (tools.getConfSiteOptionEnabledByIdApp(mylocalsconf.idapp,
shared_consts.ConfSite.Notif_Reg_Bot_ToManagers)) {
if (userdest) {
NameFrom = await User.getNameSurnameByUsername(mylocalsconf.idapp,
userdest, true) + aportador;
@@ -761,7 +771,8 @@ module.exports = {
}
if (phase === this.phase.REGISTRATION) {
await this.askConfirmationUserRegistration(mylocalsconf.idapp, shared_consts.CallFunz.REGISTRATION,
await this.askConfirmationUserRegistration(mylocalsconf.idapp,
shared_consts.CallFunz.REGISTRATION,
mylocalsconf.user, userdest, langdest);
}
@@ -803,7 +814,8 @@ module.exports = {
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
},
sendMsgTelegramToTheManagers: async function(idapp, text, onlyintofile = false, MyForm = null, nottousername = '') {
sendMsgTelegramToTheManagers: async function(
idapp, text, onlyintofile = false, MyForm = null, nottousername = '') {
tools.writeManagersLog(text);
@@ -881,7 +893,6 @@ module.exports = {
msg = cl.convertSpecialTags(rec.user, msg);
}
if (!!mydata.flotta) {
// SOSTITUISCI LE PAROLE CHIAVI
if (!!mydata.flotta.date_start)
@@ -1013,7 +1024,8 @@ module.exports = {
}
if (!!idteleg) {
strout += '\n (' + index + ') ' + user.username + ' (' + user.name + ' ' + user.surname + ':';
strout += '\n (' + index + ') ' + user.username + ' (' +
user.name + ' ' + user.surname + ':';
if (mydata.inviareale) {
await this.sendMsgTelegramByIdTelegram(idapp, idteleg, mymsg,
undefined, undefined, true);
@@ -1208,20 +1220,22 @@ module.exports = {
},
setVerifiedReg: async function (idapp, lang, usernameorig, usernameDest) {
setVerifiedReg: async function(idapp, lang, usernameorig, usernameDest) {
try {
await User.setVerifiedByAportador(idapp, usernameDest, true);
await User.setFriendsCmd(idapp, usernameorig, usernameDest,
shared_consts.FRIENDSCMD.SETFRIEND);
const msgDest = printf(getstr(lang, 'MSG_APORTADOR_CONFIRMED'), `${usernameDest}`);
const msgDest = printf(getstr(lang, 'MSG_APORTADOR_CONFIRMED'),
`${usernameDest}`);
await local_sendMsgTelegram(idapp, usernameorig, msgDest);
}catch (e) {
} catch (e) {
console.log('e', e);
}
},
askConfirmationUserRegistration: async function(idapp, myfunc, myuser, userDest = '', langdest = '') {
askConfirmationUserRegistration: async function(
idapp, myfunc, myuser, userDest = '', langdest = '') {
const cl = getclTelegByidapp(idapp);
@@ -1235,11 +1249,14 @@ module.exports = {
if (notask_verif) {
// Non chiedi la verifica Registrazione
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest, myuser.username);
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest,
myuser.username);
} else {
const name = myuser.username + (myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '')
const linkuserprof = tools.getHostByIdApp(idapp) + '/my/' + myuser.username;
const name = myuser.username +
(myuser.name ? `(${myuser.name} + ' ' + ${myuser.surname})` : '');
const linkuserprof = tools.getHostByIdApp(idapp) + '/my/' +
myuser.username;
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
`<br>Username: <b>${name}</b> (${linkuserprof})<br>Email: ` +
myuser.email);
@@ -1264,7 +1281,8 @@ module.exports = {
// Invia Msg
if (domanda) {
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda, undefined, undefined, true, keyb);
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda,
undefined, undefined, true, keyb);
}
} catch (e) {
@@ -1472,7 +1490,8 @@ class Telegram {
msg = msg.replace('{username}', user.username);
msg = msg.replace('{name}', user.name ? user.name : user.username);
msg = msg.replace('{surname}', user.surname ? user.surname : '');
msg = msg.replace('{aportador}', user.aportador_solidario ? user.aportador_solidario : '');
msg = msg.replace('{aportador_solidario}',
user.aportador_solidario ? user.aportador_solidario : '');
if (!!user.profile.link_payment)
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
if (!!user.profile.revolut)
@@ -1490,14 +1509,13 @@ class Telegram {
// const cl = getclTelegByidapp(user.idapp);
msg = msg.replace('{link_chathelp}', tools.HELP_CHAT);
}catch (e) {
} catch (e) {
console.log(e);
}
return msg;
}
async IsTesto(msg) {
let risp = '';
@@ -1567,15 +1585,21 @@ class Telegram {
if (rec.status === Status.VERIFIED) {
if (rec.user) {
if (rec.user.profile.username_telegram && msg.from.id > 0 && !msg.from.username) {
rec.user.profile.username_telegram = msg.from.username
await User.setUsernameTelegram(this.idapp, rec.user._id, msg.from.username || '', msg.from.first_name || '', msg.from.last_name || '');
if (rec.user.profile.username_telegram && msg.from.id > 0 &&
!msg.from.username) {
rec.user.profile.username_telegram = msg.from.username;
await User.setUsernameTelegram(this.idapp, rec.user._id,
msg.from.username || '', msg.from.first_name || '',
msg.from.last_name || '');
}
if (!rec.user.profile.username_telegram && msg.from.username) {
rec.user.profile.username_telegram = msg.from.username
await User.setUsernameTelegram(this.idapp, rec.user._id, msg.from.username || '', msg.from.first_name || '', msg.from.last_name || '');
this.sendMsg(msg.from.id, printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
rec.user.profile.username_telegram = msg.from.username;
await User.setUsernameTelegram(this.idapp, rec.user._id,
msg.from.username || '', msg.from.first_name || '',
msg.from.last_name || '');
this.sendMsg(msg.from.id,
printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
} else {
if (!rec.user.profile.username_telegram) {
return this.checkIfUsernameTelegramSet(msg, rec.user);
@@ -1677,8 +1701,10 @@ class Telegram {
} else if (MsgBot.SEI_LIBERO.find((rec) => testo.indexOf(rec) > -1)) {
risp = 'Io? Sono per la Libertà! ' + emo.JOY +
'\nMa se vuoi possiamo conoscerci meglio!' + emo.DANCER + emo.FIRE;
} else if (MsgBot.SEI_LIBERO_DI_RESPIRARE.find((rec) => testo.indexOf(rec) > -1)) {
risp = 'Assolutamente Sì ! Respirare è fondamentale per l\'essere umano !' + emo.DANCER + emo.FIRE;
} else if (MsgBot.SEI_LIBERO_DI_RESPIRARE.find(
(rec) => testo.indexOf(rec) > -1)) {
risp = 'Assolutamente Sì ! Respirare è fondamentale per l\'essere umano !' +
emo.DANCER + emo.FIRE;
} else if (MsgBot.FARE_DOMANDA.find((rec) => testo.indexOf(rec) > -1)) {
risp = 'Dipende ' + emo.SMILE_STAR + '\nProvaci!';
} else if (MsgBot.DIVENTERO_RICCA.find(
@@ -1687,7 +1713,8 @@ class Telegram {
emo.GIFT_HEART;
} else if (MsgBot.MA_ALLORA.find((rec) => testo.indexOf(rec) > -1)) {
risp = 'Ma allora cosa?';
} else if (MsgBot.TROVAMI_UN_UOMO_DONNA.find((rec) => testo.indexOf(rec) > -1)) {
} else if (MsgBot.TROVAMI_UN_UOMO_DONNA.find(
(rec) => testo.indexOf(rec) > -1)) {
risp = 'Eh non è cosi facile. Ma se t\'impegni a cercare ci riuscirai. Nel frattempo trova la tua strada, fai il tuo percorso interiore, e magari arriva proprio quando meno te l\'aspetti';
} else if (MsgBot.SEI_LIBERO_STASERA.find(
(rec) => testo.indexOf(rec) > -1)) {
@@ -1868,7 +1895,7 @@ class Telegram {
await this.menumsgStaff(msg);
} else if (testo === Menu.MSGPAOLO) {
await this.menumsgPaolo(msg);
// } else if (testo === Menu.MSG_NO_7_REQ) {
// } else if (testo === Menu.MSG_NO_7_REQ) {
// await this.menumsg_No_7_Req(msg);
// } else if (testo === Menu.MSG_NO_9_REQ) {
// await this.menumsg_No_9_Req(msg);
@@ -1876,10 +1903,12 @@ class Telegram {
// await this.menumsgGenerico(msg, Destin.NESSUN_IMBARCO_7REQ);
// } else if (cmd1 === Menu.MSG_TO_NAVE) {
// await this.menumsg_to_Nave(msg, cmd2);
// } else if (testo === Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI) {
// } else if (testo === 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 (testo === Menu.SETPICPROFILE) {
await this.setPhotoProfile(rec, msg);
} else if (this.isSelMenu(msg, testo, 'INDIETRO') ||
(testo === Menu.it.INDIETRO)) {
await this.msgScegliMenu(msg);
@@ -2298,7 +2327,7 @@ class Telegram {
}
permitSendMsg(user) {
return User.isAdmin(user.perm)
return User.isAdmin(user.perm);
}
async menumsgGenerico(msg, dest, username, extraparam) {
@@ -2495,7 +2524,7 @@ class Telegram {
return true;
}
}catch (e) {
} catch (e) {
console.error('e');
}
}
@@ -2521,7 +2550,9 @@ class Telegram {
if (rec) {
if (code === telegcode) {
try {
await User.setUsernameTelegram(this.idapp, user._id, msg.from.username || '', msg.from.first_name || '', msg.from.last_name || '');
await User.setUsernameTelegram(this.idapp, user._id,
msg.from.username || '', msg.from.first_name || '',
msg.from.last_name || '');
} catch (e) {}
// let ris = await this.getUser(msg, rec, false);
@@ -2529,9 +2560,11 @@ class Telegram {
await User.SetTelegramIdSuccess(this.idapp, user._id,
msg.from.id).then((recuser) => {
if (recuser) {
let name = recuser.name;
this.setPhotoProfile(rec, msg);
let username = recuser.name;
this.sendMsg(msg.from.id,
printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), name, tools.getHostByIdApp(this.idapp)));
printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), username,
tools.getHostByIdApp(this.idapp)));
this.checkIfUsernameTelegramSet(msg, recuser);
// local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg);
@@ -3053,9 +3086,11 @@ class Telegram {
// Check if you are Admin
const user = await User.UserByIdTelegram(idapp, id);
let isAdmin = user ? user.profile.manage_telegram && user.username === 'paoloar77' : false;
let isAdmin = user ? user.profile.manage_telegram && user.username ===
'paoloar77' : false;
const isManager = user ? user.profile.manage_telegram : false;
const isVerified = user ? user.profile.teleg_id > 0 && user.verified_by_aportador : false;
const isVerified = user ? user.profile.teleg_id > 0 &&
user.verified_by_aportador : false;
this.menuDb = await MyBot.findAllIdApp(idapp);
@@ -3075,8 +3110,7 @@ class Telegram {
|| (isVerified && tools.isBitActive(rec.visibility,
shared_consts.VISIB_ONLYIF_VERIFIED))
|| (rec.visibility === 0))
)
{
) {
rec.active_mem = true;
if (rec.main) {
lang = rec.lang;
@@ -3322,7 +3356,7 @@ class Telegram {
return await this._inviaMsg(id, text, form, menu, msg_id, chat_id,
ripr_menuPrec);
}
}catch (e) {
} catch (e) {
console.error('Error sendMsg', e);
}
@@ -3340,6 +3374,43 @@ class Telegram {
return mymenuout;
}
async setPhotoProfile(rec, msg) {
try {
if (rec.user) {
const idapp = this.idapp;
const bot = this.bot;
const username = rec.user.username;
const token = this.token;
let myfileprofile = tools.getdirByIdApp(idapp, true) +
server_constants.DIR_UPLOAD + '/profile/' + username +'/';
let user_profile = bot.getUserProfilePhotos(msg.from.id);
user_profile.then(function(res) {
if (res.photos[0]) {
var file_id = res.photos[0][2].file_id;
var file = bot.getFile(file_id);
file.then(function(result) {
const file_path = result.file_path;
const photo_url = 'https://api.telegram.org/file/bot' + token +
'/' + file_path;
let filename = tools.extractFileName(photo_url)
myfileprofile += filename;
tools.downloadImage(photo_url, myfileprofile).
then((ris) => {
User.setPicProfile(idapp, username, filename);
// console.log('scaricato');
});
// bot.sendMessage(chatId, photo_url);
});
}
});
}
} catch (e) {
console.error('Error setPhotoProfile', e);
}
}
getInlineKeyboard(lang, arrrisp1, arrrisp2, arrrisp3) {
let mykeyb = {
parse_mode: 'HTML',
@@ -3577,16 +3648,20 @@ if (true) {
} else if (data.action === InlineConferma.RISPOSTA_SI +
shared_consts.CallFunz.REGISTRATION) {
const changed = await myclTelegram.setCmdToUsername(rec, data.username,
const changed = await myclTelegram.setCmdToUsername(rec,
data.username,
Cmd.VALIDATE_REGISTRATION, true);
await User.setFriendsCmd(user.idapp, data.username, userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
await User.setFriendsCmd(user.idapp, data.username,
userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
if (changed) {
const msgOrig = printf(
getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'), `${userDest.username}`, tools.getHostByIdApp(user.idapp));
getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'),
`${userDest.username}`, tools.getHostByIdApp(user.idapp));
const msgDest = printf(
getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'), `${user.username}`);
getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'),
`${user.username}`);
await local_sendMsgTelegram(user.idapp, data.username,
msgOrig);
@@ -3594,8 +3669,10 @@ if (true) {
msgDest);
}
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.REGISTRATION) {
const changed = await myclTelegram.setCmdToUsername(rec, data.username,
} else if (data.action === InlineConferma.RISPOSTA_NO +
shared_consts.CallFunz.REGISTRATION) {
const changed = await myclTelegram.setCmdToUsername(rec,
data.username,
Cmd.VALIDATE_REGISTRATION, false);
if (changed) {