Zoom Calendar
This commit is contained in:
70
src/server/models/calzoom.js
Normal file
70
src/server/models/calzoom.js
Normal file
@@ -0,0 +1,70 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const CalZoomSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
lang: {
|
||||
type: String,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
},
|
||||
typeconf: {
|
||||
type: String,
|
||||
},
|
||||
date_start: {
|
||||
type: Date
|
||||
},
|
||||
date_end: {
|
||||
type: Date
|
||||
},
|
||||
id_conf_zoom: {
|
||||
type: String
|
||||
},
|
||||
note: {
|
||||
type: String
|
||||
}
|
||||
});
|
||||
|
||||
CalZoomSchema.statics.getFieldsForSearch = function () {
|
||||
return ['title']
|
||||
};
|
||||
|
||||
CalZoomSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
CalZoomSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const CalZoom = this;
|
||||
|
||||
const myfind = { idapp, date_start: { $gt: tools.IncDateNow(-1000 * 60 * 60 * 3) } };
|
||||
|
||||
return await CalZoom.find(myfind).sort({ date_start: 1 });
|
||||
};
|
||||
|
||||
CalZoomSchema.statics.getNextZoom = async function (idapp) {
|
||||
const CalZoom = this;
|
||||
|
||||
// const myfind = { idapp, $and: [{ date_start: { $gt: tools.IncDateNow(-1000 * 60 * 5) } }, { date_start: { $lt: tools.IncDateNow(1000 * 60 * 60 * 6) } }] } ;
|
||||
const myfind = { idapp, $and: [{ date_start: { $lt: tools.IncDateNow(1000 * 60 * 5) } }, { date_start: { $gt: tools.IncDateNow(-1000 * 60 * 60 * 2) } }] } ;
|
||||
|
||||
return await CalZoom.findOne(myfind).sort({ date_start: 1 });
|
||||
};
|
||||
|
||||
const CalZoom = mongoose.model('CalZoom', CalZoomSchema);
|
||||
|
||||
module.exports = { CalZoom };
|
||||
@@ -35,6 +35,7 @@ const { PaymentType } = require('../models/paymenttype');
|
||||
const { Discipline } = require('../models/discipline');
|
||||
const { Newstosent } = require('../models/newstosent');
|
||||
const { MyPage } = require('../models/mypage');
|
||||
const { CalZoom } = require('../models/calzoom');
|
||||
const { Gallery } = require('../models/gallery');
|
||||
const { TemplEmail } = require('../models/templemail');
|
||||
const { OpzEmail } = require('../models/opzemail');
|
||||
@@ -179,6 +180,8 @@ function getTableByTableName(tablename) {
|
||||
mytable = Gallery;
|
||||
else if (tablename === 'mypage')
|
||||
mytable = MyPage;
|
||||
else if (tablename === 'calzoom')
|
||||
mytable = CalZoom;
|
||||
else if (tablename === 'templemail')
|
||||
mytable = TemplEmail;
|
||||
else if (tablename === 'opzemail')
|
||||
@@ -425,6 +428,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
let newstosent = Promise.resolve([]);
|
||||
let mailinglist = Promise.resolve([]);
|
||||
let mypage = MyPage.findAllIdApp(idapp);
|
||||
let calzoom = CalZoom.findAllIdApp(idapp);
|
||||
let gallery = Gallery.findAllIdApp(idapp);
|
||||
if (sall) {
|
||||
newstosent = Newstosent.findAllIdApp(idapp);
|
||||
@@ -435,7 +439,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
calcstat = User.calculateStat(idapp, req.user.username);
|
||||
|
||||
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat])
|
||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom])
|
||||
.then((arrdata) => {
|
||||
// console.table(arrdata);
|
||||
const myuser = req.user;
|
||||
@@ -458,6 +462,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
||||
mypage: arrdata[10],
|
||||
gallery: arrdata[11],
|
||||
paymenttypes: arrdata[12],
|
||||
calzoom: arrdata[14],
|
||||
myuser,
|
||||
});
|
||||
})
|
||||
|
||||
@@ -111,7 +111,7 @@ router.post('/', async (req, res) => {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const already_registered = recextra;
|
||||
const already_registered = recextra || user.aportador_solidario === tools.APORTADOR_NONE;
|
||||
|
||||
|
||||
// Check if is an other people aportador_solidario
|
||||
|
||||
@@ -39,6 +39,7 @@ require('./models/sendmsg');
|
||||
require('./models/mailinglist');
|
||||
require('./models/newstosent');
|
||||
require('./models/mypage');
|
||||
require('./models/calzoom');
|
||||
const mysql_func = require('./mysql/mysql_func');
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ const appTelegram = ['7'];
|
||||
const printf = require('util').format;
|
||||
|
||||
const { User } = require('../models/user');
|
||||
const { CalZoom } = require('../models/calzoom');
|
||||
|
||||
const emoji = require('node-emoji');
|
||||
|
||||
@@ -13,6 +14,8 @@ const i18n = require("i18n");
|
||||
const Benvenuto = emoji.get('heartbeat') + emoji.get('heartbeat') + emoji.get('heartbeat') + ' Benvenuto!';
|
||||
|
||||
const emo = {
|
||||
STARS: emoji.get('stars'),
|
||||
FIRE: emoji.get('fire'),
|
||||
DREAM: emoji.get('beach_with_umbrella'),
|
||||
EYES: emoji.get('eyes'),
|
||||
DIZZY: emoji.get('dizzy'),
|
||||
@@ -61,6 +64,7 @@ function getemojibynumber(number) {
|
||||
const Menu = {
|
||||
LAVAGNA: emoji.get('om_symbol') + ' La tua Lavagna',
|
||||
LINK_CONDIVIDERE: emoji.get('link') + ' Link da condividere',
|
||||
ZOOM: emoji.get('information_source') + ' Zoom (Conferenze)',
|
||||
INFO: emoji.get('information_source') + ' Informazioni',
|
||||
ASSISTENZA: emoji.get('open_hands') + ' Assistenza',
|
||||
|
||||
@@ -75,8 +79,8 @@ const Menu = {
|
||||
};
|
||||
|
||||
|
||||
const MenuStandard = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.INFO, Menu.ASSISTENZA]];
|
||||
const MenuPerAdmin = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.INFO, Menu.ASSISTENZA], [Menu.ADMIN, Menu.ALTRO]];
|
||||
const MenuStandard = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.ASSISTENZA]];
|
||||
const MenuPerAdmin = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.ASSISTENZA], [Menu.ADMIN, Menu.ALTRO]];
|
||||
const MenuYesNo = [[Menu.SI, Menu.NO]];
|
||||
|
||||
const MenuAdmin = [[Menu.MSGATUTTI, Menu.INDIETRO], ['', '']];
|
||||
@@ -108,7 +112,7 @@ const txt = {
|
||||
MSG_VERIFY_OK: emoji.get('grinning') + ' Benvenuto %s. Ora sei correttamente verificato!',
|
||||
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Errore durante il salvataggio sul Server. Riprovare piú tardi',
|
||||
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
|
||||
MSG_APORTADOR_USER_REGISTERED: emoji.get('heart_eyes') + ' Si è appena Registrato %s\n(Invitato da %s)',
|
||||
MSG_APORTADOR_USER_REGISTERED: emo.FIRE + ' Si è appena Registrato %s\n(Invitato da %s)',
|
||||
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
||||
};
|
||||
|
||||
@@ -246,6 +250,8 @@ class Telegram {
|
||||
await this.menuAssistenza(msg)
|
||||
} else if (msg.text === Menu.INFO) {
|
||||
await this.menuInformazioni(msg)
|
||||
} else if (msg.text === Menu.ZOOM) {
|
||||
await this.menuZoom(msg)
|
||||
} else {
|
||||
await this.msgScegliMenu(msg);
|
||||
}
|
||||
@@ -366,9 +372,56 @@ class Telegram {
|
||||
await this.sendMsg(msg.chat.id, mystr);
|
||||
}
|
||||
|
||||
async menuZoom(msg) {
|
||||
let mystr = '';
|
||||
const listazoom = await CalZoom.findAllIdApp(this.idapp);
|
||||
|
||||
const nextzoom = await CalZoom.getNextZoom(this.idapp);
|
||||
|
||||
mystr += emo.STARS + 'Zoom in programma:' + emo.STARS + '\n\n';
|
||||
|
||||
let index = 1;
|
||||
listazoom.forEach((evento) => {
|
||||
let iniziata = false;
|
||||
if (nextzoom)
|
||||
iniziata = (nextzoom._id.toString() === evento._id.toString());
|
||||
|
||||
|
||||
if (iniziata) {
|
||||
mystr += emo.CHECK_VERDE + ' QUESTA CONFERENZA E\' INIZIATA! ' + emo.CHECK_VERDE + '\n';
|
||||
}
|
||||
|
||||
mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start)} ${emo.EYES}`;
|
||||
mystr += `\n${evento.title}\n(${evento.note})\n\n`;
|
||||
if (nextzoom) {
|
||||
if (iniziata) {
|
||||
mystr += emo.FIRE + 'CLICCA QUI PER ENTRARE ! ' + emo.FIRE + '\n';
|
||||
mystr += tools.getlinkzoom(evento.id_conf_zoom) + '\n\n';
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
await
|
||||
this
|
||||
.sendMsg(msg
|
||||
|
||||
.chat
|
||||
.id
|
||||
,
|
||||
mystr
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
async menuAdmin(msg) {
|
||||
const mystr = 'scegli una voce:';
|
||||
await this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
await
|
||||
this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
}
|
||||
|
||||
async menumsgAll(msg) {
|
||||
@@ -376,7 +429,8 @@ class Telegram {
|
||||
if (rec.user) {
|
||||
const mystr = 'Scrivi qui un Messaggio da inviare a TUTTI:';
|
||||
rec.msgall_status = StatusMSGALL.ASK;
|
||||
await this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
await
|
||||
this.sendMsg(msg.chat.id, mystr, MenuAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,7 +438,8 @@ class Telegram {
|
||||
|
||||
const mytext = tools.get__('TESTO_ASSISTENZA', msg);
|
||||
|
||||
await this.sendMsg(msg.chat.id, mytext);
|
||||
await
|
||||
this.sendMsg(msg.chat.id, mytext);
|
||||
}
|
||||
|
||||
existInMemory(msg) {
|
||||
@@ -422,23 +477,29 @@ class Telegram {
|
||||
rec.username_bo = text;
|
||||
|
||||
// Check if username exist
|
||||
const user = await User.findByUsername(this.idapp, rec.username_bo);
|
||||
const user = await
|
||||
User.findByUsername(this.idapp, rec.username_bo);
|
||||
if (!user) {
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND)
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND)
|
||||
} else {
|
||||
rec.user = user;
|
||||
await User.SetTelegramCheckCode(this.idapp, rec.username_bo, rec.code);
|
||||
await
|
||||
User.SetTelegramCheckCode(this.idapp, rec.username_bo, rec.code);
|
||||
rec.status = Status.WAITFOR_VERIFY_CODE;
|
||||
await this.sendMsg(msg.from.id, txt.MSG_VERIFY_CODE)
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_VERIFY_CODE)
|
||||
}
|
||||
}
|
||||
} else if (text.length === 0) {
|
||||
if (rec)
|
||||
rec.status = Status.NONE;
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA);
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA);
|
||||
this.deleteRecInMem(msg)
|
||||
} else {
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME)
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error setUsernameBo:', e)
|
||||
@@ -448,34 +509,39 @@ class Telegram {
|
||||
async setVerifyCode(msg) {
|
||||
try {
|
||||
const rec = this.getRecInMem(msg);
|
||||
const user = await User.findByUsername(this.idapp, rec.username_bo);
|
||||
const user = await
|
||||
User.findByUsername(this.idapp, rec.username_bo);
|
||||
const code = msg.text.toString().trim();
|
||||
let telegcode = 0;
|
||||
if (user) {
|
||||
telegcode = user.profile.teleg_checkcode.toString();
|
||||
} else {
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND);
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND);
|
||||
return
|
||||
}
|
||||
if (msg.text.length < 7) {
|
||||
if (rec) {
|
||||
if (code === telegcode) {
|
||||
rec.status = Status.VERIFIED;
|
||||
await User.SetTelegramIdSuccess(this.idapp, rec.username_bo, msg.from.id).then((recuser) => {
|
||||
if (recuser) {
|
||||
let name = recuser.name;
|
||||
this.sendMsg(msg.from.id, printf(txt.MSG_VERIFY_OK, name))
|
||||
} else {
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERR_UNKNOWN_VERIFY_CODE);
|
||||
}
|
||||
});
|
||||
await
|
||||
User.SetTelegramIdSuccess(this.idapp, rec.username_bo, msg.from.id).then((recuser) => {
|
||||
if (recuser) {
|
||||
let name = recuser.name;
|
||||
this.sendMsg(msg.from.id, printf(txt.MSG_VERIFY_OK, name))
|
||||
} else {
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERR_UNKNOWN_VERIFY_CODE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (rec.retry < 2) {
|
||||
rec.retry++;
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERR_VERIFY_CODE)
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERR_VERIFY_CODE)
|
||||
} else {
|
||||
rec.status = Status.NONE;
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA);
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA);
|
||||
this.deleteRecInMem(msg);
|
||||
}
|
||||
}
|
||||
@@ -483,9 +549,11 @@ class Telegram {
|
||||
} else if (msg.text.length === 0) {
|
||||
if (rec)
|
||||
rec.status = Status.NONE;
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA)
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA)
|
||||
} else {
|
||||
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_VERIFY_CODE_MAXLEN)
|
||||
await
|
||||
this.sendMsg(msg.from.id, txt.MSG_ERRORE_VERIFY_CODE_MAXLEN)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error setVerifyCode', e);
|
||||
@@ -495,18 +563,21 @@ class Telegram {
|
||||
async sendMsgToAll(rec, msg, texttosend) {
|
||||
if (texttosend.length < 3) {
|
||||
} else {
|
||||
const usersall = await User.getUsersTelegALL(rec.user.idapp);
|
||||
const usersall = await
|
||||
User.getUsersTelegALL(rec.user.idapp);
|
||||
|
||||
let nummsgsent = 0;
|
||||
|
||||
if (usersall) {
|
||||
for (const rec of usersall) {
|
||||
await this.sendMsg(rec.profile.teleg_id, texttosend);
|
||||
await
|
||||
this.sendMsg(rec.profile.teleg_id, texttosend);
|
||||
nummsgsent++;
|
||||
}
|
||||
}
|
||||
|
||||
await this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_SENT));
|
||||
await
|
||||
this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_SENT));
|
||||
}
|
||||
rec.start_write_msgall = false;
|
||||
|
||||
@@ -519,29 +590,35 @@ class Telegram {
|
||||
async receiveMsg(msg) {
|
||||
let status = this.getstatusInMemory(msg);
|
||||
if (status === Status.NONE) {
|
||||
await this.start(msg);
|
||||
await
|
||||
this.start(msg);
|
||||
let status = this.getstatusInMemory(msg);
|
||||
if (status !== Status.VERIFIED)
|
||||
return
|
||||
} else {
|
||||
await this.setUser(msg)
|
||||
await
|
||||
this.setUser(msg)
|
||||
}
|
||||
|
||||
const rec = this.getRecInMem(msg);
|
||||
|
||||
status = this.getstatus(rec);
|
||||
if (status === Status.WAITFOR_USERNAME_BO && !this.selectMenuHelp(msg)) {
|
||||
await this.setUsernameBo(msg)
|
||||
await
|
||||
this.setUsernameBo(msg)
|
||||
} else if (status === Status.WAITFOR_VERIFY_CODE) {
|
||||
await this.setVerifyCode(msg)
|
||||
await
|
||||
this.setVerifyCode(msg)
|
||||
} else if (status === Status.NONE) {
|
||||
await this.start(msg);
|
||||
await
|
||||
this.start(msg);
|
||||
} else if (status === Status.VERIFIED) {
|
||||
let normale = true;
|
||||
if (rec.msgall_status === StatusMSGALL.CONFIRM) {
|
||||
if (msg.text === Menu.SI) {
|
||||
// Take msg to send to ALL
|
||||
await this.sendMsgToAll(rec, msg, rec.msgtosent)
|
||||
await
|
||||
this.sendMsgToAll(rec, msg, rec.msgtosent)
|
||||
} else {
|
||||
this.sendMsg(msg.chat.id, txt.MSG_OPERAZ_ANNULLATA);
|
||||
}
|
||||
@@ -555,17 +632,20 @@ class Telegram {
|
||||
this.ChiediSINO(msg, domanda);
|
||||
} else {
|
||||
rec.msgall_status = StatusMSGALL.NONE;
|
||||
await this.msgScegliMenu(msg);
|
||||
await
|
||||
this.msgScegliMenu(msg);
|
||||
}
|
||||
normale = false
|
||||
}
|
||||
|
||||
if (normale) {
|
||||
// Check Menu
|
||||
await this.isMenu(rec, msg);
|
||||
await
|
||||
this.isMenu(rec, msg);
|
||||
}
|
||||
} else {
|
||||
await this.isMenuNotVerified(rec, msg);
|
||||
await
|
||||
this.isMenuNotVerified(rec, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,9 +653,11 @@ class Telegram {
|
||||
|
||||
const rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
|
||||
if (!rec) {
|
||||
await this.addUser(msg);
|
||||
await
|
||||
this.addUser(msg);
|
||||
|
||||
await this.sendMsg(msg.chat.id, getstr(msg.from.language_code, txt.MSG_ASK_USERNAME_BO));
|
||||
await
|
||||
this.sendMsg(msg.chat.id, getstr(msg.from.language_code, txt.MSG_ASK_USERNAME_BO));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -585,7 +667,8 @@ class Telegram {
|
||||
|
||||
async setUser(msg) {
|
||||
const id = msg.from.id;
|
||||
const user = await User.UserByIdTelegram(this.idapp, id);
|
||||
const user = await
|
||||
User.UserByIdTelegram(this.idapp, id);
|
||||
let rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
|
||||
if (user && rec) {
|
||||
rec.user = user;
|
||||
@@ -597,7 +680,8 @@ class Telegram {
|
||||
const id = msg.from.id;
|
||||
let rec = null;
|
||||
try {
|
||||
const user = await User.UserByIdTelegram(this.idapp, id);
|
||||
const user = await
|
||||
User.UserByIdTelegram(this.idapp, id);
|
||||
let rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
|
||||
if (user && !rec) {
|
||||
rec = this.addUser(msg);
|
||||
@@ -645,7 +729,8 @@ class Telegram {
|
||||
async getKeyboard(id, menu) {
|
||||
let keyb = MenuStandard;
|
||||
// Check if you are Admin
|
||||
const ismanager = await User.isManagerByIdTeleg(this.idapp, id);
|
||||
const ismanager = await
|
||||
User.isManagerByIdTeleg(this.idapp, id);
|
||||
if (ismanager)
|
||||
keyb = MenuPerAdmin;
|
||||
if (menu) {
|
||||
@@ -664,7 +749,8 @@ class Telegram {
|
||||
"resize_keyboard": true,
|
||||
"keyboard": await this.getKeyboard(id, menu)
|
||||
}
|
||||
});
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
async msgBenvenuto(id) {
|
||||
@@ -674,7 +760,8 @@ class Telegram {
|
||||
"resize_keyboard": true,
|
||||
"keyboard": await this.getKeyboard(id)
|
||||
}
|
||||
});
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
async ChiediSINO(msg, domanda) {
|
||||
@@ -695,7 +782,8 @@ class Telegram {
|
||||
"resize_keyboard": true,
|
||||
"keyboard": await this.getKeyboard(msg.from.id)
|
||||
}
|
||||
});
|
||||
})
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@ webpush.setVapidDetails(subject, publicVapidKey, privateVapidKey);
|
||||
// console.log('setVapidDetails... config...');
|
||||
|
||||
|
||||
|
||||
|
||||
// To Translate!
|
||||
textlang = {
|
||||
it: {
|
||||
@@ -117,7 +115,7 @@ module.exports = {
|
||||
gettranslate(text, lang) {
|
||||
try {
|
||||
return textlang[lang][text]
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
return textlang['it'][text]
|
||||
}
|
||||
},
|
||||
@@ -128,7 +126,7 @@ module.exports = {
|
||||
lang = msg.from.language_code;
|
||||
try {
|
||||
return textlang[lang][text]
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
return textlang['it'][text]
|
||||
}
|
||||
},
|
||||
@@ -138,7 +136,7 @@ module.exports = {
|
||||
let lang = 'it';
|
||||
try {
|
||||
return textlang[lang][text]
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
return textlang['it'][text]
|
||||
}
|
||||
},
|
||||
@@ -649,6 +647,33 @@ module.exports = {
|
||||
return mydate
|
||||
},
|
||||
|
||||
appendLeadingZeroes(n) {
|
||||
if (n <= 9) {
|
||||
return "0" + n;
|
||||
}
|
||||
return n
|
||||
},
|
||||
|
||||
getWeekDay(date) {
|
||||
//Create an array containing each day, starting with Sunday.
|
||||
const weekdays = [
|
||||
"Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedí", "Venerdì", "Sabato"
|
||||
];
|
||||
//Use the getDay() method to get the day.
|
||||
const day = date.getDay();
|
||||
//Return the element that corresponds to that index.
|
||||
return weekdays[day];
|
||||
},
|
||||
|
||||
getstrDateTimeShort(mydate) {
|
||||
// console.log('getstrDate', mytimestamp)
|
||||
return this.getWeekDay(mydate) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1) + ' ORE ' + this.appendLeadingZeroes(mydate.getHours()) + ':' + this.appendLeadingZeroes(mydate.getMinutes());
|
||||
},
|
||||
|
||||
getlinkzoom(idconf) {
|
||||
return 'https://zoom.us/j/' + idconf
|
||||
},
|
||||
|
||||
getmd5(mystr) {
|
||||
return CryptoJS.MD5(mystr.toLowerCase()).toString();
|
||||
},
|
||||
@@ -786,7 +811,7 @@ module.exports = {
|
||||
if (campi.length === 2) {
|
||||
namesurname.name = campi[0];
|
||||
namesurname.surname = campi[1];
|
||||
}else if (campi.length === 3) {
|
||||
} else if (campi.length === 3) {
|
||||
if (suffissoCognome.includes(campi[1])) {
|
||||
namesurname.name = campi[0];
|
||||
namesurname.surname = campi[1] + " " + campi[2];
|
||||
@@ -794,10 +819,10 @@ module.exports = {
|
||||
namesurname.name = campi[0] + " " + campi[1];
|
||||
namesurname.surname = campi[2];
|
||||
}
|
||||
}else if (campi.length === 4) {
|
||||
} else if (campi.length === 4) {
|
||||
namesurname.name = campi[0] + " " + campi[1];
|
||||
namesurname.surname = campi[2] + " " + campi[3];
|
||||
}else if (campi.length > 4) {
|
||||
} else if (campi.length > 4) {
|
||||
namesurname.name = campi[0] + " " + campi[1];
|
||||
namesurname.surname = " " + campi[2];
|
||||
for (let ind = 3; ind < campi.length; ind++) {
|
||||
|
||||
Reference in New Issue
Block a user