Corretto le richieste di amicizie, aggiunto Accettazione sul BOT

This commit is contained in:
paoloar77
2022-03-11 12:38:01 +01:00
parent d60be7c89e
commit 2916392d5c
4 changed files with 120 additions and 34 deletions

View File

@@ -131,7 +131,7 @@ MsgBot = {
HAHA: ['hahaha', 'ahah', '😂'],
MI_AMI: ['mi ami'],
TI_AMO: ['ti amo', 'ti adoro', 'ti lovvo'],
PREGO: [ 'prego', 'Prego ! 💋💋💋'],
PREGO: ['prego', 'Prego ! 💋💋💋'],
GRAZIE: [
'grazie ainy',
'grazie',
@@ -486,14 +486,14 @@ const txt = {
' Si è appena Registrato "%s" (n. %s)\nInvitato da %s',
MSG_APORTADOR_ASK_CONFIRM: '🆕💥 🧍‍♂️ Abilita Nuova Registrazione:',
MSG_ACCEPT_NEWENTRY_INGROUP: '❇️👥 🧍‍♂️ Accetta Ingresso nel GRUPPO %s:',
MSG_FRIENDS_ACCEPTED: '✅ %s ha accettato la tua richiesta di Amicizia !',
MSG_FRIENDS_ACCEPTED_CONFIRMED: '✅ Hai accettato la richiesta di Amicizia di %s !',
MSG_APORTADOR_CONFIRMED: '✅ %s è stato Abilitato correttamente (da %s)!',
MSG_APORTADOR_DEST_CONFIRMED: '✅ Sei stato Abilitato correttamente da %s!\n' +
'Vai sulla App oppure clicca qui per entrare\n👉🏻 %s',
MSG_GROUP_CONFIRMED: '✅ Sei stato Aggiunto sul Gruppo %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 +
'🚫 %s Non è stato Abilitato !',
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 + '🚫 %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',
@@ -862,6 +862,47 @@ const MyTelegramBot = {
},
askConfirmationUserFriend: async function(idapp, myfunc, myuser, userDest = '', username = '') {
try {
const cl = getclTelegByidapp(idapp);
const langdest = myuser.lang;
const telegid = myuser.profile.teleg_id;
let keyb = null;
let domanda = '';
const struserinfomsg = tools.getUserInfoMsg(idapp, myuser);
if (myfunc === shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
domanda = printf(tools.gettranslate('RICHIESTA_AMICIZIA', langdest), userDest) + '<br>' + struserinfomsg;
keyb = cl.getInlineKeyboard(myuser.lang, [
{
text: '✅👤 Accetta Amicizia',
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
},
{
text: '🚫👤 Rifiuta Amicizia',
callback_data: InlineConferma.RISPOSTA_NO + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
},
]);
}
// Invia Msg
if (domanda) {
const teleg_id = await User.TelegIdByUsername(idapp, userDest);
await this.local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda, undefined, undefined, true, keyb);
}
} catch (e) {
console.error('Error askConfirmationUser', e);
}
},
sendMsgTelegramToTheManagers: async function(
idapp, text, onlyintofile = false, MyForm = null, nottousername = '') {
@@ -1556,10 +1597,10 @@ class Telegram {
} else if (testo.length >= 10) {
noanswer = true;
let myfaq = this.geturlfaq();
risp = 'Io sono solo un Robot ' + emo.ROBOT_FACE + emo.JOY2 +
'Usa il menu qui sotto per interagire col BOT\n' +
'\n\nPer AIUTO, clicca qui:\n👉🏻👉🏻<a href="' + myfaq +
'">FAQ di AIUTO</a> (risposte alle domande più frequenti)\n\nSe non trovi risposta allora contatta la Chat HELP.\nGrazie';
risp = 'Ciao {username}, Io mi chiamo BOT e sono il tuo assistente Virtuale ' + emo.ROBOT_FACE + emo.JOY2 + '\n';
'Usa il menu qui sotto per interagire col BOT\n' +
'\n\nPer AIUTO, clicca qui:\n👉🏻👉🏻<a href="' + myfaq +
'">FAQ di AIUTO</a> (risposte alle domande più frequenti)\n\nSe non trovi risposta allora contatta la Chat HELP.\nGrazie';
// risp += '\nClicca qui per entrare nella Chat - HELP di Supporto\n' + 'https://t.me/joinchat/AL2qKE80rxDkgbeMGO-0bw' + '\n\nI miei colleghi umani ti aiuteranno a risolvere !';
await local_sendMsgTelegramToTheManagers(this.idapp, testo, msg,
rec.username_bo);
@@ -2353,7 +2394,7 @@ class Telegram {
const msg = await MsgTemplate.getMsgByTitleAndLang(myuser.idapp, title, myuser.lang);
const mytext = tools.convertSpecialTags(myuser, msg.body);
return this.sendMsg(myuser.profile.teleg_id, mytext);
}catch (e) {
} catch (e) {
console.error('ERR sendMsgByTemplate', e);
}
}
@@ -3140,7 +3181,7 @@ class Telegram {
}
try {
console.log('textORIG', text);
console.log('textORIG', text.substring(0, 100));
text = text.replace(/<br>/g, '\n');
text = text.replace(/<br\/>/g, '\n');
text = text.replace(/<div>/g, '');
@@ -3307,11 +3348,10 @@ class Telegram {
resize(64, 64).
withMetadata().
toFile(resized_img_small);
}catch (e) {
} catch (e) {
console.error('setPhotoProfile sharp', e);
}
// console.log('3) setPicProfile ris', ris);
return User.setPicProfile(idapp, username, filename).
then((ris) => {
@@ -3590,7 +3630,8 @@ if (true) {
await User.setaportador_solidario(user.idapp, data.username, userDest.username);
const msgOrig = printf(getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'), `${userDest.username}`, tools.getHostByIdApp(user.idapp));
const msgOrig = printf(getstr(userDest.lang, 'MSG_APORTADOR_DEST_CONFIRMED'), `${userDest.username}`,
tools.getHostByIdApp(user.idapp));
const msgDest = printf(getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'), `${user.username}`, `${userDest.username}`);
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
@@ -3636,6 +3677,26 @@ if (true) {
await User.setGroupsCmd(user.idapp, data.username, group.groupname, cmd);
}
}
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
if (userDest) {
cmd = shared_consts.FRIENDSCMD.SETFRIEND;
const foundIfAlreadyFriend = await User.isMyFriend(user.idapp, data.username, data.userDest);
if (!foundIfAlreadyFriend) {
// Aggiungilo nelle Amicizie
const ris = await User.setFriendsCmd(user.idapp, data.username, data.userDest, cmd);
if (ris) {
const msgOrig = printf(getstr(userDest.lang, 'MSG_FRIENDS_ACCEPTED', data.userDest));
const msgDest = printf(getstr(user.lang, 'MSG_FRIENDS_ACCEPTED_CONFIRMED'), data.username);
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
}
}
}
}
}