meh
This commit is contained in:
		@@ -1,30 +1,35 @@
 | 
			
		||||
const util = require('util')
 | 
			
		||||
  , fs = require('fs')
 | 
			
		||||
  , ytdl = util.promisify(require('youtube-dl').getInfo);
 | 
			
		||||
const util = require("util")
 | 
			
		||||
  , fs = require("fs")
 | 
			
		||||
  , ytdl = require("youtube-dl");
 | 
			
		||||
 | 
			
		||||
const args = [
 | 
			
		||||
const _args = [
 | 
			
		||||
  "--no-progress",
 | 
			
		||||
  "--no-warnings",
 | 
			
		||||
  "--no-check-certificate",
 | 
			
		||||
  "--max-filesize 500m",
 | 
			
		||||
  //"--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: false,
 | 
			
		||||
    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);
 | 
			
		||||
      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_info(link, _args)))) // info holen
 | 
			
		||||
          .then(
 | 
			
		||||
            res => Promise.all(res.map(t => { e.reply(t.res); return t.link; })),
 | 
			
		||||
            err => Promise.all(err.map(t => { e.reply(t.err); return t.link; }))
 | 
			
		||||
          )
 | 
			
		||||
          .then(link => {
 | 
			
		||||
            e.reply(`link: ${link}`);
 | 
			
		||||
          });
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
@@ -33,4 +38,13 @@ function checkRepost(link) {
 | 
			
		||||
  return new Promise((resolve, reject) => {
 | 
			
		||||
    resolve(link);
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function ytdl_info(link, args) {
 | 
			
		||||
  return new Promise((resolve, reject) => {
 | 
			
		||||
    ytdl.getInfo(link, args, (err, res) => {
 | 
			
		||||
      if(err) reject({ link: link, err: err });
 | 
			
		||||
      if(res) resolve({ link: link, res: res });
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user