"use strict"; const Raven = require('raven'); Raven.config('https://10749fc75fc14fc5aa6b6212adbfe9ec:c291a65aa6014bb781232e0995f7a81d@sentry.njgz.de/4').install(); const Irc = require("irc"); const Mysql = require("mysql"); require('dotenv').config({path: '/var/www/w0bm.com/.env'}); let db = Mysql.createPool({ host: process.env.DB_HOST, user: process.env.DB_USERNAME, password: process.env.DB_PASSWORD, database: process.env.DB_DATABASE, timezone: "utc" }); let irc = {}; /*Irc.Client.prototype._connectionHandler = function() { if (this.opt.webirc.ip && this.opt.webirc.pass && this.opt.webirc.host) { this.send('WEBIRC', this.opt.webirc.pass, this.opt.userName, this.opt.webirc.host, this.opt.webirc.ip); } if (this.opt.password) { this.send('PASS', this.opt.password); } if (this.opt.debug) console.log('Sending irc NICK/USER'); this.send('NICK', this.opt.nick); this.nick = this.opt.nick; this._updateMaxLineLength(); this.send('USER', this.opt.userName, 'realnetzprotokolladresse.w0bm.com', 'realnetzprotokolladresse.w0bm.com', this.opt.realName); this.emit('connect'); };*/ //irc.client = new Irc.Client('irc.rizon.so', 'w0bm', { //irc.client = new Irc.Client('irc.n0xy.net', 'w0bm', { irc.client = new Irc.Client('znc.gottz.de', 'w0bm', { // channels: ["#gz", "#w0bm"], port: 6667, secure: false, retryCount: 12000, retryDelay: 3000, userName: "Abdullah", realName: "Fritz", debug: false, selfSigned: false, debugRaw: false, autoConnect: false, password: "w0bm/n0xy:Roquaib7jae9miey3aey" }); const repl = require("repl").start("> "); repl.context.i = irc; repl.context.c = irc.client; repl.context.w = (msg) => irc.client.say("#w0bm", msg); repl.context.s = (cmd, msg) => irc.client.send(cmd, msg); Object.defineProperty(repl.context, "q", {get:process.exit}); let needJoin = false; irc.client.addListener("registered", () => { console.log("registered…"); const c = irc.client; //c.say("NickServ", "IDENTIFY dI0k2k7PH"); //c.say("NickServ", "IDENTIFY jae2Loax"); //c.say("HostServ", "ON"); //needJoin = true; }); irc.client.addListener("notice", (from, to, text) => { if (needJoin && from == "NickServ" && text.indexOf("Password accepted") != -1) { needJoin = false; const c = irc.client; //c.join("#w0bm"); //c.join("#gz"); } }); process.nextTick(()=>irc.client.connect()); const handleChatCommands = require("./chatCommands")(irc, db); const shiftRegex = /^(\.?\w+:?)\s+(.+)/; const w0bmregex = /(?:[^\/]|^|\/\/)w0bm\.com\/(?:\w+\/){0,3}([^ '\/@`´]+\.(webm)|\d+)/i; const capsmsg = [ "Captain capslock did not approve this!", "CAPS", "caps lock. unleash the mother fucking fury", "DON'T YOU TYPE AT ME IN THAT TONE OF VOICE.", "Suddenly, CAPS LOCK", "OH, so you wanna argue? BRING IT. I got my CAPS LOCK ON", "WELCOME TO THE INTERNET" ]; irc.client.addListener("error", message => console.log("error: ", message)); irc.client.on("raw", raw => { if (irc.client.opt.debugRaw) console.log(raw); /*if (raw.command == "rpl_whoischannels") { let chan = raw.args[2].split(" ").filter(c => /#w0bm$/.test(c)); if (!chan || !chan[0] || chan[0].split("#")) return; let mode = chan[0].split("#")[0]; irc.client.chans["#w0bm"].users[raw.args[1]] = mode; }*/ }); /*irc.client.on("-mode", (chan, nick, mode, user, message) => { if (typeof user != "undefined") irc.client.send("WHOIS", user); }) irc.client.on("+mode", (chan, nick, mode, user, message) => { if (typeof user != "undefined") irc.client.send("WHOIS", user); })*/ irc.client.addListener("message", (from, to, message, raw) => { const client = irc.client; // if (client.opt.debug) console.log("raw:", raw); let pm; if (pm = !/^#/.test(to)) { if (client.opt.debug) console.log("setting to from:", to, "to:", from, "cause its a PM"); to = from; } if (client.opt.debug) console.log("from:", from, "to:", to, "message:", message); if (shiftRegex.test(message)) { let cmd = message.match(shiftRegex); let args = cmd[2].trim(); cmd = cmd[1]; if (handleChatCommands({ from: from, to: to, message: message, cmd: cmd, args: args })) { //console.log("cmd:", cmd, "arg:", arg); return; } } /*if (/w0bm\.com\/\d+/.test(message)) { client.say(to, "durch Aufruf des Links: "+(message.match(/(w0bm\.com\/\d+)/)[0])+" machen Sie sich strafbar!"); return; }*/ if (/pr0gramm\.com/.test(message) && to == "#w0bm") { client.say(to, pr0text[Math.random()*pr0text.length|0]); return; } /* if (message.toUpperCase() == message && message.trim().split("").filter(c=>/[A-Z]/.test(c)).length > 5) { client.say(to, capsmsg[Math.random()*capsmsg.length|0]); } */ if (w0bmregex.test(message)) { var link = message.match(w0bmregex); if (link) { var id = link[1]; if (id.length > 20) { client.say(to, "fuck you"); return; } var webm = link[2]; db.getConnection((err, con) => { if (err) { client.say(to, "sorry.. there seems to be a database problem right now D:"); con.release(); return; } con.query( "select v.id, v.deleted_at, u.username, c.name as category, v.interpret, v.songtitle, v.imgsource,"+ " (select 1 from taggable_taggables t where t.taggable_id = v.id and t.tag_id = 1) as sfw,"+ " (select count(cm.id) from comments cm where cm.video_id = v.id and cm.deleted_at is NULL) as comments"+ " from videos v, users u, categories c where v.user_id = u.id and v.category_id = c.id"+ " and " + (webm ? "v.file" : "v.id") + " = '" + id + "'", (err, rows, fields) => { if (err) { client.say(to, "sorry.. there seems to be an sql query problem D:"); client.say(to, "" + err); con.release(); return; } var vid = rows[0]; if (!vid) { client.say(to, from + ": konnte kein video finden D:"); con.release(); return; } var txt = []; if (vid.deleted_at) txt.push("\x02gelöscht\x0f"); if (webm) txt.push("Link: \x02https://w0bm.com/" + vid.id + "\x0f"); txt.push(vid["sfw"] ? "\x039SFW\x0f" : "\x034NSFW\x0f"); ["interpret", "songtitle", "category", "username", "comments"].forEach((v, i) => { if (vid[v]) { txt.push( ["Artist", "Title", "Category", "Uploader", "Comments"][i] + ": " +"\x02" + vid[v] + "\x0f" ); } }); client.say(to, txt.join(" | ")); con.release(); }); }); return; } } if (~haitext.indexOf(message.toLowerCase())) { client.say(to, haitext[Math.random()*haitext.length|0] + " " + from + "!"); return; } if (/^!d$/.test(message)) { client.say(to, from + ": the magic dice shows " + ((Math.random()*6|0)+1) + " eyes."); } if (/^a+[yi][yiou]*$/.test(message)) { client.say(to, "ayy lmao"); return; } if (/.+\?\?$/.test(message)) { let ye = Math.random() * 2 | 0; client.say(to, "[" + (ye?"x":" ") + "] ja [" + (ye?" ":"x") + "] nein | " + message); return; } if (~[".guuchan", ".vizon", ".lottery"].indexOf(message)) { let values = new Array(29).fill().map((v,i)=>1+i); let choices = new Array(6).fill().map(()=>values.splice(Math.random()*values.length|0,1)).sort((x,y)=>x-y).join(" "); client.say(to, "/notice guuchan !bet " + choices); return; } }); const haitext = ["ohaio", "ohayou", "ohayo", "ohaiou", "ohai", "nabend", "morgen", "guten tag", "hallo", "hi", "hai", "hey", "moin", "hellau", "hello", "hallu", "yo", "servus", "tag", "tach", "alaaf", "alaf", "As-Salamu 'alaikum wa Rahmatullahi wa Barakatuhu"]; const pr0text = [ "pr0gramm.com existiert nicht!", "endlich oc von deiner fotze?", "Pfui Daibel", "kommandozeile war vorher da", "keiner von uns", "Falsches Grau", "das reicht uns nicht", "Zapalot nochmal!", "meinten sie reddit, 9gag oder fagbook?", "lustig weil pr0gramm", "lustig weil fett", "marina die huuure", "har har har kefer", "Ach du scheiße. Da drückste Minus.", "0815 wie fick", "stumpf ist trumpf", "f man weiß ja nie", "lass das nicht die repost polizei sehen!" ];