🎉 Generate ical calendar
This commit is contained in:
parent
2e335b5382
commit
fae86d6f9f
3
.gitignore
vendored
3
.gitignore
vendored
@ -134,7 +134,6 @@ dist
|
|||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/node
|
# End of https://www.toptal.com/developers/gitignore/api/node
|
||||||
|
|
||||||
|
|
||||||
config.json
|
config.json
|
||||||
|
|
||||||
test
|
test
|
||||||
|
public/
|
43
bot.js
43
bot.js
@ -3,20 +3,28 @@
|
|||||||
|
|
||||||
const axios = require("axios").default;
|
const axios = require("axios").default;
|
||||||
const moment = require("moment");
|
const moment = require("moment");
|
||||||
|
const ical = require("ical-generator").default;
|
||||||
|
|
||||||
const config = require("./config.json");
|
const config = require("./config.json");
|
||||||
|
|
||||||
async function main() {
|
//let events_data
|
||||||
// let data = (await axios("https://vps.anotherfoxguy.com/dl/fur-events.json")).data;
|
|
||||||
let data = (await axios("https://api.fynn.ai/v1/events")).data;
|
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
//events_data = (await axios("https://vps.anotherfoxguy.com/dl/fur-events.json")).data;
|
||||||
|
events_data = (await axios("https://api.fynn.ai/v1/events")).data;
|
||||||
|
|
||||||
|
//GenDiscord();
|
||||||
|
GenIcal();
|
||||||
|
}
|
||||||
|
|
||||||
|
function GenDiscord() {
|
||||||
let min = moment().add(1, "minutes"); // minutes
|
let min = moment().add(1, "minutes"); // minutes
|
||||||
let max = moment().add(61, "minutes");
|
let max = moment().add(61, "minutes");
|
||||||
// let max = moment().add(8, "hours");
|
// let max = moment().add(8, "hours");
|
||||||
|
|
||||||
//console.log(dat.data)
|
//console.log(dat.data)
|
||||||
|
|
||||||
data = data.filter((event) => event.type != "Lobby");
|
let data = events_data.filter((event) => event.type != "Lobby");
|
||||||
const events = data.filter((event) =>
|
const events = data.filter((event) =>
|
||||||
moment.unix(event.start).isBetween(min, max)
|
moment.unix(event.start).isBetween(min, max)
|
||||||
);
|
);
|
||||||
@ -26,7 +34,7 @@ async function main() {
|
|||||||
events.forEach((event) => {
|
events.forEach((event) => {
|
||||||
console.log(event.name);
|
console.log(event.name);
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.subType) {
|
||||||
case "Meetup":
|
case "Meetup":
|
||||||
colour = 1293056;
|
colour = 1293056;
|
||||||
break;
|
break;
|
||||||
@ -88,4 +96,29 @@ async function main() {
|
|||||||
//let event = data[1];
|
//let event = data[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GenIcal() {
|
||||||
|
const calendar = ical({
|
||||||
|
name: 'Furality Schedule',
|
||||||
|
description: 'Unofficial Furality Schedule created by AnotherFoxGuy',
|
||||||
|
source: 'https://furality.anotherfoxguy.com/calendar.ical',
|
||||||
|
ttl: 3600
|
||||||
|
});
|
||||||
|
|
||||||
|
events_data.forEach((event) => {
|
||||||
|
calendar.createEvent({
|
||||||
|
id: event.id,
|
||||||
|
start: moment.unix(event.start),
|
||||||
|
end: moment.unix(event.end),
|
||||||
|
summary: event.name,
|
||||||
|
description: event.description,
|
||||||
|
url: `https://furality.org/schedule#${event.id}`,
|
||||||
|
attachments: [
|
||||||
|
event.imageUrl
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
calendar.save('./public/calendar.ical');
|
||||||
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
57
package-lock.json
generated
57
package-lock.json
generated
@ -6,6 +6,7 @@
|
|||||||
"": {
|
"": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
|
"ical-generator": "^4.1.0",
|
||||||
"moment": "^2.29.4"
|
"moment": "^2.29.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -75,6 +76,57 @@
|
|||||||
"node": ">= 6"
|
"node": ">= 6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ical-generator": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ical-generator/-/ical-generator-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-5GrFDJ8SAOj8cB9P1uEZIfKrNxSZ1R2eOQfZePL+CtdWh4RwNXWe8b0goajz+Hu37vcipG3RVldoa2j57Y20IA==",
|
||||||
|
"dependencies": {
|
||||||
|
"uuid-random": "^1.3.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^14.8.0 || >=16.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@touch4it/ical-timezones": ">=1.6.0",
|
||||||
|
"@types/luxon": ">= 1.26.0",
|
||||||
|
"@types/mocha": ">= 8.2.1",
|
||||||
|
"@types/node": ">= 15.0.0",
|
||||||
|
"dayjs": ">= 1.10.0",
|
||||||
|
"luxon": ">= 1.26.0",
|
||||||
|
"moment": ">= 2.29.0",
|
||||||
|
"moment-timezone": ">= 0.5.33",
|
||||||
|
"rrule": ">= 2.6.8"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@touch4it/ical-timezones": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/luxon": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/mocha": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"dayjs": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"luxon": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"moment": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"moment-timezone": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"rrule": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mime-db": {
|
"node_modules/mime-db": {
|
||||||
"version": "1.52.0",
|
"version": "1.52.0",
|
||||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||||
@ -106,6 +158,11 @@
|
|||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
||||||
|
},
|
||||||
|
"node_modules/uuid-random": {
|
||||||
|
"version": "1.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid-random/-/uuid-random-1.3.2.tgz",
|
||||||
|
"integrity": "sha512-UOzej0Le/UgkbWEO8flm+0y+G+ljUon1QWTEZOq1rnMAsxo2+SckbiZdKzAHHlVh6gJqI1TjC/xwgR50MuCrBQ=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.4.0",
|
||||||
|
"ical-generator": "^4.1.0",
|
||||||
"moment": "^2.29.4"
|
"moment": "^2.29.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user