This commit is contained in:
Flummi
2017-11-26 13:51:08 +01:00
parent 6f8145c5aa
commit fdafc44044
6 changed files with 54 additions and 26 deletions

View File

@ -2,8 +2,9 @@ import { logger } from "../log.js";
import { getLevel } from "../admin.js";
const colors = {
red: "\x0304$1\x0F",
blue: "\x0312$1\x0F"
red: "\x0304$1\x0304",
blue: "\x0312$1\x0312",
yellow: "\x0308$1\x0308"
};
const replaceColor = (match, color, text) => {
@ -159,8 +160,8 @@ export class irc {
}
format(msg) {
return msg
.replace(/\[b\](.*?)\[\/b\]/g, "\x02$1\x0F") // bold
.replace(/\[i\](.*?)\[\/i\]/g, "\x1D$1\x0F") // italic
.replace(/\[b\](.*?)\[\/b\]/g, "\x02$1\x02") // bold
.replace(/\[i\](.*?)\[\/i\]/g, "\x1D$1\x1D") // italic
.replace(/\[color=(.*?)](.*?)\[\/color\]/g, replaceColor) // colors
;
}

View File

@ -53,6 +53,11 @@ export class tg {
account: tmp.from.id.toString()
})
},
self: {
me: {
nickname: "Uwe"
}
},
message: tmp.text,
time: tmp.date,
raw: tmp,

View File

@ -1,13 +1,13 @@
const util = require("util")
, fs = require("fs")
, ytdl = require("youtube-dl");
const fs = require("fs")
, ytdl = require("ytdl-core");
const _args = [
"--no-progress",
"--no-warnings",
"--no-check-certificate",
"--dump-json"
//"--max-filesize 500m",
'-o "./tmp/%(title)s.%(ext)s"'
//'-o "./tmp/%(title)s.%(ext)s"'
];
@ -21,13 +21,14 @@ module.exports = bot => {
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}`);
.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);
});
}
}
@ -38,13 +39,4 @@ 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 });
});
});
}

View File

@ -146,7 +146,7 @@ module.exports = bot => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.reply(`Assuming [b]${args[0]}'s[/b] gender... they're a ${data.genders[~~(Math.random() * data.genders.length)]}.`);
e.reply(`Assuming [b]${args[0]}'s[/b] gender... it's a ${data.genders[~~(Math.random() * data.genders.length)]}.`);
}
});