Notifica Telegram e Push quando mandi la stretta di mano
This commit is contained in:
@@ -709,7 +709,7 @@ const MyTelegramBot = {
|
||||
MyForm = null) {
|
||||
|
||||
if (!idtelegram)
|
||||
return;
|
||||
return {text: ''};
|
||||
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl && idtelegram) {
|
||||
@@ -718,6 +718,8 @@ const MyTelegramBot = {
|
||||
chat_id, ripr_menuPrec);
|
||||
}
|
||||
|
||||
return {text: ''};
|
||||
|
||||
},
|
||||
|
||||
deleteRecInMemByUsername: function (idapp, username_bo) {
|
||||
@@ -977,14 +979,14 @@ const MyTelegramBot = {
|
||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_HANDSHAKE) {
|
||||
sendnotif = true;
|
||||
typedir = shared_consts.TypeNotifs.TYPEDIR_HANDSHAKE;
|
||||
typeid = shared_consts.TypeNotifs.ID_HANDSHAKE_NEW_REC;
|
||||
typeid = shared_consts.TypeNotifs.ID_HANDSHAKE_ACCEPTED;
|
||||
paramsObj = { usernameDest: userDest };
|
||||
|
||||
domanda = printf(tools.gettranslate('RICHIESTA_HANDSHAKE', langdest), myuser.username) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
text: '✅🤝 Ricambia la fiducia',
|
||||
text: '✅🤝 Ricambia la stretta di mano',
|
||||
callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + userDest + tools.SEP + '',
|
||||
},
|
||||
]);
|
||||
@@ -1153,7 +1155,7 @@ sendMsgTelegramToTheAdminAllSites: async function (text, senzaintestazione) {
|
||||
},
|
||||
|
||||
sendMsgTelegramToTheAdmin: async function (idapp, text, senzaintestazione) {
|
||||
const usersmanagers = await User.getusersManagers(idapp);
|
||||
const usersmanagers = await User.getusersAdmin(idapp);
|
||||
|
||||
let intestaz = emo.ROBOT_FACE + '[BOT-ADMIN]' + emo.ADMIN + ': ';
|
||||
if (senzaintestazione)
|
||||
@@ -1300,39 +1302,6 @@ sendMsgFromSiteToBotTelegram: async function (idapp, user, params) {
|
||||
|
||||
};
|
||||
|
||||
async function sendMsgTelegramToTheAdmin(idapp, text, msg) {
|
||||
const usersmanagers = await User.getusersManagers(idapp);
|
||||
|
||||
const clorig = getclTelegByidapp(idapp);
|
||||
const rec = clorig.getRecInMem(msg);
|
||||
let username = '';
|
||||
if (!!rec) {
|
||||
username = rec.username_bo;
|
||||
} else {
|
||||
username = msg.chat.username;
|
||||
}
|
||||
|
||||
text = emo.ROBOT_FACE + '[BOT-ADMIN]' + emo.ADMIN + ': Da ' +
|
||||
msg.chat.first_name + ' ' + msg.chat.last_name + ' [' + username +
|
||||
']: \n' + text;
|
||||
tools.writeEventsLog(text);
|
||||
|
||||
if (usersmanagers) {
|
||||
for (const rec of usersmanagers) {
|
||||
if (User.isAdmin(rec.perm)) {
|
||||
const idtelegram = rec.profile.teleg_id;
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl && idtelegram) {
|
||||
await cl.sendMsg(idtelegram, text);
|
||||
}
|
||||
await tools.snooze(300);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
async function setVerifiedReg(idapp, lang, usernameorig, usernameDest) {
|
||||
try {
|
||||
await User.setVerifiedByAportador(idapp, usernameorig, true);
|
||||
@@ -1384,6 +1353,32 @@ async function local_sendMsgTelegramToTheManagers(
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
async function local_sendMsgTelegramToTheAdmin(
|
||||
idapp, text, msg, username_bo) {
|
||||
const usersAdmin = await User.getusersAdmin(idapp);
|
||||
|
||||
let username = msg.chat.username;
|
||||
if (username_bo)
|
||||
username = username_bo;
|
||||
|
||||
text = emo.ROBOT_FACE + ': Da ' + msg.chat.first_name + ' ' +
|
||||
msg.chat.last_name + ' (' + username + '): \n' + text;
|
||||
tools.writeEventsLog(text);
|
||||
|
||||
if (usersAdmin) {
|
||||
for (const rec of usersAdmin) {
|
||||
const idtelegram = rec.profile.teleg_id;
|
||||
const cl = getclTelegByidapp(idapp);
|
||||
if (cl && idtelegram) {
|
||||
await cl.sendMsg(idtelegram, text, undefined, undefined, undefined,
|
||||
undefined, true);
|
||||
}
|
||||
await tools.snooze(100);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
async function local_sendMsgTelegram(idapp, username, text) {
|
||||
@@ -3090,9 +3085,12 @@ class Telegram {
|
||||
}
|
||||
|
||||
const rec = this.getRecInMem(msg);
|
||||
let testo = msg.text.toLowerCase().trim();
|
||||
|
||||
status = this.getstatus(rec);
|
||||
if (status === Status.WAITFOR_USERNAME_TELEGRAM && !this.selectMenuHelp(msg) && !this.selectMenuLang(msg)) {
|
||||
if (testo === Menu.EXIT_TELEGRAM) {
|
||||
await this.menuExitToTelegram(msg);
|
||||
}else if (status === Status.WAITFOR_USERNAME_TELEGRAM && !this.selectMenuHelp(msg) && !this.selectMenuLang(msg)) {
|
||||
// await this.setUsernameBo(msg);
|
||||
await this.settotheDatabase(msg);
|
||||
} else if (status === Status.WAITFOR_USERNAME_INVITANTE && !this.selectMenuHelp(msg) && !this.selectMenuLang(msg)) {
|
||||
@@ -4037,6 +4035,8 @@ if (true) {
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
// Invia questo msg anche all'Admin
|
||||
await local_sendMsgTelegramToTheAdmin(user.idapp, msgDest, msg, data.userDest);
|
||||
}
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.REGISTRATION) {
|
||||
@@ -4136,12 +4136,12 @@ if (true) {
|
||||
|
||||
if (userDest) {
|
||||
cmd = shared_consts.FRIENDSCMD.SETHANDSHAKE;
|
||||
const foundIfAlreadyFriend = await User.isMyHandShake(user.idapp, data.username, data.userDest);
|
||||
const foundIfAlreadyFriend = await User.isMyHandShake(user.idapp, data.userDest, data.username);
|
||||
|
||||
if (!foundIfAlreadyFriend) {
|
||||
// Aggiungilo nelle HandShake
|
||||
const req = tools.getReqByPar(user.idapp, username_action);
|
||||
const ris = await User.setFriendsCmd(req, user.idapp, data.username, data.userDest, cmd);
|
||||
const ris = await User.setFriendsCmd(req, user.idapp, data.userDest, data.username, cmd);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user