From 2c3b284e37601f1015e05e78daf017fdb5c2bbf9 Mon Sep 17 00:00:00 2001 From: Flummi Date: Thu, 20 Jul 2023 12:48:19 +0000 Subject: [PATCH] cleanup --- chatCommands.js | 24 -------------------- index.js | 60 +++++-------------------------------------------- 2 files changed, 5 insertions(+), 79 deletions(-) diff --git a/chatCommands.js b/chatCommands.js index 31751c6..e8d0993 100644 --- a/chatCommands.js +++ b/chatCommands.js @@ -22,7 +22,6 @@ const alphanoise = [8,20,10,14,12,11,26,16,4,21,22,13,24,6,5,15,2,23,7,19,18,25, p.run = function (o) { let client = this.irc.client; let db = this.db; - //let level = client.chans[o.to] ? client.chans[o.to].users[o.from] : undefined; let level = client.chans["#w0bm"] ? client.chans["#w0bm"].users[o.from] : undefined; level = level !== undefined ? level.split("").map(x=>userLevels.indexOf(x)).sort().pop() : -1; if (level === null || level === undefined) level = -1; @@ -65,11 +64,6 @@ p.run = function (o) { client.say(o.to, "User limit reached"); return true; case ".status": - /*if (level < getLevel("admin")) { - client.say(o.to, o.from + ": dein level: " + userLevelNames[level] + ", benötigtes level: admin"); - return true; - }*/ - db.getConnection((err, con) => { if (err) { client.say(o.to, "sorry.. datenbank is kapott D: nixc jkhsjdhjs Flummi"); @@ -101,24 +95,6 @@ p.run = function (o) { if (row.deleted_at) stati.push("gelöscht seit: " + row.deleted_at); client.say(o.to, (o.args || o.from) + " ist: " + stati.join(", ")); - /*var vid = rows[0]; - if (!vid.id) { - 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"); - ["interpret", "songtitle", "category", "username", "comments"].forEach((v, i) => { - if (vid[v]) { - txt.push( - ["Interpret", "Titel", "Kategorie", "Uploader", "Kommentare"][i] + ": " - +"\x02" + vid[v] + "\x0f"); - } - }); - - client.say(to, txt.join(" | "));*/ con.release(); }); }); diff --git a/index.js b/index.js index a3b859b..e6fc7a1 100755 --- a/index.js +++ b/index.js @@ -17,38 +17,16 @@ let db = Mysql.createPool({ 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(config.servers.n0xy.host, config.servers.n0xy.nick, { - // channels: ["#gz", "#w0bm"], port: config.servers.n0xy.port, secure: config.servers.n0xy.secure, - retryCount: 12000, - retryDelay: 3000, userName: config.servers.n0xy.userName, realName: config.servers.n0xy.realName, sasl: config.servers.n0xy.sasl, debug: false, debugRaw: false, selfSigned: false, - autoConnect: false, + autoConnect: true, password: config.servers.n0xy.srvPassword, channels: ["#w0bm", "#f0ck"] }); @@ -63,13 +41,9 @@ if (process.env.NODE_ENV != 'production') { Object.defineProperty(repl.context, "q", {get:process.exit}); } -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 w0bmregex = /(?:[^\/]|^|\/\/)(?:b\.)?w0bm\.com\/(?:\w+\/){0,3}([^ '\/@`´]+\.(webm)|\d+)/i; const w0bmregex = /(?:\b(\w+)\.)?\bw0bm\.com\/(?:\w+\/){0,3}([^ '\/@`´]+\.(webm)|\d+)/i; const capsmsg = [ "Captain capslock did not approve this!", @@ -83,28 +57,8 @@ const capsmsg = [ 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"); @@ -123,25 +77,21 @@ irc.client.addListener("message", (from, to, message, raw) => { cmd: cmd, args: args })) { - //console.log("cmd:", cmd, "arg:", arg); + if (client.opt.debug) + console.log("cmd:", cmd, "arg:", args); 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) { + 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);