This commit is contained in:
Edgar 2021-11-04 11:17:52 +00:00
parent 82da139825
commit 1acc1596db
4 changed files with 158 additions and 21 deletions

3
.gitignore vendored
View File

@ -133,3 +133,6 @@ dist
.svelte-kit
# End of https://www.toptal.com/developers/gitignore/api/node
config.json

66
bot.js
View File

@ -1,13 +1,69 @@
// https://api.fynn.ai/events
// https://vps.anotherfoxguy.com/dl/fur-events.json
const axios = require('axios').default;
const axios = require("axios").default;
const moment = require("moment");
const config = require("./config.json");
async function main(){
let dat = await axios.get("https://vps.anotherfoxguy.com/dl/fur-events.json")
async function main() {
// let data = (await axios("https://vps.anotherfoxguy.com/dl/fur-events.json")).data;
let data = (await axios("https://api.fynn.ai/events")).data;
console.log(dat)
let currdate = moment();
let min = moment().subtract(15, "minutes"); // minutes
let max = moment().add(15, "minutes");
//console.log(dat.data)
const events = data.filter((event) =>
moment.unix(event.start).isBetween(min, max)
);
events.forEach((event) => {
// console.log(moment.unix(event.start).isBetween(min, max))
// let startTime = moment.unix(event.start)
// let endTime = moment.unix(event.end)
// let duration = moment.duration(endTime.diff(startTime))
console.log(event.name);
let message = `${event.name} will start in <t:${event.start}:R>`; // <t:1636124400:R>
// axios
// .post(config.webhookurl, {
// content: message
// })
// .catch(function (error) {
// console.error(error);
// });
});
let event = data[1];
let embed = {
title: event.name, //`${event.name} will start in <t:${event.start}:R>`,// <t:1636124400:R>
description: event.description,
timestamp: moment.unix(event.start),
url: `https://furality.org/schedule#${event.id}`
};
if (event.image_url != "missing") {
embed.thumbnail = {
url: `https://furality.org/${event.image_url}`,
}
}
// axios
// .post(config.webhookurl, {
// embeds: [embed]
// })
// .catch(function (error) {
// console.error(error);
// });
console.log(
JSON.stringify({
embeds: [embed],
})
);
}
main()
main();

106
package-lock.json generated
View File

@ -1,19 +1,95 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"axios": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
"integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
"requires": {
"follow-redirects": "^1.14.4"
}
"name": "furality-discord-bot",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"axios": "^0.24.0",
"moment": "^2.29.1",
"turndown": "^7.1.1"
}
},
"node_modules/axios": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
"integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
"dependencies": {
"follow-redirects": "^1.14.4"
}
},
"node_modules/domino": {
"version": "2.1.6",
"resolved": "https://registry.npmjs.org/domino/-/domino-2.1.6.tgz",
"integrity": "sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ=="
},
"node_modules/follow-redirects": {
"version": "1.14.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz",
"integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
"engines": {
"node": "*"
}
},
"node_modules/turndown": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/turndown/-/turndown-7.1.1.tgz",
"integrity": "sha512-BEkXaWH7Wh7e9bd2QumhfAXk5g34+6QUmmWx+0q6ThaVOLuLUqsnkq35HQ5SBHSaxjSfSM7US5o4lhJNH7B9MA==",
"dependencies": {
"domino": "^2.1.6"
}
}
},
"follow-redirects": {
"version": "1.14.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz",
"integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA=="
"dependencies": {
"axios": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
"integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
"requires": {
"follow-redirects": "^1.14.4"
}
},
"domino": {
"version": "2.1.6",
"resolved": "https://registry.npmjs.org/domino/-/domino-2.1.6.tgz",
"integrity": "sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ=="
},
"follow-redirects": {
"version": "1.14.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz",
"integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA=="
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"turndown": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/turndown/-/turndown-7.1.1.tgz",
"integrity": "sha512-BEkXaWH7Wh7e9bd2QumhfAXk5g34+6QUmmWx+0q6ThaVOLuLUqsnkq35HQ5SBHSaxjSfSM7US5o4lhJNH7B9MA==",
"requires": {
"domino": "^2.1.6"
}
}
}
}
}

View File

@ -1,5 +1,7 @@
{
"dependencies": {
"axios": "^0.24.0"
"axios": "^0.24.0",
"moment": "^2.29.1",
"turndown": "^7.1.1"
}
}