multi-account-post-schedule.../helpers/afis_science.mjs

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-03-03 12:22:55 +01:00
2023-03-03 15:19:09 +01:00
import sendPostMastodon, {
getArticlesFromDaysInRssFeed,
makeTitleContentFromRss,
parseRssFeed,
} from "./utils.mjs";
2023-03-03 14:08:18 +01:00
2023-03-03 15:19:09 +01:00
const afis_rss_feed_url = 'https://afis.org/rss.xml';
const days_back_in_rss_feed = 7;
2023-03-03 14:08:18 +01:00
2023-03-03 15:19:09 +01:00
async function postLink() {
2023-03-03 14:08:18 +01:00
2023-03-03 17:28:41 +01:00
console.log("envoi de post des articles afis sciences publiés depuis " + days_back_in_rss_feed + " jours par le compte afis91")
2023-03-03 12:22:55 +01:00
2023-03-03 15:19:09 +01:00
let parsedFeed = await parseRssFeed(afis_rss_feed_url)
let articles = await getArticlesFromDaysInRssFeed(parsedFeed, days_back_in_rss_feed)
console.log('articles', articles)
let contentOfPost = 'Articles des ' + days_back_in_rss_feed + ' derniers jours sur le site web de l\'AFIS: \n'
+ makeTitleContentFromRss(articles)
2023-03-03 12:22:55 +01:00
let configPost = {
author: 'afis91',
website: 'afis.org',
2023-03-03 15:19:09 +01:00
// disable_slugify: true,
slug: "afis_picture",
content_type: "text/markdown",
folder_image: process.cwd() + '/assets/',
image: "afis_picture_of_the_day.jpg",
2023-03-03 12:22:55 +01:00
message: `# ${contentOfPost}
2023-03-03 15:19:09 +01:00
#afis #science #pseudoScience #hebdo`,
2023-03-03 12:22:55 +01:00
}
2023-03-03 15:19:09 +01:00
sendPostMastodon(configPost)
2023-03-03 12:22:55 +01:00
}
postLink();