- Registrazione: conferma Abilitazione da Telegram
- Richiesta Amicizia
This commit is contained in:
@@ -334,6 +334,11 @@ const InlineZoomConferma = {
|
||||
NON_CONFERMA_ZOOM_PRESENZA: 'nonconf_pres',
|
||||
};
|
||||
|
||||
const InlineConferma = {
|
||||
RISPOSTA_SI: 'r_s',
|
||||
RISPOSTA_NO: 'r_n',
|
||||
};
|
||||
|
||||
const SendMsgCmd = [
|
||||
CONTA_SOLO,
|
||||
RICEVI_EMAIL,
|
||||
@@ -452,15 +457,13 @@ const txt = {
|
||||
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',
|
||||
MSG_APORTADOR_ASK_CONFIRM: emo.QUESTION_MARK +
|
||||
' Si vuole confermare di Conoscere "%s ?',
|
||||
MSG_APORTADOR_CONFIRMED: emo.SUN + ' %s è stato confermato correttamente!',
|
||||
MSG_APORTADOR_DEST_CONFIRMED: emo.SUN +
|
||||
' Sei stato Verificato correttamente 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!',
|
||||
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||
' Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s. Contattalo se lo conosci, oppure trova un altro invitante !',
|
||||
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
|
||||
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||
' %s Non è stato Verificato !',
|
||||
'🚫 %s Non è stato Abilitato !',
|
||||
MSG_ISCRITTO_CONACREIS: emo.FIRE + ' Si è appena Iscritto al Conacreis "%s"',
|
||||
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
||||
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
|
||||
@@ -620,7 +623,7 @@ module.exports = {
|
||||
|
||||
getFormDaMostrare: function(idapp, myfunc, myuser) {
|
||||
|
||||
FormDaMostrare = null;
|
||||
let FormDaMostrare = null;
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
|
||||
@@ -629,13 +632,14 @@ module.exports = {
|
||||
{
|
||||
text: 'Conferma Presenza Zoom',
|
||||
// callback_data: { action: InlineZoomConferma.CONFERMA_ZOOM_PRESENZA, username: myuser.username }
|
||||
callback_data: InlineZoomConferma.CONFERMA_ZOOM_PRESENZA + '|' +
|
||||
callback_data: InlineZoomConferma.CONFERMA_ZOOM_PRESENZA + tools.SEP +
|
||||
myuser.username,
|
||||
},
|
||||
{
|
||||
text: 'Annulla Presenza Zoom',
|
||||
// callback_data: { action: InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA, username: myuser.username }
|
||||
callback_data: InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA + '|' +
|
||||
callback_data: InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA +
|
||||
tools.SEP +
|
||||
myuser.username,
|
||||
},
|
||||
]);
|
||||
@@ -684,9 +688,14 @@ module.exports = {
|
||||
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
|
||||
|
||||
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'),
|
||||
`${mylocalsconf.user.name + ' ' + mylocalsconf.user.surname}`);
|
||||
`${mylocalsconf.user.name + ' ' + mylocalsconf.user.surname + '(' + mylocalsconf.user.username + ')' + 'email: ' + mylocalsconf.user.email }`);
|
||||
const msgyes = printf(getstr(langdest, 'MSG_APORTADOR_CONFIRMED'),
|
||||
`${mylocalsconf.user.name + ' ' + mylocalsconf.user.surname}`);
|
||||
const msgNo = printf(getstr(langdest, 'MSG_APORTADOR_NOT_CONFIRMED'),
|
||||
@@ -707,8 +716,7 @@ module.exports = {
|
||||
msgDestNo, mylocalsconf.user.username);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
},
|
||||
|
||||
notifyIscrizioneToTelegram: async function(phase, mylocalsconf) {
|
||||
@@ -1083,7 +1091,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
sendMsgTelegram: async function(
|
||||
idapp, username, text, alsotomanagers, username_mitt) {
|
||||
idapp, username, text, alsotomanagers = false, username_mitt = '') {
|
||||
const {User} = require('../models/user');
|
||||
|
||||
const teleg_id = await User.TelegIdByUsername(idapp, username);
|
||||
@@ -1111,6 +1119,9 @@ module.exports = {
|
||||
sendMsgTelegramByIdTelegram: async function(
|
||||
idapp, idtelegram, text, message_id, chat_id, ripr_menuPrec,
|
||||
MyForm = null) {
|
||||
|
||||
console.log('sendMsgTelegramByIdTelegram', text);
|
||||
|
||||
if (!idtelegram)
|
||||
return;
|
||||
|
||||
@@ -1128,7 +1139,48 @@ module.exports = {
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl) {
|
||||
return await cl.updateMenuBot();
|
||||
return cl.updateMenuBot();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
askConfirmationUserRegistration: async function(idapp, myfunc, myuser, userDest = '', langdest = '') {
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
|
||||
try {
|
||||
|
||||
let keyb = null;
|
||||
let domanda = '';
|
||||
|
||||
if (myfunc === shared_consts.CallFunz.REGISTRATION) {
|
||||
domanda = printf(getstr(langdest, 'MSG_APORTADOR_ASK_CONFIRM'),
|
||||
`<br>${myuser.name + ' ' + myuser.surname + ' (' + myuser.username +
|
||||
') <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
|
||||
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);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -1208,6 +1260,19 @@ async function local_sendMsgTelegramToTheManagers(
|
||||
|
||||
}
|
||||
|
||||
async function local_sendMsgTelegram(idapp, username, text) {
|
||||
|
||||
const teleg_id = await User.TelegIdByUsername(idapp, username);
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
let ris = null;
|
||||
if (cl && teleg_id) {
|
||||
ris = await cl.sendMsg(teleg_id, text);
|
||||
}
|
||||
|
||||
return ris;
|
||||
|
||||
}
|
||||
|
||||
function getstr(lang, key, param1) {
|
||||
|
||||
let mystr = '';
|
||||
@@ -1298,7 +1363,6 @@ class Telegram {
|
||||
if (rec.user)
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -2349,8 +2413,7 @@ class Telegram {
|
||||
|
||||
async setCmdToUsername(rec, username, cmd_to_set, valuebool) {
|
||||
if (cmd_to_set === Cmd.VALIDATE_REGISTRATION) {
|
||||
return await User.setVerifiedByAportador(rec.user.idapp, username,
|
||||
valuebool);
|
||||
return User.setVerifiedByAportador(rec.user.idapp, username, valuebool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2466,12 +2529,13 @@ class Telegram {
|
||||
FormDaMostrare = this.getInlineKeyboard(lang, [
|
||||
{
|
||||
text: Menu[lang].SI,
|
||||
callback_data: InlineCmd.VOGLIO_IMBARCARMI + '|' +
|
||||
callback_data: InlineCmd.VOGLIO_IMBARCARMI + tools.SEP +
|
||||
utente.username,
|
||||
},
|
||||
{
|
||||
text: Menu[lang].NO,
|
||||
callback_data: InlineCmd.NON_VOGLIO_IMBARCARMI + '|' +
|
||||
callback_data: InlineCmd.NON_VOGLIO_IMBARCARMI +
|
||||
tools.SEP +
|
||||
utente.username,
|
||||
},
|
||||
]);
|
||||
@@ -3266,17 +3330,19 @@ if (true) {
|
||||
|
||||
let dataarr = [];
|
||||
let data = {
|
||||
action: 0,
|
||||
action: '',
|
||||
username: '',
|
||||
userDest: '',
|
||||
};
|
||||
|
||||
const datastr = callbackQuery.data;
|
||||
if (!!datastr) {
|
||||
dataarr = datastr.split('|');
|
||||
dataarr = datastr.split(tools.SEP);
|
||||
if (!!dataarr) {
|
||||
data = {
|
||||
action: dataarr[0],
|
||||
username: dataarr[1],
|
||||
username: dataarr[1] ? dataarr[1] : '',
|
||||
userDest: dataarr[2] ? dataarr[2] : '',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3291,6 +3357,10 @@ if (true) {
|
||||
const rec = myclTelegram.getRecInMem(msg);
|
||||
const user = await User.getUserShortDataByUsername(idapp,
|
||||
data.username);
|
||||
const userDest = data.userDest
|
||||
? await User.getUserShortDataByUsername(idapp, data.userDest)
|
||||
: null;
|
||||
|
||||
if (!!rec) {
|
||||
if (!!user) {
|
||||
if (data.action === InlineCmd.VOGLIO_IMBARCARMI) {
|
||||
@@ -3323,6 +3393,35 @@ if (true) {
|
||||
|
||||
await User.setZoomPresenza(user.idapp, user._id, false);
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI +
|
||||
shared_consts.CallFunz.REGISTRATION) {
|
||||
await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, true);
|
||||
|
||||
const msgOrig = printf(
|
||||
getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'),
|
||||
`${userDest.name + ' ' + userDest.surname}`);
|
||||
const msgDest = printf(
|
||||
getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'),
|
||||
`${user.name + ' ' + user.surname}`);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO +
|
||||
shared_consts.CallFunz.REGISTRATION) {
|
||||
await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, false);
|
||||
|
||||
const msgOrig = printf(
|
||||
getstr(userDest.lang, 'MSG_APORTADOR_DEST_NOT_CONFIRMED'),
|
||||
`${userDest.name + ' ' + userDest.surname}`);
|
||||
const msgDest = printf(
|
||||
getstr(user.lang, 'MSG_APORTADOR_NOT_CONFIRMED'),
|
||||
`${user.name + ' ' + user.surname}`);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user