diff --git a/src/url_metadata.js b/src/url_metadata.js index 53dff50..65faf34 100644 --- a/src/url_metadata.js +++ b/src/url_metadata.js @@ -7,10 +7,14 @@ var request_options = { } }; -bot.global.text(/(https?:\/\/[^ ,\)"\n]*)/ig, (b) => { - // console.log(JSON.stringify(b.envelope.payload, null, 2)); + + +bot.global.text(/(https?:\/\/[^ ,\)"\n]*)/ig, async (b) => { + // console.log(JSON.stringify(b.match, null, 2)); for (url of b.match) { - // console.log(JSON.stringify(url, null, 2)); + console.log('-----------------------------------'); + console.log(JSON.stringify(url, null, 2)); + console.log('-----------------------------------'); if (!/(coa|pad)\.crapaud-fou\.org/.test(url)) { request_options.url = url; request(request_options, (err, res, body) => { @@ -28,6 +32,9 @@ bot.global.text(/(https?:\/\/[^ ,\)"\n]*)/ig, (b) => { extra += " - [invidious](https://invidio.us/watch?v=" + t[1] + ")"; } } + console.log('-----------------------------------'); + console.log(JSON.stringify(link, null, 2)); + console.log('-----------------------------------'); b.respond("[>>>](" + link + ") _" + match[1].replace(/\n/g, " ") + "_" + extra); } } else { @@ -41,6 +48,7 @@ bot.global.text(/(https?:\/\/[^ ,\)"\n]*)/ig, (b) => { } }); } + await new Promise((resolve) => setTimeout(resolve, 1000)); } }, { id: 'get-url-metadata'