Skip to content

Commit

Permalink
Improve topic detection system and add server-side commands
Browse files Browse the repository at this point in the history
Improved topic detection system and added server-side commands for host.
  • Loading branch information
Gisgar3 committed Jul 20, 2018
1 parent 26f9850 commit 72533f0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 18 deletions.
74 changes: 58 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,17 @@ 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();

// -----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) {
Expand Down Expand Up @@ -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.`);
}
}
}
}
Expand All @@ -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);
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 72533f0

Please sign in to comment.