Aggiunto messaggio nella registrazione, dicendo che occorre avere Telegram installato.
PASSARE TUTTI I _DOC e mettergli .lean() prima dello then() -> velocizza le Query di Mongodb "Floriterapia costellazioni familiari coach motivazionale Tecniche Essene" Inserimento Gruppi: anche il comune obbligatorio Far comparire le ultime persone registrate Mettere il controllo dell'abilitazione del BOT Telegram solo dopo che conosco il suo username, e cosi gli metto anche il contatto telegram. risolto foto profilo di telegram che non si salvava in automatico tolto il controllo della email aggiunto msg se errore al server, installare altro browser.
This commit is contained in:
@@ -198,6 +198,7 @@ MsgBot = {
|
||||
DONNA: ['donna', 'femmina'],
|
||||
FARE_DOMANDA: ['fare una domanda', 'posso farti una domanda'],
|
||||
DIVENTERO_RICCA: ['diventerò ricc'],
|
||||
DOVE_VUOI_VIVERE: ['dove vuoi vivere'],
|
||||
MA_ALLORA: ['ma allora'],
|
||||
};
|
||||
|
||||
@@ -772,12 +773,6 @@ module.exports = {
|
||||
addtext + text, false, null, userdest);
|
||||
}
|
||||
|
||||
if (phase === this.phase.REGISTRATION) {
|
||||
await this.askConfirmationUserRegistration(mylocalsconf.idapp,
|
||||
shared_consts.CallFunz.REGISTRATION,
|
||||
mylocalsconf.user, userdest, langdest);
|
||||
}
|
||||
|
||||
/*
|
||||
// Invia richiesta allo Sponsor
|
||||
const domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
||||
@@ -1236,62 +1231,6 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
askConfirmationUserRegistration: async function(
|
||||
idapp, myfunc, myuser, userDest = '', langdest = '') {
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
|
||||
try {
|
||||
|
||||
let keyb = null;
|
||||
let domanda = '';
|
||||
|
||||
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
|
||||
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
|
||||
|
||||
if (notask_verif) {
|
||||
// Non chiedi la verifica Registrazione
|
||||
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;
|
||||
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
||||
`<br>Username: <b>${name}</b> (${linkuserprof})<br>Email: ` +
|
||||
myuser.email);
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Abilita ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_SI +
|
||||
shared_consts.CallFunz.REGISTRATION + tools.SEP +
|
||||
myuser.username + tools.SEP + userDest,
|
||||
},
|
||||
{
|
||||
text: '🚫 Rifiuta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_NO +
|
||||
shared_consts.CallFunz.REGISTRATION + tools.SEP +
|
||||
myuser.username + tools.SEP + userDest,
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Invia Msg
|
||||
if (domanda) {
|
||||
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
|
||||
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda,
|
||||
undefined, undefined, true, keyb);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error askConfirmationUserRegistration', e);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@@ -1328,6 +1267,69 @@ async function sendMsgTelegramToTheAdmin(idapp, text, msg) {
|
||||
|
||||
}
|
||||
|
||||
async function askConfirmationUserRegistration(idapp, myfunc, myuser, usernametelegram = '', name_telegram = '', surname_telegram = '') {
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
|
||||
try {
|
||||
|
||||
const userDest = myuser.aportador_solidario;
|
||||
const langdest = myuser.lang;
|
||||
|
||||
let keyb = null;
|
||||
let domanda = '';
|
||||
|
||||
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
|
||||
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
|
||||
|
||||
if (notask_verif) {
|
||||
// Non chiedi la verifica Registrazione
|
||||
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;
|
||||
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
||||
`<br>Username: <b>${name}</b><br>Profilo su APP: ${linkuserprof}<br>Email: ` +
|
||||
myuser.email);
|
||||
|
||||
if (usernametelegram) {
|
||||
domanda += '<br>Profilo su Telegram [' + name_telegram + ' ' + surname_telegram + ']:<br>' + 'https://t.me/' + usernametelegram;
|
||||
}
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Abilita ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_SI +
|
||||
shared_consts.CallFunz.REGISTRATION + tools.SEP +
|
||||
myuser.username + tools.SEP + userDest,
|
||||
},
|
||||
{
|
||||
text: '🚫 Rifiuta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_NO +
|
||||
shared_consts.CallFunz.REGISTRATION + tools.SEP +
|
||||
myuser.username + tools.SEP + userDest,
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// Invia Msg
|
||||
if (domanda) {
|
||||
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
|
||||
await local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda,
|
||||
undefined, undefined, true, keyb);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error askConfirmationUserRegistration', e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getusernameByUser(idapp, msg) {
|
||||
let username = '';
|
||||
let rec = this.getRecInMem(msg);
|
||||
@@ -1381,6 +1383,24 @@ async function local_sendMsgTelegram(idapp, username, text) {
|
||||
|
||||
}
|
||||
|
||||
async function local_sendMsgTelegramByIdTelegram(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) {
|
||||
|
||||
return await cl.sendMsg(idtelegram, text, null, MyForm, message_id,
|
||||
chat_id, ripr_menuPrec);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getstr(lang, key, param1) {
|
||||
|
||||
let mystr = '';
|
||||
@@ -1598,6 +1618,14 @@ class Telegram {
|
||||
msg.from.last_name || '');
|
||||
await this.sendMsg(msg.from.id,
|
||||
printf(getstr(rec.user.lang, 'MSG_SET_USERNAME_OK')));
|
||||
|
||||
if (!rec.user.verified_by_aportador) {
|
||||
askConfirmationUserRegistration(this.idapp,
|
||||
shared_consts.CallFunz.REGISTRATION, rec.user,
|
||||
msg.from.username || '', msg.from.first_name || '',
|
||||
msg.from.last_name || '');
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!rec.user.profile.username_telegram) {
|
||||
return this.checkIfUsernameTelegramSet(msg, rec.user);
|
||||
@@ -1711,8 +1739,9 @@ 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.DOVE_VUOI_VIVERE.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'Mah a me piacerebbe vivere al mare, ma anche vicino al verde, in montagna. Sarebbe l\'ideale 😄';
|
||||
} 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)) {
|
||||
@@ -2568,9 +2597,15 @@ class Telegram {
|
||||
if (recuser) {
|
||||
this.setPhotoProfile(rec, msg);
|
||||
let username = recuser.name;
|
||||
|
||||
this.sendMsg(msg.from.id,
|
||||
printf(getstr(recuser.lang, 'MSG_VERIFY_OK'), username, tools.getHostByIdApp(this.idapp)));
|
||||
|
||||
if (msg.from.username) {
|
||||
askConfirmationUserRegistration(this.idapp,
|
||||
shared_consts.CallFunz.REGISTRATION, recuser,msg.from.username || '', msg.from.first_name || '', msg.from.last_name || '');
|
||||
}
|
||||
|
||||
this.checkIfUsernameTelegramSet(msg, recuser);
|
||||
// local_sendMsgTelegramToTheManagers(this.idapp, recuser.name + ' ' + recuser.surname + ' si è Verificato a Telegram BOT! (lang=' + recuser.lang + ')' + emo.STARS, msg);
|
||||
} else {
|
||||
@@ -3098,9 +3133,12 @@ class Telegram {
|
||||
if (recuser) {
|
||||
if (!(recuser.menuSaved[idapp]))
|
||||
load = true;
|
||||
|
||||
if (recuser.menuDb || recuser.pageChange)
|
||||
load = true;
|
||||
}
|
||||
}
|
||||
if (load || !recuser.menuDb || recuser.pageChange) {
|
||||
if (load) {
|
||||
|
||||
// Check if you are Admin
|
||||
const user = await User.UserByIdTelegram(idapp, id);
|
||||
@@ -3154,7 +3192,7 @@ class Telegram {
|
||||
recuser.pageChange = false;
|
||||
recuser.menuSaved[idapp] = arrlang;
|
||||
}
|
||||
return recuser.menuSaved[idapp];
|
||||
return recuser ? recuser.menuSaved[idapp] : null;
|
||||
} catch (e) {
|
||||
console.log('Err loadMenuFromDb: ' + e);
|
||||
}
|
||||
@@ -3205,7 +3243,7 @@ class Telegram {
|
||||
return '';
|
||||
} else if (recdb.type === shared_consts.BOTTYPE_MENU) {
|
||||
if (recdb.value) {
|
||||
this.isMenu(rec, msg, recdb.value, true);
|
||||
this.isMenu(recuser, msg, recdb.value, true);
|
||||
return shared_consts.RIS_OK;
|
||||
}
|
||||
}
|
||||
@@ -3411,18 +3449,24 @@ class Telegram {
|
||||
|
||||
const file_path = result.file_path;
|
||||
const photo_url = 'https://api.telegram.org/file/bot' + token + '/' + file_path;
|
||||
console.log('photo_url', photo_url);
|
||||
console.log('1) photo_url', photo_url);
|
||||
let filename = tools.extractFileName(photo_url);
|
||||
myfileprofile += filename;
|
||||
console.log('myfileprofile', myfileprofile);
|
||||
|
||||
const pathfile = tools.extractFilePath(myfileprofile);
|
||||
tools.mkdirpath(pathfile);
|
||||
|
||||
console.log('2) myfileprofile', pathfile);
|
||||
return tools.downloadImage(photo_url, myfileprofile).
|
||||
then((ris) => {
|
||||
console.log('setPicProfile ris', ris);
|
||||
console.log('3) setPicProfile ris', ris);
|
||||
return User.setPicProfile(idapp, username, filename).then((ris) => {
|
||||
console.log('sendMsg picprofile Copied !');
|
||||
console.log('4) sendMsg picprofile Copied !');
|
||||
local_sendMsgTelegram(idapp, username, printf(getstr(lang, 'MSG_SET_PICPROFILE'), editprofile));
|
||||
});
|
||||
// console.log('scaricato');
|
||||
}).catch((err) => {
|
||||
console.error('Error setPhotoProfile', err);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user