2017-11-07 17:22:41 +00:00
|
|
|
import { cfg, read } from './inc/cfg.js';
|
2017-11-08 11:56:04 +00:00
|
|
|
import { wrapper } from './inc/wrapper.js';
|
|
|
|
//const TelegramBot = require('node-telegram-bot-api');
|
|
|
|
//const safeEval = require('safe-eval');
|
|
|
|
//const util = require('util');
|
|
|
|
//const fs = require('fs');
|
|
|
|
//const ytdl = util.promisify(require('youtube-dl').getInfo);
|
2017-11-07 17:22:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
read().then(() => {
|
2017-11-08 11:56:04 +00:00
|
|
|
let bot = new wrapper();
|
|
|
|
|
|
|
|
bot.on('message', msg => {
|
|
|
|
console.log( msg );
|
|
|
|
});
|
2017-11-07 17:22:41 +00:00
|
|
|
});
|
2017-11-08 11:56:04 +00:00
|
|
|
/*const lib = new (require(`${__dirname}/inc/lib`))(cfg);
|
|
|
|
lib.events.on('message', msg => {
|
|
|
|
if( msg.event[1] === "privmsg" ) {
|
|
|
|
const e = lib.reply( msg );
|
|
|
|
console.log( `IRC: (${e.time}) ${e.network} -> ${e.channel} -> ${e.user.nick}: ${e.message}` );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const bot = new TelegramBot("381368731:AAFalG-LknIbtBDuOvRXcxHUEK9Jg_o1UCw", { polling: true });
|
|
|
|
bot.on('message', (msg) => {
|
|
|
|
var e = lib.replytg(bot, msg);
|
|
|
|
console.log( `TG: (${e.time}) ${e.channel} -> ${e.user.nick}: ${e.message}` );
|
2017-11-07 17:22:41 +00:00
|
|
|
|
2017-11-08 11:56:04 +00:00
|
|
|
switch(e.message) {
|
|
|
|
case "1":
|
|
|
|
e.reply("normal");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//if(e.user.nick === "Flummi" || e.user.nick === "jkhsjdhjs" || e.user.nick === "Flummsi" || e.user.nick === "mrhanky" || e.user.nick === "gz") {
|
|
|
|
if(e.message.match(/^\.js /)) { // JS-Sandbox
|
|
|
|
let args = e.message.substring(3);
|
|
|
|
var context = {
|
|
|
|
e: e,
|
|
|
|
msg: msg
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
var output = safeEval(args, context);
|
|
|
|
if(typeof output !== undefined && output !== 'undefined' && output) {
|
|
|
|
let blah = JSON.stringify( output );
|
|
|
|
if(blah != "Converting circular structure to JSON")
|
|
|
|
e.reply( blah.length > 250 ? `holy fuck, Ausgabe wäre viel zu lang! (${blah.length} Zeichen :DDDDDD)` : blah );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(err) {
|
|
|
|
e.reply(err.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi)) { // parser
|
|
|
|
let links = e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi);
|
|
|
|
const args = [
|
|
|
|
//"-j",
|
|
|
|
//"-q",
|
|
|
|
"--no-progress",
|
|
|
|
"--no-warnings",
|
|
|
|
"--no-check-certificate",
|
|
|
|
"--max-filesize 500m",
|
|
|
|
'-o "./tmp/%(title)s.%(ext)s"'
|
|
|
|
];
|
2017-11-07 17:22:41 +00:00
|
|
|
|
2017-11-08 11:56:04 +00:00
|
|
|
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 );
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//}
|
|
|
|
break;
|
2017-11-07 17:22:41 +00:00
|
|
|
}
|
2017-11-08 11:56:04 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function checkRepost(link) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
resolve( link );
|
|
|
|
});
|
|
|
|
}*/
|