Add Movement !
This commit is contained in:
@@ -878,7 +878,7 @@ const MyTelegramBot = {
|
||||
]);
|
||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
domanda = i18n.__({phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest} , groupname) + '<br>' + struserinfomsg;
|
||||
domanda = i18n.__({phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest}, groupname) + '<br>' + struserinfomsg;
|
||||
|
||||
keyb = cl.getInlineKeyboard(myuser.lang, [
|
||||
{
|
||||
@@ -926,7 +926,7 @@ const MyTelegramBot = {
|
||||
sendnotif = true;
|
||||
typedir = shared_consts.TypeNotifs.TYPEDIR_FRIENDS;
|
||||
typeid = shared_consts.TypeNotifs.ID_FRIENDS_NEW_REC;
|
||||
paramsObj = {usernameDest: userDest}
|
||||
paramsObj = {usernameDest: userDest};
|
||||
|
||||
domanda = printf(tools.gettranslate('RICHIESTA_AMICIZIA', langdest), myuser.username) + '<br>' + struserinfomsg;
|
||||
|
||||
@@ -948,7 +948,6 @@ const MyTelegramBot = {
|
||||
await this.local_sendMsgTelegramByIdTelegram(idapp, teleg_id, domanda, undefined, undefined, true, keyb);
|
||||
}
|
||||
|
||||
|
||||
if (sendnotif) {
|
||||
const req = this.getReqByPar(idapp, username);
|
||||
// CREATE NOTIFICATION IN TABLE SENDNOTIF
|
||||
@@ -1675,9 +1674,10 @@ class Telegram {
|
||||
noanswer = true;
|
||||
let myfaq = this.geturlfaq();
|
||||
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' +
|
||||
'\nPer <strong>AIUTO</strong>, clicca qui:\n👉🏻👉🏻<a href="' + myfaq +
|
||||
'">FAQ di AIUTO</a> (risposte alle domande più frequenti)\n\nSe non trovi risposta allora contatta la <a href="' + tools.getTelegramSupportChat(this.idapp) + '">Chat di HELP</a>.\nGrazie';
|
||||
'Usa il menu qui sotto per interagire col BOT\n' +
|
||||
'\nPer <strong>AIUTO</strong>, clicca qui:\n👉🏻👉🏻<a href="' + myfaq +
|
||||
'">FAQ di AIUTO</a> (risposte alle domande più frequenti)\n\nSe non trovi risposta allora contatta la <a href="' +
|
||||
tools.getTelegramSupportChat(this.idapp) + '">Chat di HELP</a>.\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);
|
||||
@@ -3735,284 +3735,291 @@ if (true) {
|
||||
else if (process.env.NODE_ENV === 'test')
|
||||
arrTeleg = appTelegram_TEST;
|
||||
|
||||
console.log('TELEGRAM STARTING.... NODE_ENV:' + process.env.NODE_ENV);
|
||||
var internetAvailable = require('internet-available');
|
||||
|
||||
internetAvailable().then(() => {
|
||||
// ..
|
||||
console.log('TELEGRAM STARTING.... NODE_ENV:' + process.env.NODE_ENV);
|
||||
|
||||
for (const idapp of arrTeleg) {
|
||||
for (const idapp of arrTeleg) {
|
||||
|
||||
try {
|
||||
const token = tools.getTelegramKeyByIdApp(idapp);
|
||||
const nomebot = tools.getTelegramBotNameByIdApp(idapp);
|
||||
try {
|
||||
const token = tools.getTelegramKeyByIdApp(idapp);
|
||||
const nomebot = tools.getTelegramBotNameByIdApp(idapp);
|
||||
|
||||
// console.log('idapp', idapp, 'token', token);
|
||||
// console.log('idapp', idapp, 'token', token);
|
||||
|
||||
if (!!token) {
|
||||
console.log('*** START BOT ' + nomebot);
|
||||
const bot = new TelegramBot(token, {polling: true});
|
||||
if (!!token) {
|
||||
console.log('*** START BOT ' + nomebot);
|
||||
const bot = new TelegramBot(token, {polling: true});
|
||||
|
||||
if (url === '0') {
|
||||
const ngrok = require('ngrok');
|
||||
ngrok.connect(port, function onConnect(error, u) {
|
||||
if (error) throw error;
|
||||
url = u;
|
||||
console.log(`Game tunneled at ${url}`);
|
||||
});
|
||||
}
|
||||
if (url === '0') {
|
||||
const ngrok = require('ngrok');
|
||||
ngrok.connect(port, function onConnect(error, u) {
|
||||
if (error) throw error;
|
||||
url = u;
|
||||
console.log(`Game tunneled at ${url}`);
|
||||
});
|
||||
}
|
||||
|
||||
arrTelegram.push({idapp, cl: new Telegram(idapp, bot)});
|
||||
arrTelegram.push({idapp, cl: new Telegram(idapp, bot)});
|
||||
|
||||
bot.onText(/\/start/, (msg) => {
|
||||
const myclTelegram = getclTelegBytoken(bot.token);
|
||||
|
||||
myclTelegram.start(msg);
|
||||
|
||||
});
|
||||
|
||||
// Matches "/echo [whatever]"
|
||||
bot.onText(/\/echo (.+)/, (msg, match) => {
|
||||
// 'msg' is the received Message from Telegram
|
||||
// 'match' is the result of executing the regexp above on the text content
|
||||
// of the message
|
||||
|
||||
const chatId = msg.chat.id;
|
||||
const resp = match[1]; // the captured "whatever"
|
||||
|
||||
// send back the matched "whatever" to the chat
|
||||
bot.sendMessage(chatId, resp);
|
||||
});
|
||||
|
||||
// Listen for any kind of message. There are different kinds of
|
||||
// messages.
|
||||
bot.on('message', (msg) => {
|
||||
|
||||
const myclTelegram = getclTelegBytoken(bot.token);
|
||||
|
||||
// const chatId = msg.chat.id;
|
||||
|
||||
myclTelegram.receiveMsg(msg);
|
||||
});
|
||||
|
||||
// Handle callback queries
|
||||
bot.on('callback_query', async (callbackQuery) => {
|
||||
// console.log('callback_query', callbackQuery);
|
||||
|
||||
try {
|
||||
bot.onText(/\/start/, (msg) => {
|
||||
const myclTelegram = getclTelegBytoken(bot.token);
|
||||
|
||||
let dataarr = [];
|
||||
let data = {
|
||||
action: '',
|
||||
username: '',
|
||||
userDest: '',
|
||||
groupId: 0,
|
||||
};
|
||||
myclTelegram.start(msg);
|
||||
|
||||
const datastr = callbackQuery.data;
|
||||
if (!!datastr) {
|
||||
dataarr = datastr.split(tools.SEP);
|
||||
if (!!dataarr) {
|
||||
data = {
|
||||
action: dataarr[0],
|
||||
username: dataarr[1] ? dataarr[1] : '',
|
||||
userDest: dataarr[2] ? dataarr[2] : '',
|
||||
groupId: dataarr[3] ? parseInt(dataarr[3]) : '',
|
||||
};
|
||||
});
|
||||
|
||||
// Matches "/echo [whatever]"
|
||||
bot.onText(/\/echo (.+)/, (msg, match) => {
|
||||
// 'msg' is the received Message from Telegram
|
||||
// 'match' is the result of executing the regexp above on the text content
|
||||
// of the message
|
||||
|
||||
const chatId = msg.chat.id;
|
||||
const resp = match[1]; // the captured "whatever"
|
||||
|
||||
// send back the matched "whatever" to the chat
|
||||
bot.sendMessage(chatId, resp);
|
||||
});
|
||||
|
||||
// Listen for any kind of message. There are different kinds of
|
||||
// messages.
|
||||
bot.on('message', (msg) => {
|
||||
|
||||
const myclTelegram = getclTelegBytoken(bot.token);
|
||||
|
||||
// const chatId = msg.chat.id;
|
||||
|
||||
myclTelegram.receiveMsg(msg);
|
||||
});
|
||||
|
||||
// Handle callback queries
|
||||
bot.on('callback_query', async (callbackQuery) => {
|
||||
// console.log('callback_query', callbackQuery);
|
||||
|
||||
try {
|
||||
const myclTelegram = getclTelegBytoken(bot.token);
|
||||
|
||||
let dataarr = [];
|
||||
let data = {
|
||||
action: '',
|
||||
username: '',
|
||||
userDest: '',
|
||||
groupId: 0,
|
||||
};
|
||||
|
||||
const datastr = callbackQuery.data;
|
||||
if (!!datastr) {
|
||||
dataarr = datastr.split(tools.SEP);
|
||||
if (!!dataarr) {
|
||||
data = {
|
||||
action: dataarr[0],
|
||||
username: dataarr[1] ? dataarr[1] : '',
|
||||
userDest: dataarr[2] ? dataarr[2] : '',
|
||||
groupId: dataarr[3] ? parseInt(dataarr[3]) : '',
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
const msg = callbackQuery.message;
|
||||
const opts = {
|
||||
chat_id: msg.chat.id,
|
||||
message_id: msg.message_id,
|
||||
};
|
||||
const msg = callbackQuery.message;
|
||||
const opts = {
|
||||
chat_id: msg.chat.id,
|
||||
message_id: msg.message_id,
|
||||
};
|
||||
|
||||
const status = await myclTelegram.setInit(msg);
|
||||
const status = await myclTelegram.setInit(msg);
|
||||
|
||||
const rec = myclTelegram.getRecInMem(msg);
|
||||
const rec = myclTelegram.getRecInMem(msg);
|
||||
|
||||
const username_action = rec.user ? rec.user.username : '';
|
||||
const username_action = rec.user ? rec.user.username : '';
|
||||
|
||||
data.username = await User.getRealUsernameByUsername(idapp, data.username);
|
||||
data.userDest = await User.getRealUsernameByUsername(idapp, data.userDest);
|
||||
data.username = await User.getRealUsernameByUsername(idapp, data.username);
|
||||
data.userDest = await User.getRealUsernameByUsername(idapp, data.userDest);
|
||||
|
||||
const user = await User.getUserShortDataByUsername(idapp, data.username);
|
||||
const userDest = data.userDest ? await User.getUserShortDataByUsername(idapp, data.userDest) : null;
|
||||
const user = await User.getUserShortDataByUsername(idapp, data.username);
|
||||
const userDest = data.userDest ? await User.getUserShortDataByUsername(idapp, data.userDest) : null;
|
||||
|
||||
let group = null;
|
||||
let circuit = null;
|
||||
if (data.groupId) {
|
||||
group = await MyGroup.findOne({idapp, _id: data.groupId}).lean();
|
||||
}
|
||||
if (data.circuitId) {
|
||||
circuit = await Circuit.findOne({idapp, _id: data.circuitId}).lean();
|
||||
}
|
||||
let group = null;
|
||||
let circuit = null;
|
||||
if (data.groupId) {
|
||||
group = await MyGroup.findOne({idapp, _id: data.groupId}).lean();
|
||||
}
|
||||
if (data.circuitId) {
|
||||
circuit = await Circuit.findOne({idapp, _id: data.circuitId}).lean();
|
||||
}
|
||||
|
||||
let cmd = 0;
|
||||
let cmd = 0;
|
||||
|
||||
if (!!rec) {
|
||||
if (!!user) {
|
||||
if (data.action === InlineCmd.VOGLIO_IMBARCARMI) {
|
||||
// Controlla se è qualificato!
|
||||
const mydata = tools.AddDate(user.date_reg, 7);
|
||||
if (!!rec) {
|
||||
if (!!user) {
|
||||
if (data.action === InlineCmd.VOGLIO_IMBARCARMI) {
|
||||
// Controlla se è qualificato!
|
||||
const mydata = tools.AddDate(user.date_reg, 7);
|
||||
|
||||
// bot.editMessageText(tools.gettranslate('ADDED_TOLISTAINGRESSO', user.lang), opts);
|
||||
// bot.editMessageText(tools.gettranslate('ADDED_TOLISTAINGRESSO', user.lang), opts);
|
||||
|
||||
} else if (data.action === InlineCmd.NON_VOGLIO_IMBARCARMI) {
|
||||
await User.NonVoglioImbarcarmi(user.idapp, user.username);
|
||||
} else if (data.action === InlineCmd.NON_VOGLIO_IMBARCARMI) {
|
||||
await User.NonVoglioImbarcarmi(user.idapp, user.username);
|
||||
|
||||
const msgadd = '[' + user.username + '] ' + user.name + ' ' +
|
||||
user.surname + ' ha risposto che NON VUOLE IMBARCARSI !';
|
||||
const msgadd = '[' + user.username + '] ' + user.name + ' ' +
|
||||
user.surname + ' ha risposto che NON VUOLE IMBARCARSI !';
|
||||
|
||||
await local_sendMsgTelegramToTheManagers(user.idapp, msgadd,
|
||||
msg, false); // Anche a STAFF
|
||||
} else if (data.action ===
|
||||
InlineZoomConferma.CONFERMA_ZOOM_PRESENZA) {
|
||||
await local_sendMsgTelegramToTheManagers(user.idapp, msgadd,
|
||||
msg, false); // Anche a STAFF
|
||||
} else if (data.action ===
|
||||
InlineZoomConferma.CONFERMA_ZOOM_PRESENZA) {
|
||||
|
||||
await User.setZoomPresenza(user.idapp, user._id, true);
|
||||
await User.setZoomPresenza(user.idapp, user._id, true);
|
||||
|
||||
} else if (data.action ===
|
||||
InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA) {
|
||||
} else if (data.action ===
|
||||
InlineZoomConferma.NON_CONFERMA_ZOOM_PRESENZA) {
|
||||
|
||||
await User.setZoomPresenza(user.idapp, user._id, false);
|
||||
await User.setZoomPresenza(user.idapp, user._id, false);
|
||||
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.REGISTRATION) {
|
||||
const changed = await myclTelegram.setCmdToUsername(rec,
|
||||
data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, true);
|
||||
|
||||
if (changed) {
|
||||
const req = tools.getReqByPar(user.idapp, username_action);
|
||||
await User.setFriendsCmd(req, user.idapp, data.username, userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
|
||||
|
||||
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 msgDest = printf(getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'), `${user.username}`, `${userDest.username}`);
|
||||
|
||||
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) {
|
||||
if (userDest.username === user.aportador_solidario) {
|
||||
const changed = await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, false);
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.REGISTRATION) {
|
||||
const changed = await myclTelegram.setCmdToUsername(rec,
|
||||
data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, true);
|
||||
|
||||
if (changed) {
|
||||
const nomeDest = tools.getNomeCognomeEUserNameByUser(userDest);
|
||||
const nomestr = tools.getNomeCognomeEUserNameByUser(user);
|
||||
const req = tools.getReqByPar(user.idapp, username_action);
|
||||
await User.setFriendsCmd(req, user.idapp, data.username, userDest.username, shared_consts.FRIENDSCMD.SETFRIEND);
|
||||
|
||||
const msgOrig = printf(getstr(userDest.lang, 'MSG_APORTADOR_DEST_NOT_CONFIRMED', nomeDest));
|
||||
const msgDest = printf(getstr(user.lang, 'MSG_APORTADOR_NOT_CONFIRMED'), nomestr);
|
||||
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 msgDest = printf(getstr(user.lang, 'MSG_APORTADOR_CONFIRMED'), `${user.username}`, `${userDest.username}`);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
}
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_GRUPPO) {
|
||||
|
||||
if (group) {
|
||||
cmd = shared_consts.GROUPSCMD.SETGROUP;
|
||||
const foundIfAlreadyGroup = await User.ifAlreadyInGroup(user.idapp, data.username, group.groupname);
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.REGISTRATION) {
|
||||
if (userDest.username === user.aportador_solidario) {
|
||||
const changed = await myclTelegram.setCmdToUsername(rec, data.username,
|
||||
Cmd.VALIDATE_REGISTRATION, false);
|
||||
|
||||
if (!foundIfAlreadyGroup) {
|
||||
// Aggiungilo nel Gruppo
|
||||
await User.setGroupsCmd(user.idapp, data.username, group.groupname, cmd, 0, username_action);
|
||||
}
|
||||
if (changed) {
|
||||
const nomeDest = tools.getNomeCognomeEUserNameByUser(userDest);
|
||||
const nomestr = tools.getNomeCognomeEUserNameByUser(user);
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_GRUPPO) {
|
||||
|
||||
if (group) {
|
||||
cmd = shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP;
|
||||
const foundIfAlreadyGroup = await User.ifAlreadyInGroup(user.idapp, data.username, group.groupname);
|
||||
|
||||
if (foundIfAlreadyGroup) {
|
||||
// Rimuovilo nel Gruppo
|
||||
await User.setGroupsCmd(user.idapp, data.username, group.groupname, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.SET;
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (!foundIfAlreadyCircuit) {
|
||||
// Aggiungilo nel Gruppo
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST;
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (foundIfAlreadyCircuit) {
|
||||
// Rimuovilo nel Circuito
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} 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 req = tools.getReqByPar(user.idapp, username_action);
|
||||
const ris = await User.setFriendsCmd(req, user.idapp, data.username, data.userDest, cmd);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
|
||||
|
||||
if (userDest) {
|
||||
cmd = shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS;
|
||||
const foundIfAlreadyFriend = await User.isMyFriend(user.idapp, data.username, data.userDest);
|
||||
|
||||
if (foundIfAlreadyFriend) {
|
||||
// Aggiungilo nelle Amicizie
|
||||
const ris = await User.setFriendsCmd(req, user.idapp, data.username, data.userDest, cmd);
|
||||
if (ris) {
|
||||
const msgDest = printf(getstr(user.lang, 'MSG_FRIENDS_NOT_ACCEPTED_CONFIRMED'), data.username);
|
||||
const msgOrig = printf(getstr(userDest.lang, 'MSG_APORTADOR_DEST_NOT_CONFIRMED', nomeDest));
|
||||
const msgDest = printf(getstr(user.lang, 'MSG_APORTADOR_NOT_CONFIRMED'), nomestr);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.username, msgOrig);
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
}
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_GRUPPO) {
|
||||
|
||||
if (group) {
|
||||
cmd = shared_consts.GROUPSCMD.SETGROUP;
|
||||
const foundIfAlreadyGroup = await User.ifAlreadyInGroup(user.idapp, data.username, group.groupname);
|
||||
|
||||
if (!foundIfAlreadyGroup) {
|
||||
// Aggiungilo nel Gruppo
|
||||
await User.setGroupsCmd(user.idapp, data.username, group.groupname, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_GRUPPO) {
|
||||
|
||||
if (group) {
|
||||
cmd = shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP;
|
||||
const foundIfAlreadyGroup = await User.ifAlreadyInGroup(user.idapp, data.username, group.groupname);
|
||||
|
||||
if (foundIfAlreadyGroup) {
|
||||
// Rimuovilo nel Gruppo
|
||||
await User.setGroupsCmd(user.idapp, data.username, group.groupname, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_SI + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.SET;
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (!foundIfAlreadyCircuit) {
|
||||
// Aggiungilo nel Gruppo
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_CIRCUIT) {
|
||||
|
||||
if (circuit) {
|
||||
cmd = shared_consts.CIRCUITCMD.REMOVE_FROM_MYLIST;
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(user.idapp, data.username, circuit.name);
|
||||
|
||||
if (foundIfAlreadyCircuit) {
|
||||
// Rimuovilo nel Circuito
|
||||
await User.setCircuitCmd(user.idapp, data.username, circuit.name, cmd, 0, username_action);
|
||||
}
|
||||
|
||||
}
|
||||
} 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 req = tools.getReqByPar(user.idapp, username_action);
|
||||
const ris = await User.setFriendsCmd(req, user.idapp, data.username, data.userDest, cmd);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else if (data.action === InlineConferma.RISPOSTA_NO + shared_consts.CallFunz.RICHIESTA_AMICIZIA) {
|
||||
|
||||
if (userDest) {
|
||||
cmd = shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS;
|
||||
const foundIfAlreadyFriend = await User.isMyFriend(user.idapp, data.username, data.userDest);
|
||||
|
||||
if (foundIfAlreadyFriend) {
|
||||
// Aggiungilo nelle Amicizie
|
||||
const ris = await User.setFriendsCmd(req, user.idapp, data.username, data.userDest, cmd);
|
||||
if (ris) {
|
||||
const msgDest = printf(getstr(user.lang, 'MSG_FRIENDS_NOT_ACCEPTED_CONFIRMED'), data.username);
|
||||
|
||||
await local_sendMsgTelegram(user.idapp, data.userDest, msgDest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error BOT callback_query', e);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error BOT callback_query', e);
|
||||
}
|
||||
|
||||
/*
|
||||
let text;
|
||||
/*
|
||||
let text;
|
||||
|
||||
if (action === 'edit') {
|
||||
text = 'Edited Text';
|
||||
}
|
||||
if (action === 'edit') {
|
||||
text = 'Edited Text';
|
||||
}
|
||||
|
||||
bot.editMessageText(text, opts);
|
||||
*/
|
||||
bot.editMessageText(text, opts);
|
||||
*/
|
||||
|
||||
// bot.answerCallbackQuery(callbackQuery.id, { url });
|
||||
});
|
||||
// bot.answerCallbackQuery(callbackQuery.id, { url });
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error Telegram LOOP : ' + e.message);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error Telegram LOOP : ' + e.message);
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
arrTeleg = [];
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
module.exports = MyTelegramBot;
|
||||
|
||||
Reference in New Issue
Block a user