Abilitazione del BOT

This commit is contained in:
Surya Paolo
2023-12-17 16:20:44 +01:00
parent 4290895a97
commit c71f4af370
8 changed files with 221 additions and 13 deletions

View File

@@ -695,6 +695,7 @@ const ADMIN_IDTELEGRAM_TEST = 5356627050; // 5022837609; //Surya Arena
const MyTelegramBot = {
ADMIN_IDTELEGRAM_SERVER: '12429864', //Paolo
ADMIN_USERNAME_TELEGRAM: 'surya1977', //Paolo
ADMIN_USER_SERVER: 'paoloar77',
ADMIN_USER_NAME_SERVER: 'Paolo',
@@ -710,7 +711,7 @@ const MyTelegramBot = {
} else {
return appTelegram;
}
},
getAppTelegramTest: function () {
@@ -719,7 +720,7 @@ const MyTelegramBot = {
} else {
return appTelegram_TEST;
}
},
local_sendMsgTelegramByIdTelegram: async function (idapp, idtelegram, text,
@@ -978,7 +979,7 @@ const MyTelegramBot = {
if (send_notif && msg_notifpush) {
// SEND PUSH NOTIFICATION
await tools.sendNotificationToUser(userId, title, msg_notifpush, openUrl, '', tag, actions);
await tools.sendNotificationToUser(userId, title, msg_notifpush, openUrl, '', tag, actions);
}
@@ -3435,15 +3436,26 @@ class Telegram {
rec.status = Status.NONE;
if (!msg.from.username) {
// Non ha l'Username:
// Chiedi l'username sul Bot:
if (tools.getConfSiteOptionEnabledByIdApp(this.idapp, shared_consts.ConfSite.AskUsernameSulBot)) {
rec.status = Status.WAITFOR_USERNAME_TELEGRAM;
}
} else {
// Ha l'Username
// Chiedi l'invitante ?
if (tools.getConfSiteOptionEnabledByIdApp(this.idapp, shared_consts.ConfSite.AskInvitantesulBot)) {
rec.status = Status.WAITFOR_USERNAME_INVITANTE;
}
}
if (rec.status === Status.NONE) {
// Se il Sito non chiede di autenticarsi o l'invitante, allora lo Verifico direttamente !
rec.status = Status.VERIFIED;
}
this.arrUsers.push(rec);
if (tools.getConfSiteOptionEnabledByIdApp(this.idapp, shared_consts.ConfSite.AskInvitantesulBot)) {
@@ -4065,11 +4077,16 @@ if (true) {
else if (process.env.NODE_ENV === 'test')
arrTeleg = MyTelegramBot.getAppTelegramTest();
const arrTelegFromSite = tools.getArrTelegramFromSite();
if (arrTelegFromSite.length > 0) {
arrTeleg = arrTelegFromSite;
}
var internetAvailable = require('internet-available');
internetAvailable().then(() => {
// ..
console.log('TELEGRAM STARTING.... NODE_ENV:' + process.env.NODE_ENV);
console.log('TELEGRAM STARTING.... ' + process.env.NODE_ENV);
for (const idapp of arrTeleg) {
@@ -4080,7 +4097,9 @@ if (true) {
// console.log('idapp', idapp, 'token', token);
if (!!token) {
console.log('*** START BOT ' + nomebot);
console.log('-------------------------------------');
console.log('*** STARTING BOT ' + nomebot);
console.log('-------------------------------------');
const bot = new TelegramBot(token, { polling: true });
if (url === '0') {
@@ -4095,6 +4114,7 @@ if (true) {
arrTelegram.push({ idapp, cl: new Telegram(idapp, bot) });
bot.onText(/\/start/, (msg) => {
console.log('*** BOT PARTITO CORRETTAMENTE !!! (Start Cmd)');
const myclTelegram = getclTelegBytoken(bot.token);
myclTelegram.start(msg);