adding title

This commit is contained in:
Michael (GP) 2022-12-14 16:07:25 -05:00
parent 999d7e27b7
commit 1916ac93e7

25
bot.js
View File

@ -46,6 +46,7 @@ const download_image = async (url, image_path) => {
})(); })();
async function getLastPostDate() { async function getLastPostDate() {
console.log("Getting Last Post Date: getLastPostDate()");
let timeline = await M.get( let timeline = await M.get(
`accounts/${process.env.MASTODON_ACCOUNT_ID}/statuses`, `accounts/${process.env.MASTODON_ACCOUNT_ID}/statuses`,
{} {}
@ -87,20 +88,24 @@ async function processFeed(feed, postDate) {
); );
await download_image(metadata.image, path); await download_image(metadata.image, path);
let mediaup = await M.post("media", { return postFeedItem(path, item);
file: fs.createReadStream(path),
});
return M.post("statuses", {
status: `${
item.contentSnippet ? item.contentSnippet : item.title
}\n\n#NeoVibe #${process.env.POST_HASHTAG}\n\n${item.link}`,
media_ids: [mediaup.data.id],
});
}) })
); );
} }
async function postFeedItem(path, item) {
let mediaup = await M.post("media", {
file: fs.createReadStream(path),
});
return M.post("statuses", {
status: `${item.title}\n\n${
item.contentSnippet ? "\n\n" + item.contentSnippet : ""
}\n\n#NeoVibe #${process.env.POST_HASHTAG}\n\n${item.link}`,
media_ids: [mediaup.data.id],
});
}
async function runBot() { async function runBot() {
console.log("Running Bot: runBot()"); console.log("Running Bot: runBot()");