const bot = require('bbot'); const request = require('request'); bot.global.text(/(https?:\/\/[^ ,\)"]*)/ig, (b) => { // console.log(JSON.stringify(b.envelope.payload, null, 2)); for (url of b.match) { // console.log(JSON.stringify(url, null, 2)); if (!/(coa|pad)\.crapaud-fou\.org/.test(url)) { request(url, (err, res, body) => { if (!err) { // console.log(JSON.stringify(res.request.uri.href, null, 2)); var re = /]*>([^<]*)<\/title>/gi; var match = re.exec(body); if (match && match[1]) { var extra = ""; var link = res.request.uri.href; if (/youtube.com/.test(link)) { if (t = /[?&]v=([^&]+)/.exec(link)) { link = "https://www.youtube.com/watch?v=" + t[1]; extra += " - [no-cookie](https://www.youtube-nocookie.com/embed/" + t[1] + ")"; extra += " - [invidious](https://invidio.us/watch?v=" + t[1] + ")"; } } b.respond("[:link:](" + link + ") _" + match[1] + "_" + extra); } } }); } } }, { id: 'get-url-metadata' });