initial commit
This commit is contained in:
parent
b1abb60274
commit
27accb1184
7
.env.sample
Normal file
7
.env.sample
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Mastodon Info
|
||||||
|
MASTODON_ACCESS_KEY=
|
||||||
|
MASTODON_API_URL=
|
||||||
|
MASTODON_ACCOUNT_ID=
|
||||||
|
|
||||||
|
# Prefix for the post
|
||||||
|
POST_PREFIX=
|
32
bot.js
Normal file
32
bot.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
if (process.env.NODE_ENV !== "production") {
|
||||||
|
require("dotenv").config();
|
||||||
|
}
|
||||||
|
let Mastodon = require("mastodon-api");
|
||||||
|
let Parser = require("rss-parser");
|
||||||
|
let parser = new Parser();
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const M = new Mastodon({
|
||||||
|
access_token: `${process.env.MASTODON_ACCESS_KEY}`,
|
||||||
|
timeout_ms: 60 * 1000, // optional HTTP request timeout to apply to all requests.
|
||||||
|
api_url: `${process.env.MASTODON_API_URL}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
let feed = await parser.parseURL("http://feeds.feedburner.com/ign/games-all");
|
||||||
|
|
||||||
|
let timeline = await M.get(
|
||||||
|
`accounts/${process.env.MASTODON_ACCOUNT_ID}/statuses`,
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
var postDate = new Date(timeline.data[0].created_at);
|
||||||
|
|
||||||
|
feed.items.forEach((item) => {
|
||||||
|
let pubDate = new Date(item.pubDate);
|
||||||
|
|
||||||
|
if (pubDate > postDate) {
|
||||||
|
M.post("statuses", {
|
||||||
|
status: `#${process.env.POST_PREFIX}:\n\n${item.title}\n\n${item.link}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
3909
package-lock.json
generated
Normal file
3909
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
25
package.json
Normal file
25
package.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "neovibe-bots",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "NeoVibe bots",
|
||||||
|
"main": "bot.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/MikeHuntington/neovibe-bots.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/MikeHuntington/neovibe-bots/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/MikeHuntington/neovibe-bots#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
|
"mastodon-api": "^1.3.0",
|
||||||
|
"rss-parser": "^3.12.0",
|
||||||
|
"yaml": "^2.1.3"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user