Skip to content

Commit a5a9595

Browse files
committed
feat: added support for facebook medias
1 parent 4a319a2 commit a5a9595

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

handlers/facebook.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
require('dotenv').config()
2-
3-
const facebookScrapper = () => {
4-
1+
const faceScrapper = async (bot, chatId, medias) => {
2+
try {
3+
await bot.sendMessage(chatId, 'Processing your link, please wait...')
4+
await bot.sendVideo(chatId, medias[0].url)
5+
} catch (error) {
6+
bot.sendMessage(chatId, `An error ocurred while processing the link. Try again!`)
7+
}
58
}
69

7-
module.exports = facebookScrapper
10+
module.exports = {
11+
linkPrefix: 'https://www.facebook.com/',
12+
handle: faceScrapper
13+
}

test/scrapper.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const options = {
1313
'X-RapidAPI-Host': APIHost
1414
},
1515
data: {
16-
url: 'https://br.pinterest.com/pin/58757970133022487/'
16+
url: 'https://www.facebook.com/reel/1273876849979229'
1717
}
1818
};
1919

2020
const runScrapper = async () => {
2121
try {
2222
const response = await axios.request(options);
23-
console.log(response.data.medias.reverse()[0]);
23+
console.log(response.data.medias);
2424
} catch (error) {
2525
console.error(error);
2626
}

0 commit comments

Comments
 (0)