Non permettere il cambio del codice del gruppo
disattivare l'abilitazione se la registrazione arriva da me paoloar77 Sistemato il Menu del BOT per inviare msg a tutti e per ricevere il proprio Link personale. Non permettere il cambio del codice del gruppo Aggiunta la Provincia tra parentesi nei Comuni: es Rimini (RN)
This commit is contained in:
@@ -240,10 +240,10 @@ const Menu = {
|
||||
MSG_TO_USER: 'sendmsgto',
|
||||
ADMIN: emoji.get('information_desk_person') + ' Admin',
|
||||
ALTRO: emoji.get('newspaper') + ' Altro',
|
||||
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',
|
||||
NESSUN_IMBARCO_7REQ: emoji.get('incoming_envelope') + 'No Imbarco (7 Req)',
|
||||
// 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',
|
||||
// NESSUN_IMBARCO_7REQ: emoji.get('incoming_envelope') + 'No Imbarco (7 Req)',
|
||||
MSG_SI_INVITATI_NO_7REQ_INVITATI: emoji.get('incoming_envelope') +
|
||||
'Inv e NO 7 Req',
|
||||
MSGSTAFF: emoji.get('incoming_envelope') + ' Invia a STAFF',
|
||||
@@ -745,7 +745,7 @@ module.exports = {
|
||||
rismsg = await this.sendMsgTelegram(mylocalsconf.idapp, userdest, text);
|
||||
}
|
||||
|
||||
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
|
||||
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text, false, null, userdest);
|
||||
|
||||
if (phase === this.phase.REGISTRATION) {
|
||||
await this.askConfirmationUserRegistration(mylocalsconf.idapp, shared_consts.CallFunz.REGISTRATION,
|
||||
@@ -790,8 +790,7 @@ module.exports = {
|
||||
await this.sendMsgTelegramToTheManagers(mylocalsconf.idapp, addtext + text);
|
||||
},
|
||||
|
||||
sendMsgTelegramToTheManagers: async function(
|
||||
idapp, text, onlyintofile = false, MyForm = null) {
|
||||
sendMsgTelegramToTheManagers: async function(idapp, text, onlyintofile = false, MyForm = null, nottousername = '') {
|
||||
|
||||
tools.writeManagersLog(text);
|
||||
|
||||
@@ -799,9 +798,12 @@ module.exports = {
|
||||
const usersmanagers = await User.getusersManagers(idapp);
|
||||
if (usersmanagers) {
|
||||
for (const rec of usersmanagers) {
|
||||
await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id,
|
||||
emo.ROBOT_FACE + ': ' + text, undefined, undefined, true, MyForm);
|
||||
await tools.snooze(100);
|
||||
if (rec.username !== nottousername) {
|
||||
await this.sendMsgTelegramByIdTelegram(idapp, rec.profile.teleg_id,
|
||||
emo.ROBOT_FACE + ': ' + text, undefined, undefined, true,
|
||||
MyForm);
|
||||
await tools.snooze(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -828,7 +830,6 @@ module.exports = {
|
||||
return true;
|
||||
|
||||
},
|
||||
|
||||
getMsgByTipoMsg: async function(mydata, lang, user, sonosognatore) {
|
||||
if (!!mydata.msgextra) {
|
||||
return {body: mydata.msgextra, title: ''};
|
||||
@@ -862,26 +863,11 @@ module.exports = {
|
||||
title = ris.title;
|
||||
}
|
||||
|
||||
if (!!user) {
|
||||
msg = msg.replace('{username}', user.username);
|
||||
msg = msg.replace('{name}', user.name ? user.name : user.username);
|
||||
msg = msg.replace('{surname}', user.surname ? user.surname : '');
|
||||
if (!!user.profile.link_payment)
|
||||
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
|
||||
if (!!user.profile.revolut)
|
||||
msg = msg.replace('{revolut}', user.profile.revolut);
|
||||
if (!!user.profile.payeer_id)
|
||||
msg = msg.replace('{payeer_id}', user.profile.payeer_id);
|
||||
if (!!user.profile.advcash_id)
|
||||
msg = msg.replace('{advcash_id}', user.profile.advcash_id);
|
||||
if (!!user.profile.email_paypal)
|
||||
msg = msg.replace('{email_paypal}', user.profile.email_paypal);
|
||||
if (!!user.profile.note_payment)
|
||||
msg = msg.replace('{note_payment}', user.profile.note_payment);
|
||||
const cl = getclTelegByidapp(user.idapp);
|
||||
if (cl) {
|
||||
msg = cl.convertSpecialTags(rec.user, msg);
|
||||
}
|
||||
|
||||
// const cl = getclTelegByidapp(user.idapp);
|
||||
msg = msg.replace('{link_chathelp}', tools.HELP_CHAT);
|
||||
|
||||
if (!!mydata.flotta) {
|
||||
// SOSTITUISCI LE PAROLE CHIAVI
|
||||
@@ -1203,6 +1189,19 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
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}`);
|
||||
await local_sendMsgTelegram(idapp, usernameorig, msgDest);
|
||||
}catch (e) {
|
||||
console.log('e', e);
|
||||
}
|
||||
},
|
||||
|
||||
askConfirmationUserRegistration: async function(idapp, myfunc, myuser, userDest = '', langdest = '') {
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
@@ -1236,8 +1235,13 @@ module.exports = {
|
||||
|
||||
// INvia Msg
|
||||
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
|
||||
const notask_verif = await User.notAsk_VerifByUsername(idapp, userDest);
|
||||
await this.sendMsgTelegramByIdTelegram(myuser.idapp, teleg_id, domanda,
|
||||
undefined, undefined, true, keyb);
|
||||
undefined, undefined, true, keyb);bot
|
||||
|
||||
if (notask_verif) {
|
||||
this.setVerifiedReg(myuser.idapp, myuser.lang, userDest, myuser.username);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error askConfirmationUserRegistration', e);
|
||||
@@ -1438,6 +1442,37 @@ class Telegram {
|
||||
'\n\nI miei colleghi umani ti aiuteranno a risolvere !';
|
||||
}
|
||||
|
||||
convertSpecialTags(user, msg) {
|
||||
try {
|
||||
if (!!user) {
|
||||
msg = msg.replace('{username}', user.username);
|
||||
msg = msg.replace('{name}', user.name ? user.name : user.username);
|
||||
msg = msg.replace('{surname}', user.surname ? user.surname : '');
|
||||
if (!!user.profile.link_payment)
|
||||
msg = msg.replace('{link_paypalme}', user.profile.link_payment);
|
||||
if (!!user.profile.revolut)
|
||||
msg = msg.replace('{revolut}', user.profile.revolut);
|
||||
if (!!user.profile.payeer_id)
|
||||
msg = msg.replace('{payeer_id}', user.profile.payeer_id);
|
||||
if (!!user.profile.advcash_id)
|
||||
msg = msg.replace('{advcash_id}', user.profile.advcash_id);
|
||||
if (!!user.profile.email_paypal)
|
||||
msg = msg.replace('{email_paypal}', user.profile.email_paypal);
|
||||
if (!!user.profile.note_payment)
|
||||
msg = msg.replace('{note_payment}', user.profile.note_payment);
|
||||
}
|
||||
|
||||
// const cl = getclTelegByidapp(user.idapp);
|
||||
msg = msg.replace('{link_chathelp}', tools.HELP_CHAT);
|
||||
|
||||
}catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
async IsTesto(msg) {
|
||||
|
||||
let risp = '';
|
||||
@@ -1526,7 +1561,7 @@ class Telegram {
|
||||
|
||||
if (risp === '') {
|
||||
if (menusite) {
|
||||
risp = this.getValueMenu(this.idapp, testo, lang);
|
||||
risp = this.getValueMenu(this.idapp, rec, msg, testo, lang);
|
||||
noanswer = true;
|
||||
} else if (MsgBot.CIAO.includes(testo.replace('!', ''))) {
|
||||
risp = 'Ciao ';
|
||||
@@ -1663,6 +1698,8 @@ class Telegram {
|
||||
}
|
||||
}
|
||||
|
||||
risp = this.convertSpecialTags(rec.user, risp);
|
||||
|
||||
let keyboard = null;
|
||||
|
||||
if (contastiera) {
|
||||
@@ -1711,7 +1748,7 @@ class Telegram {
|
||||
return risp !== '';
|
||||
}
|
||||
|
||||
async isMenuNotVerified(rec, msg) {
|
||||
async isMenuNotVerified(rec, msg, notlast) {
|
||||
if (this.isSelMenu(msg, msg.text, 'ASSISTENZA')) {
|
||||
await this.menuAssistenza(msg);
|
||||
} else if (msg.text === Menu.LANG_IT) {
|
||||
@@ -1733,7 +1770,7 @@ class Telegram {
|
||||
} else if (this.isSelMenu(msg, msg.text, 'ZOOM') ||
|
||||
MsgBot.PROSSIMO_ZOOM.find((rec) => msg.text.indexOf(rec) > -1)) {
|
||||
await this.menuZoom(msg);
|
||||
} else if (await this.IsTesto(msg)) {
|
||||
} else if (!notlast && await this.IsTesto(msg)) {
|
||||
// OK
|
||||
} else {
|
||||
await this.msgScegliMenu(msg);
|
||||
@@ -1761,14 +1798,14 @@ class Telegram {
|
||||
return trovato;
|
||||
}
|
||||
|
||||
async isMenu(rec, msg) {
|
||||
async isMenu(rec, msg, testo, notlast) {
|
||||
if (!msg)
|
||||
return;
|
||||
|
||||
if (msg.text === undefined)
|
||||
if (testo === undefined)
|
||||
return;
|
||||
|
||||
const arrtext = msg.text.split(' ');
|
||||
const arrtext = testo.split(' ');
|
||||
let cmd2 = '';
|
||||
let cmd1 = arrtext[0];
|
||||
if (arrtext.length > 1)
|
||||
@@ -1776,56 +1813,56 @@ class Telegram {
|
||||
|
||||
let oldusername = rec.msgall_username_specifico;
|
||||
|
||||
if ((this.isSelMenu(msg, msg.text, 'ESCI_DA_CHAT')) ||
|
||||
(this.isSelMenu(msg, msg.text, 'INDIETRO'))) {
|
||||
if ((this.isSelMenu(msg, testo, 'ESCI_DA_CHAT')) ||
|
||||
(this.isSelMenu(msg, testo, 'INDIETRO'))) {
|
||||
rec.msgall_username_specifico = '';
|
||||
} else {
|
||||
if (rec.msgall_username_specifico !== '') {
|
||||
await this.SendMsgToUser(msg, rec, rec.msgall_username_specifico,
|
||||
msg.text);
|
||||
testo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isSelMenu(msg, msg.text, 'LAVAGNA') ||
|
||||
MsgBot.LAVAGNA.find((rec) => msg.text.indexOf(rec) > -1)) {
|
||||
if (this.isSelMenu(msg, testo, 'LAVAGNA') ||
|
||||
MsgBot.LAVAGNA.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
await this.menuLavagna(msg);
|
||||
} else if (this.isSelMenu(msg, msg.text, 'ACCEDI')) {
|
||||
} else if (this.isSelMenu(msg, testo, 'ACCEDI')) {
|
||||
await this.menuAccedi(msg);
|
||||
} else if (this.isSelMenu(msg, msg.text, 'LINK_CONDIVIDERE')) {
|
||||
} else if (this.isSelMenu(msg, testo, 'LINK_CONDIVIDERE')) {
|
||||
await this.menuLinkCondividere(msg);
|
||||
} else if (msg.text === Menu.EXIT_TELEGRAM) {
|
||||
} else if (testo === Menu.EXIT_TELEGRAM) {
|
||||
await this.menuExitToTelegram(msg);
|
||||
} else if (msg.text === Menu.ADMIN) {
|
||||
} else if (testo === Menu.ADMIN) {
|
||||
await this.menuAdmin(msg);
|
||||
} else if (msg.text === Menu.LANG) {
|
||||
} else if (testo === Menu.LANG) {
|
||||
await this.menuLang(msg);
|
||||
} else if (msg.text === Menu.MSGATUTTI) {
|
||||
} else if (testo === Menu.MSGATUTTI) {
|
||||
await this.menumsgAll(msg);
|
||||
} else if (msg.text === Menu.MSGSTAFF) {
|
||||
} else if (testo === Menu.MSGSTAFF) {
|
||||
await this.menumsgStaff(msg);
|
||||
} else if (msg.text === Menu.MSGPAOLO) {
|
||||
} else if (testo === Menu.MSGPAOLO) {
|
||||
await this.menumsgPaolo(msg);
|
||||
} else if (msg.text === Menu.MSG_NO_7_REQ) {
|
||||
await this.menumsg_No_7_Req(msg);
|
||||
} else if (msg.text === Menu.MSG_NO_9_REQ) {
|
||||
await this.menumsg_No_9_Req(msg);
|
||||
} else if (msg.text === Menu.NESSUN_IMBARCO_7REQ) {
|
||||
await this.menumsgGenerico(msg, Destin.NESSUN_IMBARCO_7REQ);
|
||||
} else if (cmd1 === Menu.MSG_TO_NAVE) {
|
||||
await this.menumsg_to_Nave(msg, cmd2);
|
||||
} else if (msg.text === Menu.MSG_SI_INVITATI_NO_7REQ_INVITATI) {
|
||||
await this.menumsg_Si_Invitati_No_7Req(msg);
|
||||
// } 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);
|
||||
// } else if (testo === Menu.NESSUN_IMBARCO_7REQ) {
|
||||
// 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) {
|
||||
// await this.menumsg_Si_Invitati_No_7Req(msg);
|
||||
} else if (cmd1.toLowerCase() === Menu.MSG_TO_USER) {
|
||||
await this.menumsg_A_Utente(msg);
|
||||
} else if (this.isSelMenu(msg, msg.text, 'INDIETRO') ||
|
||||
(msg.text === Menu.it.INDIETRO)) {
|
||||
} else if (this.isSelMenu(msg, testo, 'INDIETRO') ||
|
||||
(testo === Menu.it.INDIETRO)) {
|
||||
await this.msgScegliMenu(msg);
|
||||
} else if (this.isSelMenu(msg, msg.text, 'ESCI_DA_CHAT')) {
|
||||
} else if (this.isSelMenu(msg, testo, 'ESCI_DA_CHAT')) {
|
||||
await this.sendMsg(msg.chat.id, 'Uscito dalla Chat con ' + oldusername);
|
||||
rec.msgall_username_specifico = '';
|
||||
} else {
|
||||
await this.isMenuNotVerified(rec, msg);
|
||||
await this.isMenuNotVerified(rec, msg, notlast);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2235,18 +2272,25 @@ class Telegram {
|
||||
}
|
||||
}
|
||||
|
||||
permitSendMsg(user) {
|
||||
return User.isAdmin(user.perm)
|
||||
}
|
||||
|
||||
async menumsgGenerico(msg, dest, username, extraparam) {
|
||||
const rec = this.getRecInMem(msg);
|
||||
if (rec.user) {
|
||||
rec.msgall_status = StatusMSGALL.ASK;
|
||||
rec.msgall_achi = dest;
|
||||
rec.extraparam = extraparam;
|
||||
if (!!username) {
|
||||
rec.msgall_username_specifico = username;
|
||||
|
||||
if (this.permitSendMsg(rec.user)) {
|
||||
rec.msgall_status = StatusMSGALL.ASK;
|
||||
rec.msgall_achi = dest;
|
||||
rec.extraparam = extraparam;
|
||||
if (!!username) {
|
||||
rec.msgall_username_specifico = username;
|
||||
}
|
||||
const mystr = 'Scrivi qui un Messaggio da inviare a' + ' [' +
|
||||
this.getDestinStr(msg, dest, rec) + ']:';
|
||||
await this.sendMsg(msg.chat.id, mystr, MenuSend);
|
||||
}
|
||||
const mystr = 'Scrivi qui un Messaggio da inviare a' + ' [' +
|
||||
this.getDestinStr(msg, dest, rec) + ']:';
|
||||
await this.sendMsg(msg.chat.id, mystr, MenuSend);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2843,10 +2887,10 @@ class Telegram {
|
||||
|
||||
if (normale) {
|
||||
// Check Menu
|
||||
await this.isMenu(rec, msg);
|
||||
await this.isMenu(rec, msg, msg.text, false);
|
||||
}
|
||||
} else {
|
||||
await this.isMenuNotVerified(rec, msg);
|
||||
await this.isMenuNotVerified(rec, msg, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2984,11 +3028,9 @@ 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_email && user.verified_by_aportador : false;
|
||||
const isVerified = user ? user.profile.teleg_id > 0 && user.verified_by_aportador : false;
|
||||
|
||||
this.menuDb = await MyBot.findAllIdApp(idapp);
|
||||
|
||||
@@ -2999,29 +3041,34 @@ class Telegram {
|
||||
let lang = '';
|
||||
|
||||
for (const rec of this.menuDb) {
|
||||
if (rec.active && rec.main && rec.page === this.pagenow
|
||||
rec.active_mem = false;
|
||||
if (rec.active && rec.page === this.pagenow
|
||||
&& ((isAdmin && tools.isBitActive(rec.visibility,
|
||||
shared_consts.VISIB_ONLY_ADMIN))
|
||||
|| (isManager && tools.isBitActive(rec.visibility,
|
||||
shared_consts.VISIB_ONLY_MANAGER))
|
||||
|| (isVerified && tools.isBitActive(rec.visibility,
|
||||
shared_consts.VISIB_ONLYIF_LOGGED))
|
||||
shared_consts.VISIB_ONLYIF_VERIFIED))
|
||||
|| (rec.visibility === 0))
|
||||
) {
|
||||
lang = rec.lang;
|
||||
if (!arrlang[rec.lang])
|
||||
arrlang[rec.lang] = {menu: []};
|
||||
)
|
||||
{
|
||||
rec.active_mem = true;
|
||||
if (rec.main) {
|
||||
lang = rec.lang;
|
||||
if (!arrlang[rec.lang])
|
||||
arrlang[rec.lang] = {menu: []};
|
||||
|
||||
if (riga !== rec.riga) {
|
||||
if (arrtemp.length > 0)
|
||||
arrlang[rec.lang].menu.push(arrtemp);
|
||||
if (riga !== rec.riga) {
|
||||
if (arrtemp.length > 0)
|
||||
arrlang[rec.lang].menu.push(arrtemp);
|
||||
|
||||
riga = rec.riga;
|
||||
arrtemp = [];
|
||||
riga = rec.riga;
|
||||
arrtemp = [];
|
||||
}
|
||||
|
||||
arrtemp.push(rec.label);
|
||||
}
|
||||
|
||||
arrtemp.push(rec.label);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3051,9 +3098,11 @@ class Telegram {
|
||||
}
|
||||
|
||||
for (const rec of this.menuDb) {
|
||||
if (rec.idapp === idapp && rec.lang === lang &&
|
||||
rec.label.toLowerCase() === testo) {
|
||||
return true;
|
||||
if (rec.active_mem) {
|
||||
if (rec.idapp === idapp && rec.lang === lang &&
|
||||
rec.label.toLowerCase() === testo) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -3062,22 +3111,31 @@ class Telegram {
|
||||
return false;
|
||||
}
|
||||
|
||||
getValueMenu(idapp, testo, lang) {
|
||||
getValueMenu(idapp, rec, msg, testo, lang) {
|
||||
try {
|
||||
for (const rec of this.menuDb) {
|
||||
if (rec.idapp === idapp && rec.lang === lang &&
|
||||
rec.label.toLowerCase() === testo) {
|
||||
if (rec.type === shared_consts.BOTTYPE_TEXT) {
|
||||
return rec.value;
|
||||
}
|
||||
if (rec.type === shared_consts.BOTTYPE_PAGE) {
|
||||
if (tools.isNumber(rec.value)) {
|
||||
this.pagenow = parseInt(rec.value);
|
||||
this.pageChange = true;
|
||||
for (const recdb of this.menuDb) {
|
||||
if (recdb.active_mem) {
|
||||
if (recdb.idapp === idapp && recdb.lang === lang &&
|
||||
recdb.label.toLowerCase() === testo) {
|
||||
if (recdb.type === shared_consts.BOTTYPE_TEXT) {
|
||||
return recdb.value;
|
||||
} else if (recdb.type === shared_consts.BOTTYPE_LINK) {
|
||||
//++TODO: Link diretto !?
|
||||
return recdb.value;
|
||||
} else if (recdb.type === shared_consts.BOTTYPE_PAGE) {
|
||||
if (tools.isNumber(recdb.value)) {
|
||||
this.pagenow = parseInt(recdb.value);
|
||||
this.pageChange = true;
|
||||
}
|
||||
return '';
|
||||
} else if (recdb.type === shared_consts.BOTTYPE_MENU) {
|
||||
if (recdb.value) {
|
||||
this.isMenu(rec, msg, recdb.value, true);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
|
||||
Reference in New Issue
Block a user