.
This commit is contained in:
36
src/inc/trigger/parser.js
Normal file
36
src/inc/trigger/parser.js
Normal 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);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user