From 72533f0c21e82f19d926a29aa88f7b6165290995 Mon Sep 17 00:00:00 2001 From: Gavin Isgar Date: Fri, 20 Jul 2018 18:49:41 -0400 Subject: [PATCH 1/3] Improve topic detection system and add server-side commands Improved topic detection system and added server-side commands for host. --- main.js | 74 +++++++++++++++++++++++++++++++++++++---------- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 60 insertions(+), 18 deletions(-) diff --git a/main.js b/main.js index aaa190f..21e2869 100644 --- a/main.js +++ b/main.js @@ -15,6 +15,7 @@ var request = require("request"); var commands = require("./commands.json"); var tokens = require("./exclude/tokens.json"); var fs = require("fs"); +const readline = require("readline"); const package = require("./package.json"); const { app, BrowserWindow } = require('electron'); var date = new Date(); @@ -22,24 +23,9 @@ var date = new Date(); // -----CHANNELS----- var logChannel = "423939166401855518"; var newcomerChannel = "423937750937501697"; +var mainChannel = "443227379712917505"; // ---------- -function createWindow() { - var win = new BrowserWindow({ width: 1300, height: 800, frame: false }) - win.on('closed', () => { - win = null - }) - win.show(); - win.setTitle("ratzBot Server"); - win.loadURL(url.format({ - pathname: path.join(__dirname, "main.html"), - protocol: "file", - slashes: true - })) -} - -app.on(`ready`, createWindow); - bot.on('message', (message) => { try { if (fs.readFileSync("./exclude/bannedusers.ratz").includes(message.author.id.toString()) == true) { @@ -388,6 +374,11 @@ bot.on('message', (message) => { message.channel.send(`${message.author}, your message was deleted because it possibly relates to a blocked topic. To appeal the deletion of your message, contact an administrator.`); } } + if (message.content.includes("NIGGER") || message.content.includes("nigger") || message.content.includes("NIGGA") || message.content.includes("nigga")) { + fs.appendFileSync("./exclude/bannedmessages.ratz", `\r\n(${message.author.username} [${message.author.id}], ${message.createdTimestamp}) ${message.content.toString()}`); + message.delete(); + message.channel.send(`${message.author}, your message was deleted because it possibly relates to a blocked topic. To appeal the deletion of your message, contact an administrator.`); + } } } } @@ -409,5 +400,56 @@ bot.on("error", (error) => { fs.appendFileSync("./exclude/errors.ratz", `\r\nERROR at ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()} ${date.getMonth()}/${date.getDate()}/${date.getFullYear()}: ${error.name} | ${error.message}\n`); }) +bot.on("disconnect", (userconnection) => { + try { + bot.login(tokens.bottoken); + } + catch (err) { + console.log(`**RECON. ERROR**: ${err}`); + } +}) + +// -----READLINE----- +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +rl.on("line", (input) => { + if (input.toString().startsWith("/ratz userban ")) { + var result = input.slice(14); + try { + bot.guilds.forEach(function (getGuilds) { + if (getGuilds.name == "ratzcord") { + getGuilds.members.forEach(function (getMembers) { + if (getMembers.id == `${result}`) { + getMembers.ban("Banned by ratzBot system."); + console.log(`**BAN**: User ${result} was successfully banned.`); + } + else { + // Do nothing + } + }) + } + else { + // Do nothing + } + }) + } + catch (err) { + console.log(`**ERROR**: ${err}`); + } + } + if (input.toString().startsWith("/ratz writemain ")) { + var result = input.slice(16); + try { + bot.channels.get(mainChannel).send(`${result}`); + } + catch (err) { + console.log(`**ERROR**: ${err}`); + } + } +}) + bot.login(tokens.bottoken); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 03f96a5..e76a9f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ratzbot", - "version": "2.6.0", + "version": "2.7.0-RC", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 147d842..0f9e18b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ratzbot", - "version": "2.6.0", + "version": "2.7.0-RC", "description": "Discord bot for Twitch streamer ratzDoll", "main": "main.js", "scripts": { From 4803c58293b3c55749fae520a5f0689bb142c394 Mon Sep 17 00:00:00 2001 From: Gavin Isgar Date: Fri, 20 Jul 2018 19:29:53 -0400 Subject: [PATCH 2/3] Add event commands Added event commands for upcoming events. --- commands.json | 8 ++++++-- main.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/commands.json b/commands.json index defab96..52ed098 100644 --- a/commands.json +++ b/commands.json @@ -12,7 +12,9 @@ "/ratz ratcoininfo + Twitch Username", "/ratz laststream", "/ratz gituserinfo + GitHub Username", - "/ratz gitrepoinfo + {GitHubUsername}/{RepositoryName}" + "/ratz gitrepoinfo + {GitHubUsername}/{RepositoryName}", + "/ratz showactiveevent", + "/ratz joinactiveevent" ], "definitions": [ "Shows all commands for ratzBot", @@ -27,6 +29,8 @@ "Shows the amount of RTC a user has on Twitch", "Shows last stream VOD and VOD information", "Shows information for provided GitHub user", - "Show information for provided GitHub repository (which is owned by the provided GitHub username)" + "Show information for provided GitHub repository (which is owned by the provided GitHub username)", + "Shows active server event", + "Join active server event" ] } \ No newline at end of file diff --git a/main.js b/main.js index 21e2869..4e6aa4a 100644 --- a/main.js +++ b/main.js @@ -20,6 +20,10 @@ const package = require("./package.json"); const { app, BrowserWindow } = require('electron'); var date = new Date(); +//-----SERVER EVENTS----- +var activeevent = ""; +// --------- + // -----CHANNELS----- var logChannel = "423939166401855518"; var newcomerChannel = "423937750937501697"; @@ -271,6 +275,29 @@ bot.on('message', (message) => { } }) } + // -----SERVER EVENTS----- + if (message.content.toString() == "/ratz joinactiveevent") { + if (activeevent == "") { + message.channel.send(`${message.author}, there is no active event on the server.`); + } + else { + try { + fs.appendFileSync("./exclude/eventuserlist.ratz", `\r\n${message.author.id}`); + message.channel.send(`${message.author}, you are now joined into the ${activeevent}!`); + } + catch (err) { + message.channel.send(`${message.author}, an error occured during the process. Try again later.`); + } + } + } + if (message.content.toString() == "/ratz showactiveevent") { + if (activeevent == "") { + message.channel.send(`${message.author}, there is no active event on the server.`); + } + else { + message.channel.send(`${message.author}, the active event on the server is the ${activeevent}.`); + } + } // -----STREAMLABS INTEGRATION----- if (message.content.startsWith("/ratz ratcoininfo ")) { var result = message.content.slice(18); @@ -449,6 +476,12 @@ rl.on("line", (input) => { console.log(`**ERROR**: ${err}`); } } + // -----SERVER EVENTS----- + if (input.toString().startsWith("/ratz setevent ")) { + var result = input.slice(15); + activeevent = result; + console.log(`**EVENT**: Event has been set.`); + } }) From 30e5ff2e611ff78b10f79c991105fd31e44bbcff Mon Sep 17 00:00:00 2001 From: Gavin Isgar Date: Sun, 22 Jul 2018 20:12:13 -0400 Subject: [PATCH 3/3] Change versioning for v2.7.0 release Changed versioning number for v2.7.0 release. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index e76a9f5..e26acd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ratzbot", - "version": "2.7.0-RC", + "version": "2.7.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0f9e18b..d2f1cd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ratzbot", - "version": "2.7.0-RC", + "version": "2.7.0", "description": "Discord bot for Twitch streamer ratzDoll", "main": "main.js", "scripts": {