This commit is contained in:
Flummi
2017-11-20 19:43:17 +01:00
parent 0d3d5f7c8a
commit 88039bbe05
5 changed files with 36 additions and 118 deletions

36
src/inc/trigger/parser.js Normal file
View File

@ -0,0 +1,36 @@
const util = require('util')
, fs = require('fs')
, ytdl = util.promisify(require('youtube-dl').getInfo);
const args = [
"--no-progress",
"--no-warnings",
"--no-check-certificate",
"--max-filesize 500m",
'-o "./tmp/%(title)s.%(ext)s"'
];
module.exports = bot => {
bot._trigger.set("parser", {
call: /https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi,
level: 0,
active: true,
clients: ["irc"],
f: e => {
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)))) // get informations
.then(res => {
res.forEach(data => {
e.reply(data.title);
});
});
}
});
};
function checkRepost(link) {
return new Promise((resolve, reject) => {
resolve(link);
});
}