mirror of
https://github.com/FliegendeWurst/telegram_notes_bot.git
synced 2024-10-18 05:10:46 +00:00
25 lines
702 B
JavaScript
25 lines
702 B
JavaScript
// Create as JS Backend note and add these attributes:
|
|
// ~targetTemplateEvent=@event template (this note is described below)
|
|
// #customRequestHandler=event_alerts
|
|
// Create another note (event template) with this promoted attributes:
|
|
// startTime
|
|
// Optionally add:
|
|
// endTime, location
|
|
|
|
const {req, res} = api;
|
|
|
|
const targetTemplate = await api.currentNote.getRelationValue("targetTemplateEvent");
|
|
const events = await api.getNotesWithLabel("template", targetTemplate);
|
|
|
|
let eventsData = [];
|
|
|
|
for (const event of events) {
|
|
const attr = await event.getAttribute("label", "startTime");
|
|
eventsData.push({
|
|
name: event.title,
|
|
startTime: attr.value
|
|
});
|
|
}
|
|
|
|
res.send(eventsData);
|