add link to youtube no-cookie and invidio
This commit is contained in:
parent
f0bd2e365a
commit
101b69666d
1 changed files with 11 additions and 1 deletions
|
@ -9,12 +9,22 @@ bot.global.text(/(https?:\/\/[^ ,\)"]*)/ig, (b) => {
|
||||||
if (!/(coa|pad)\.crapaud-fou\.org/.test(url)) {
|
if (!/(coa|pad)\.crapaud-fou\.org/.test(url)) {
|
||||||
request(url, (err, res, body) => {
|
request(url, (err, res, body) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
console.log(JSON.stringify(res.request.uri.href, null, 2));
|
||||||
var re = /<title[^>]*>([^<]*)<\/title>/gi;
|
var re = /<title[^>]*>([^<]*)<\/title>/gi;
|
||||||
var match = re.exec(body);
|
var match = re.exec(body);
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
// b.respondEnvelope({ attachments: [] })
|
// b.respondEnvelope({ attachments: [] })
|
||||||
// b.envelope.payload.quickReply({ attachments: [] });
|
// b.envelope.payload.quickReply({ attachments: [] });
|
||||||
b.respond("[:link:](" + url + ") _" + match[1] + "_");
|
var extra = "";
|
||||||
|
var link = res.request.uri.href;
|
||||||
|
if (/youtube.com/.test(res.request.uri.href)) {
|
||||||
|
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 += " - [invidio](https://invidio.us/watch?v=" + t[1] + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
b.respond("[:link:](" + url + ") _" + match[1] + "_" + extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue