Version 0.5.25
Registration with no need to insert "invitante"
This commit is contained in:
@@ -63,5 +63,6 @@
|
||||
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario (%s) può accumulare",
|
||||
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
|
||||
"STATUS_SENT": "Inviato",
|
||||
"STATUS_REFUSED": "Rifiutato"
|
||||
"STATUS_REFUSED": "Rifiutato",
|
||||
"CLICCA_QUI": "CLICCA QUI"
|
||||
}
|
||||
|
||||
@@ -380,6 +380,10 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
getName: function(mylocalsconf) {
|
||||
return mylocalsconf.name ? (mylocalsconf.surname ? (mylocalsconf.name + ' ' + mylocalsconf.surname) : mylocalsconf.name) : mylocalsconf.username
|
||||
},
|
||||
|
||||
sendEmail_CancelBooking: async function(res, lang, emailto, user, idapp, recbooking) {
|
||||
|
||||
tools.mylog('sendEmail_CancelBooking');
|
||||
@@ -403,8 +407,7 @@ module.exports = {
|
||||
|
||||
mylocalsconf = await this.preparaConfPerBooking(res, idapp, mylocalsconf, recbooking, 'Cancellazione');
|
||||
|
||||
let msgtelegram = 'Cancellazione Evento [' + mylocalsconf.name + ' (' + mylocalsconf.name + ' ' + mylocalsconf.surname + ')] ' +
|
||||
mylocalsconf.eventtextplain;
|
||||
let msgtelegram = 'Cancellazione Evento [' + this.getName(mylocalsconf) + '] ' + mylocalsconf.eventtextplain;
|
||||
|
||||
telegrambot.sendMsgTelegramToTheManagers(idapp, msgtelegram);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ const tools = require('../tools/general');
|
||||
const appTelegram = [tools.FREEPLANET, tools.RISO];
|
||||
|
||||
const appTelegram_TEST = [tools.FREEPLANET, tools.ARCADEI, tools.RISO];
|
||||
const appTelegram_DEVELOP = [tools.RISO, tools.FREEPLANET];
|
||||
const appTelegram_DEVELOP = [tools.RISO];
|
||||
|
||||
const appTelegramFinti = ['2', tools.CNM, tools.ARCADEI];
|
||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET, tools.FREEPLANET];
|
||||
@@ -887,11 +887,13 @@ const MyTelegramBot = {
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅ Accetta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP + groupid,
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
||||
groupid,
|
||||
},
|
||||
{
|
||||
text: '🚫 Rifiuta ' + myuser.username,
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP + groupid,
|
||||
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP +
|
||||
groupid,
|
||||
},
|
||||
]);
|
||||
}
|
||||
@@ -2502,16 +2504,18 @@ class Telegram {
|
||||
|
||||
}
|
||||
|
||||
async askUsernameInvitante(msg) {
|
||||
async askUsernameInvitante(msg, linkreg) {
|
||||
try {
|
||||
let rec = this.getRecInMem(msg);
|
||||
if (msg.text === undefined || msg.text === 'undefined')
|
||||
return false;
|
||||
|
||||
if (rec) {
|
||||
if (rec && !rec.aportador_solidario) {
|
||||
rec.status = Status.SET_USERNAME_INVITANTE;
|
||||
await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), 'MSG_ASK_USERNAME_INVITANTE', tools.getNomeAppByIdApp(this.idapp), null));
|
||||
|
||||
} else {
|
||||
// if (linkreg)
|
||||
// this.asktoRegistrationByLink(msg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error setUsernameBo:', e);
|
||||
@@ -2584,11 +2588,13 @@ class Telegram {
|
||||
|
||||
async setUsernameInvitante(msg) {
|
||||
try {
|
||||
if (!!msg.text) {
|
||||
let mymsg = msg.text.toString().trim().toLowerCase();
|
||||
|
||||
if (!!mymsg) {
|
||||
const rec = this.getRecInMem(msg);
|
||||
let aportador_solidario = rec.aportador_solidario;
|
||||
if (!aportador_solidario) {
|
||||
aportador_solidario = msg.text.toString().trim().toLowerCase();
|
||||
aportador_solidario = mymsg;
|
||||
aportador_solidario = tools.removeAtChar(aportador_solidario);
|
||||
let user = await User.getUserShortDataByUsername(this.idapp, aportador_solidario);
|
||||
if (!user) {
|
||||
@@ -2954,6 +2960,41 @@ class Telegram {
|
||||
return status;
|
||||
}
|
||||
|
||||
getInvitanteByMsg(msg) {
|
||||
try {
|
||||
|
||||
let mymsg = msg.text.toString().trim().toLowerCase();
|
||||
let invitante = '';
|
||||
if (mymsg.startsWith('/start')) {
|
||||
let myarrmsg = mymsg.split(' ');
|
||||
if (myarrmsg.length > 0) {
|
||||
mymsg = myarrmsg[1];
|
||||
if (mymsg.startsWith('inv_')) {
|
||||
invitante = mymsg.substring(4);
|
||||
return invitante;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
async setInvitante(msg, invitante, crea) {
|
||||
let rec = this.getRecInMem(msg);
|
||||
if (!rec && crea) {
|
||||
let status = await this.setInit(msg);
|
||||
rec = this.getRecInMem(msg);
|
||||
}
|
||||
if (rec) {
|
||||
if (!rec.aportador_solidario && invitante) {
|
||||
rec.aportador_solidario = invitante;
|
||||
rec.status = Status.SET_USERNAME_INVITANTE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async receiveMsg(msg) {
|
||||
|
||||
// Check if Username Telegram Present
|
||||
@@ -2974,9 +3015,22 @@ class Telegram {
|
||||
// await this.setUsernameBo(msg);
|
||||
await this.settotheDatabase(msg);
|
||||
} else if (status === Status.WAITFOR_USERNAME_INVITANTE && !this.selectMenuHelp(msg) && !this.selectMenuLang(msg)) {
|
||||
await this.askUsernameInvitante(msg);
|
||||
await this.askUsernameInvitante(msg, true);
|
||||
// await this.settotheDatabase(msg);
|
||||
} else if (status === Status.SET_USERNAME_INVITANTE) {
|
||||
let mymsg = msg.text.toString().trim().toLowerCase();
|
||||
let invitante = '';
|
||||
if (mymsg && mymsg.startsWith('/start')) {
|
||||
let myarrmsg = mymsg.split(' ');
|
||||
if (myarrmsg.length > 0) {
|
||||
mymsg = myarrmsg[1];
|
||||
if (mymsg && mymsg.startsWith('inv_')) {
|
||||
invitante = mymsg.substring(4);
|
||||
await this.setInvitante(msg, invitante);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await this.setUsernameInvitante(msg);
|
||||
} else if (status === Status.NONE) {
|
||||
await this.start(msg);
|
||||
@@ -3081,12 +3135,12 @@ class Telegram {
|
||||
let linkreg = tools.getLinkRegByIdAppAndMsgStrutt(this.idapp, msg, rec);
|
||||
|
||||
if (process.env.LOCALE === '1') {
|
||||
linkreg = 'http://192.168.1.115:8084/signup/' + rec.aportador_solidario + '/' + msg.from.username + '/' + msg.from.id;
|
||||
// linkreg = 'http://localhost:8084/signup/' + rec.aportador_solidario + '/' + msg.from.username + '/' + msg.from.id;
|
||||
}
|
||||
|
||||
const keyb = this.getInlineKeyboard(this.getlang(msg), [
|
||||
{
|
||||
text: '✅ CLICCA QUI ',
|
||||
text: '✅ ' + i18n.__('CLICCA_QUI'),
|
||||
url: linkreg,
|
||||
},
|
||||
]);
|
||||
@@ -3095,7 +3149,7 @@ class Telegram {
|
||||
await this.sendMsg(msg.chat.id, getstr(this.getlang(msg), 'MSG_SIGNUP', tools.getNomeAppByIdApp(this.idapp)), null, keyb);
|
||||
|
||||
} else if (status === Status.WAITFOR_USERNAME_INVITANTE) {
|
||||
await this.askUsernameInvitante(msg);
|
||||
await this.askUsernameInvitante(msg, false);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -3204,6 +3258,9 @@ class Telegram {
|
||||
|
||||
this.arrUsers.push(rec);
|
||||
|
||||
// Aportador
|
||||
this.setInvitante(msg, this.getInvitanteByMsg(msg), false);
|
||||
|
||||
return rec;
|
||||
|
||||
}
|
||||
@@ -3796,12 +3853,24 @@ if (true) {
|
||||
|
||||
// Listen for any kind of message. There are different kinds of
|
||||
// messages.
|
||||
bot.on('message', (msg) => {
|
||||
bot.on('message', async (msg) => {
|
||||
|
||||
const myclTelegram = getclTelegBytoken(bot.token);
|
||||
|
||||
// const chatId = msg.chat.id;
|
||||
let mymsg = msg.text.toString().trim().toLowerCase();
|
||||
let invitante = '';
|
||||
if (mymsg && mymsg.startsWith('/start')) {
|
||||
let myarrmsg = mymsg.split(' ');
|
||||
if (myarrmsg.length > 0) {
|
||||
mymsg = myarrmsg[1];
|
||||
if (mymsg && mymsg.startsWith('inv_')) {
|
||||
invitante = mymsg.substring(4);
|
||||
// await myclTelegram.setInvitante(msg, invitante);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const chatId = msg.chat.id;
|
||||
myclTelegram.receiveMsg(msg);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user