41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
import fs from "fs";
|
|
import ytdl from "ytdl-core";
|
|
|
|
const _args = [
|
|
"--no-progress",
|
|
"--no-warnings",
|
|
"--no-check-certificate",
|
|
"--dump-json"
|
|
//"--max-filesize 500m",
|
|
//'-o "./tmp/%(title)s.%(ext)s"'
|
|
];
|
|
|
|
|
|
export default bot => {
|
|
bot._trigger.set("parser", new bot.trigger({
|
|
call: /https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi,
|
|
active: false,
|
|
clients: ["irc"],
|
|
f: e => {
|
|
if(e.network === "n0xy" && e.channel === "#kbot-dev") {
|
|
const links = e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi);
|
|
Promise.all(links.map(link => checkRepost(link))) // repostcheck
|
|
.then(res => Promise.all(res.map(link => ytdl(link, _args)))) // info holen
|
|
.then(res => {
|
|
res.forEach(info => {
|
|
e.reply(info);
|
|
});
|
|
})
|
|
.catch(err => {
|
|
e.reply(err);
|
|
});
|
|
}
|
|
}
|
|
}));
|
|
};
|
|
|
|
function checkRepost(link) {
|
|
return new Promise((resolve, reject) => {
|
|
resolve(link);
|
|
});
|
|
} |