blah
This commit is contained in:
94
src/inc/events/message.js
Normal file
94
src/inc/events/message.js
Normal file
@ -0,0 +1,94 @@
|
||||
const safeEval = require('safe-eval');
|
||||
const util = require('util');
|
||||
const fs = require('fs');
|
||||
const ytdl = util.promisify(require('youtube-dl').getInfo);
|
||||
require('irc-colors').global();
|
||||
|
||||
module.exports = (lib) => {
|
||||
lib.events.on('message', function(msg) {
|
||||
if( msg.event[1] === 'privmsg' ) { // Triggerauswertung und blah
|
||||
//lib.rpc.emit('call', 'rizon', 'privmsg', [ '#f0ck', JSON.stringify(msg) ]);
|
||||
var e = lib.reply(msg);
|
||||
switch(e.message) {
|
||||
case "1":
|
||||
e.reply("normal");
|
||||
break;
|
||||
case "2":
|
||||
e.replyAction("action");
|
||||
break;
|
||||
case "3":
|
||||
e.replyNotice("notice");
|
||||
break;
|
||||
case "4":
|
||||
e.reply("Debugzeugs (lib.interfaces.rpc.sock) in die Konsole pfostiert.");
|
||||
console.log(lib.interfaces.rpc.sock);
|
||||
break;
|
||||
case "6":
|
||||
e.reply("\x02!kick kbotv3\x02");
|
||||
break;
|
||||
case "5":
|
||||
e.reply("!kick kbotv3");
|
||||
break;
|
||||
case "whois":
|
||||
lib.rpc.emit('call', e.network, 'raw', [ 'whois', e.user.nick ]);
|
||||
e.reply(`whois an ${e.user.nick} ist raus!`);
|
||||
break;
|
||||
default:
|
||||
if(e.user.nick === "Flummi" || e.user.nick === "jkhsjdhjs" || e.user.nick === "pFT" || 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,
|
||||
setInterval: setInterval,
|
||||
clearInterval: clearInterval
|
||||
}
|
||||
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"'
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if( msg.event === 'metadata' )
|
||||
console.log(msg);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function checkRepost(link) {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve( link );
|
||||
});
|
||||
}
|
9
src/inc/events/sync.js
Normal file
9
src/inc/events/sync.js
Normal file
@ -0,0 +1,9 @@
|
||||
module.exports = (lib) => {
|
||||
lib.events.on('message', function(msg) {
|
||||
if( msg.event == 'synchronize' ) {
|
||||
if( msg.keys.length == 0 )
|
||||
setTimeout(lib.loadIRC, 500);
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
11
src/inc/events/whois.js
Normal file
11
src/inc/events/whois.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = (lib) => {
|
||||
lib.events.on('message', function(msg) {
|
||||
if( msg.event[1] === 'whois' || (msg.event[1] === 'unknown' && msg.message.command === 'RPL_WHOISNICKSERVREG') ) {
|
||||
console.log(msg);
|
||||
}
|
||||
|
||||
if( msg.event[1] === 'who' ) {
|
||||
console.log(msg.message.who);
|
||||
}
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user