This is the module that you need to send rss news to a facebook page.
support for:
- Cron sintaxis to flexible time publishing.
- Filter function, to filter your content.
- Preprocess function to add extra data to meessages.
- Enabled link preview option.
- Flexible message template with handlebar.
Install
npm i rss-to-facebook
use
const rssToFacebook = require("rss-to-facebook");
const {
FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, FACEBOOK_PAGE_ACCES_TOKEN, FACEBOOK_PAGE_ID,
} = process.env;
rssToFacebook({
facebookAppID: FACEBOOK_APP_ID,
facebookAppSecret: FACEBOOK_APP_SECRET,
facebookPageAccesToken: FACEBOOK_PAGE_ACCES_TOKEN,
facebookPageID: FACEBOOK_PAGE_ID,
cron: "*/15 * * * * *",
timezone: "America/Havana",
source: "https://feed.informer.com/digests/ZO8A5LZCGA/feeder.rss",
preprocess: async (item) => {
item.color = "green";
return item;
},
template:
'Color is {{color}}, <a href="{{image}}"> </a> <b><a href="{{link}}">{{title}}</a></b>\n @{{channel}}',
filter: async ({ date }) => {
const d = new Date();
return (
date.getDate() === d.getDate() &&
date.getMonth() === d.getMonth() &&
date.getFullYear() === d.getFullYear()
);
},
extraFields: { colo: "red", line: "stroke" },
});
Cron sintaxis
# ┌────────────── second (optional)
# │ ┌──────────── minute
# │ │ ┌────────── hour
# │ │ │ ┌──────── day of month
# │ │ │ │ ┌────── month
# │ │ │ │ │ ┌──── day of week
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * *
- every five minutes.
0 */5 * * * *
- every quarter hour.
0 */15 * * * *
- every hour at minute 30.
0 30 * * * *
- three times every hour, at minute 0, 5 and 10
0 0,5,10 * * * *
- every half hour
0 */30 * * * *
More example https://crontab.guru/examples.html
Timezone
https://github.com/moment/moment-timezone/blob/develop/data/packed/latest.json
Template fields
- title
- link
- image
- channel
- description
- date
use the preprocess function to add fields, then modify the template to show the new fields in the message
rssToTelegram({
...
preprocess: async (item) => {
item.color = "green";
return item;
},
template: 'Color is {{color}}, Link is {{link}}, Title is {{title}} \n @{{channel}}',
...
})
Donate Bitcoin:
bitcoin:3GqQcxFk5y7onUyoTKqZHwoWXvLusqJSVG
3GqQcxFk5y7onUyoTKqZHwoWXvLusqJSVG
Contact: fabiel.leon.oliva@gmail.com