Doppia modalità di Registrazione con lista extra utenti

This commit is contained in:
Paolo Arena
2020-01-13 23:52:51 +01:00
parent 8f784df4fa
commit e23a3a792e
25 changed files with 829 additions and 163 deletions

View File

@@ -423,64 +423,67 @@ function getclTelegByidapp(idapp) {
return null;
}
for (const idapp of appTelegram) {
if (!tools.testing()) {
console.log('TELEGRAM STARTING.... ');
for (const idapp of appTelegram) {
const token = tools.getTelegramKeyByIdApp(idapp);
// console.log('idapp', idapp, 'token', token);
const token = tools.getTelegramKeyByIdApp(idapp);
// console.log('idapp', idapp, 'token', token);
if (!!token) {
const bot = new TelegramBot(token, { polling: true });
if (!!token) {
const bot = new TelegramBot(token, { polling: true });
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);
bot.onText(/\/start/, (msg) => {
const myclTelegram = getclTelegBytoken(bot.token);
myclTelegram.start(msg);
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
// 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"
const chatId = msg.chat.id;
const resp = match[1]; // the captured "whatever"
// send back the matched "whatever" to the chat
bot.sendMessage(chatId, resp);
});
// 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) => {
// Listen for any kind of message. There are different kinds of
// messages.
bot.on('message', (msg) => {
const myclTelegram = getclTelegBytoken(bot.token);
const myclTelegram = getclTelegBytoken(bot.token);
// console.log('msg', msg);
const chatId = msg.chat.id;
// console.log('msg', msg);
const chatId = msg.chat.id;
myclTelegram.receiveMsg(msg);
// var bye = "bye";
// if (msg.text.toString().toLowerCase().includes(bye)) {
// bot.sendMessage(msg.chat.id, "Hope to see you around again , Bye");
// }
myclTelegram.receiveMsg(msg);
// var bye = "bye";
// if (msg.text.toString().toLowerCase().includes(bye)) {
// bot.sendMessage(msg.chat.id, "Hope to see you around again , Bye");
// }
// send a message to the chat acknowledging receipt of their message
// bot.sendMessage(chatId, 'Received your message');
});
// send a message to the chat acknowledging receipt of their message
// bot.sendMessage(chatId, 'Received your message');
});
// Handle callback queries
bot.on('callback_query', function onCallbackQuery(callbackQuery) {
console.log('callback_query', callbackQuery);
// Handle callback queries
bot.on('callback_query', function onCallbackQuery(callbackQuery) {
console.log('callback_query', callbackQuery);
bot.answerCallbackQuery(callbackQuery.id, { url });
});
}
bot.answerCallbackQuery(callbackQuery.id, { url });
});
}
}