aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2019-04-08 02:04:10 +0200
committermarzavec <admin@marzavec.com>2019-04-08 02:04:10 +0200
commitf353ecbd9e9e8e409303bb4f5c5590e95f579869 (patch)
tree3345967ae59a46f59fe86c0d6fda432115594927 /server/src/commands
parentrefactoring 1 of 2 (diff)
downloadhackchat-f353ecbd9e9e8e409303bb4f5c5590e95f579869.tar.gz
hackchat-f353ecbd9e9e8e409303bb4f5c5590e95f579869.zip
refactoring 2 of 2
Diffstat (limited to 'server/src/commands')
-rw-r--r--server/src/commands/admin/addmod.js2
-rw-r--r--server/src/commands/admin/listusers.js2
-rw-r--r--server/src/commands/admin/reload.js8
-rw-r--r--server/src/commands/admin/removemod.js2
-rw-r--r--server/src/commands/admin/saveconfig.js2
-rw-r--r--server/src/commands/admin/shout.js2
-rw-r--r--server/src/commands/core/changenick.js4
-rw-r--r--server/src/commands/core/chat.js4
-rw-r--r--server/src/commands/core/emote.js4
-rw-r--r--server/src/commands/core/help.js4
-rw-r--r--server/src/commands/core/invite.js2
-rw-r--r--server/src/commands/core/join.js2
-rw-r--r--server/src/commands/core/move.js2
-rw-r--r--server/src/commands/core/whisper.js4
-rw-r--r--server/src/commands/internal/disconnect.js4
-rw-r--r--server/src/commands/internal/socketreply.js4
-rw-r--r--server/src/commands/mod/ban.js4
-rw-r--r--server/src/commands/mod/dumb.js4
-rw-r--r--server/src/commands/mod/kick.js2
-rw-r--r--server/src/commands/mod/moveuser.js2
-rw-r--r--server/src/commands/mod/speak.js2
-rw-r--r--server/src/commands/mod/unban.js4
-rw-r--r--server/src/commands/mod/unbanall.js4
23 files changed, 37 insertions, 37 deletions
diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js
index a30b175..6853a42 100644
--- a/server/src/commands/admin/addmod.js
+++ b/server/src/commands/admin/addmod.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin
if (socket.uType != 'admin') {
- return server._police.frisk(socket.remoteAddress, 20);
+ return server.police.frisk(socket.remoteAddress, 20);
}
// add new trip to config
diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js
index 472b89d..5ff350f 100644
--- a/server/src/commands/admin/listusers.js
+++ b/server/src/commands/admin/listusers.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin
if (socket.uType != 'admin') {
- return server._police.frisk(socket.remoteAddress, 20);
+ return server.police.frisk(socket.remoteAddress, 20);
}
// find all users currently in a channel
diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js
index 27be19c..588d1c5 100644
--- a/server/src/commands/admin/reload.js
+++ b/server/src/commands/admin/reload.js
@@ -6,11 +6,11 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin
if (socket.uType != 'admin') {
- return server._police.frisk(socket.remoteAddress, 20);
+ return server.police.frisk(socket.remoteAddress, 20);
}
// do command reload and store results
- let loadResult = core.dynamicImports.reloadDirCache('src/commands');
+ let loadResult = core.dynamicImports.reloadDirCache();
loadResult += core.commands.loadCommands();
// clear and rebuild all module hooks
@@ -18,9 +18,9 @@ exports.run = async (core, server, socket, data) => {
// build reply based on reload results
if (loadResult == '') {
- loadResult = `Reloaded ${core.commands._commands.length} commands, 0 errors`;
+ loadResult = `Reloaded ${core.commands.commands.length} commands, 0 errors`;
} else {
- loadResult = `Reloaded ${core.commands._commands.length} commands, error(s):
+ loadResult = `Reloaded ${core.commands.commands.length} commands, error(s):
${loadResult}`;
}
diff --git a/server/src/commands/admin/removemod.js b/server/src/commands/admin/removemod.js
index 87f4124..a2d862c 100644
--- a/server/src/commands/admin/removemod.js
+++ b/server/src/commands/admin/removemod.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin
if (socket.uType != 'admin') {
- return server._police.frisk(socket.remoteAddress, 20);
+ return server.police.frisk(socket.remoteAddress, 20);
}
// remove trip from config
diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js
index a95a39a..65fff0e 100644
--- a/server/src/commands/admin/saveconfig.js
+++ b/server/src/commands/admin/saveconfig.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin
if (socket.uType != 'admin') {
- return server._police.frisk(socket.remoteAddress, 20);
+ return server.police.frisk(socket.remoteAddress, 20);
}
// attempt save, notify of failure
diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js
index e9c69e0..821a22a 100644
--- a/server/src/commands/admin/shout.js
+++ b/server/src/commands/admin/shout.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin
if (socket.uType != 'admin') {
- return server._police.frisk(socket.remoteAddress, 20);
+ return server.police.frisk(socket.remoteAddress, 20);
}
// send text to all channels
diff --git a/server/src/commands/core/changenick.js b/server/src/commands/core/changenick.js
index ae057b3..cb6d1d0 100644
--- a/server/src/commands/core/changenick.js
+++ b/server/src/commands/core/changenick.js
@@ -7,7 +7,7 @@ const verifyNickname = (nick) => /^[a-zA-Z0-9_]{1,24}$/.test(nick);
// module main
exports.run = async (core, server, socket, data) => {
- if (server._police.frisk(socket.remoteAddress, 6)) {
+ if (server.police.frisk(socket.remoteAddress, 6)) {
return server.reply({
cmd: 'warn',
text: 'You are changing nicknames too fast. Wait a moment before trying again.'
@@ -31,7 +31,7 @@ exports.run = async (core, server, socket, data) => {
// prevent admin impersonation
// TODO: prevent mod impersonation
if (newNick.toLowerCase() == core.config.adminName.toLowerCase()) {
- server._police.frisk(socket.remoteAddress, 4);
+ server.police.frisk(socket.remoteAddress, 4);
return server.reply({
cmd: 'warn',
diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js
index bb9584e..7b7e79e 100644
--- a/server/src/commands/core/chat.js
+++ b/server/src/commands/core/chat.js
@@ -24,12 +24,12 @@ exports.run = async (core, server, socket, data) => {
if (!text) {
// lets not send objects or empty text, yea?
- return server._police.frisk(socket.remoteAddress, 13);
+ return server.police.frisk(socket.remoteAddress, 13);
}
// check for spam
let score = text.length / 83 / 4;
- if (server._police.frisk(socket.remoteAddress, score)) {
+ if (server.police.frisk(socket.remoteAddress, score)) {
return server.reply({
cmd: 'warn',
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.'
diff --git a/server/src/commands/core/emote.js b/server/src/commands/core/emote.js
index 40fcff2..f51f854 100644
--- a/server/src/commands/core/emote.js
+++ b/server/src/commands/core/emote.js
@@ -24,12 +24,12 @@ exports.run = async (core, server, socket, payload) => {
if (!text) {
// lets not send objects or empty text, yea?
- return server._police.frisk(socket.remoteAddress, 8);
+ return server.police.frisk(socket.remoteAddress, 8);
}
// check for spam
let score = text.length / 83 / 4;
- if (server._police.frisk(socket.remoteAddress, score)) {
+ if (server.police.frisk(socket.remoteAddress, score)) {
return server.reply({
cmd: 'warn',
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.'
diff --git a/server/src/commands/core/help.js b/server/src/commands/core/help.js
index 51f6d87..8eccdb6 100644
--- a/server/src/commands/core/help.js
+++ b/server/src/commands/core/help.js
@@ -8,7 +8,7 @@ const stripIndents = require('common-tags').stripIndents;
// module main
exports.run = async (core, server, socket, payload) => {
// check for spam
- if (server._police.frisk(socket.remoteAddress, 2)) {
+ if (server.police.frisk(socket.remoteAddress, 2)) {
return server.reply({
cmd: 'warn',
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.'
@@ -27,7 +27,7 @@ exports.run = async (core, server, socket, payload) => {
API: {cmd: 'help', command: '<command name>'}`;
reply += '\n\n-------------------------------------\n\n';
- let categories = core.commands.categories().sort();
+ let categories = core.commands.categoriesList.sort();
for (let i = 0, j = categories.length; i < j; i++) {
reply += `${categories[i].replace('../src/commands/', '').replace(/^\w/, c => c.toUpperCase())} Commands:\n`;
let catCommands = core.commands.all(categories[i]).sort((a, b) => a.info.name.localeCompare(b.info.name));
diff --git a/server/src/commands/core/invite.js b/server/src/commands/core/invite.js
index 046e47a..70393b1 100644
--- a/server/src/commands/core/invite.js
+++ b/server/src/commands/core/invite.js
@@ -8,7 +8,7 @@ const verifyNickname = (nick) => /^[a-zA-Z0-9_]{1,24}$/.test(nick);
// module main
exports.run = async (core, server, socket, data) => {
// check for spam
- if (server._police.frisk(socket.remoteAddress, 2)) {
+ if (server.police.frisk(socket.remoteAddress, 2)) {
return server.reply({
cmd: 'warn',
text: 'You are sending invites too fast. Wait a moment before trying again.'
diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js
index ce900db..965a8bc 100644
--- a/server/src/commands/core/join.js
+++ b/server/src/commands/core/join.js
@@ -55,7 +55,7 @@ exports.parseNickname = (core, data) => {
// module main
exports.run = async (core, server, socket, data) => {
// check for spam
- if (server._police.frisk(socket.remoteAddress, 3)) {
+ if (server.police.frisk(socket.remoteAddress, 3)) {
return server.reply({
cmd: 'warn',
text: 'You are joining channels too fast. Wait a moment and try again.'
diff --git a/server/src/commands/core/move.js b/server/src/commands/core/move.js
index e85f481..8e97a06 100644
--- a/server/src/commands/core/move.js
+++ b/server/src/commands/core/move.js
@@ -5,7 +5,7 @@
// module main
exports.run = async (core, server, socket, data) => {
// check for spam
- if (server._police.frisk(socket.remoteAddress, 6)) {
+ if (server.police.frisk(socket.remoteAddress, 6)) {
return server.reply({
cmd: 'warn',
text: 'You are changing channels too fast. Wait a moment before trying again.'
diff --git a/server/src/commands/core/whisper.js b/server/src/commands/core/whisper.js
index c515d43..109889d 100644
--- a/server/src/commands/core/whisper.js
+++ b/server/src/commands/core/whisper.js
@@ -26,12 +26,12 @@ exports.run = async (core, server, socket, payload) => {
if (!text) {
// lets not send objects or empty text, yea?
- return server._police.frisk(socket.remoteAddress, 13);
+ return server.police.frisk(socket.remoteAddress, 13);
}
// check for spam
let score = text.length / 83 / 4;
- if (server._police.frisk(socket.remoteAddress, score)) {
+ if (server.police.frisk(socket.remoteAddress, score)) {
return server.reply({
cmd: 'warn',
text: 'You are sending too much text. Wait a moment and try again.\nPress the up arrow key to restore your last message.'
diff --git a/server/src/commands/internal/disconnect.js b/server/src/commands/internal/disconnect.js
index 8656779..520f8cb 100644
--- a/server/src/commands/internal/disconnect.js
+++ b/server/src/commands/internal/disconnect.js
@@ -5,9 +5,9 @@
// module main
exports.run = async (core, server, socket, data) => {
- if (data.cmdKey !== server._cmdKey) {
+ if (data.cmdKey !== server.cmdKey) {
// internal command attempt by client, increase rate limit chance and ignore
- return server._police.frisk(socket.remoteAddress, 20);
+ return server.police.frisk(socket.remoteAddress, 20);
}
// send leave notice to client peers
diff --git a/server/src/commands/internal/socketreply.js b/server/src/commands/internal/socketreply.js
index fa3b8cf..5dadaf6 100644
--- a/server/src/commands/internal/socketreply.js
+++ b/server/src/commands/internal/socketreply.js
@@ -4,9 +4,9 @@
// module main
exports.run = async (core, server, socket, data) => {
- if (data.cmdKey !== server._cmdKey) {
+ if (data.cmdKey !== server.cmdKey) {
// internal command attempt by client, increase rate limit chance and ignore
- return server._police.frisk(socket.remoteAddress, 20);
+ return server.police.frisk(socket.remoteAddress, 20);
}
// send warning to target socket
diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js
index 93c536b..9c8eb4f 100644
--- a/server/src/commands/mod/ban.js
+++ b/server/src/commands/mod/ban.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin or mod
if (socket.uType === 'user') {
- return server._police.frisk(socket.remoteAddress, 10);
+ return server.police.frisk(socket.remoteAddress, 10);
}
// check user input
@@ -36,7 +36,7 @@ exports.run = async (core, server, socket, data) => {
}
// commit arrest record
- server._police.arrest(badClient.remoteAddress, badClient.hash);
+ server.police.arrest(badClient.remoteAddress, badClient.hash);
console.log(`${socket.nick} [${socket.trip}] banned ${targetNick} in ${socket.channel}`);
diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js
index d64c746..d5e8fee 100644
--- a/server/src/commands/mod/dumb.js
+++ b/server/src/commands/mod/dumb.js
@@ -14,7 +14,7 @@ exports.init = (core) => {
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin or mod
if (socket.uType === 'user') {
- return server._police.frisk(socket.remoteAddress, 10);
+ return server.police.frisk(socket.remoteAddress, 10);
}
// check user input
@@ -93,7 +93,7 @@ exports.chatCheck = (core, server, socket, payload) => {
}
// blanket "spam" protection, may expose the ratelimiting lines from `chat` and use that, TODO: one day #lazydev
- server._police.frisk(socket.remoteAddress, 9);
+ server.police.frisk(socket.remoteAddress, 9);
return false;
}
diff --git a/server/src/commands/mod/kick.js b/server/src/commands/mod/kick.js
index 808defa..f3bc7ca 100644
--- a/server/src/commands/mod/kick.js
+++ b/server/src/commands/mod/kick.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin or mod
if (socket.uType === 'user') {
- return server._police.frisk(socket.remoteAddress, 10);
+ return server.police.frisk(socket.remoteAddress, 10);
}
// check user input
diff --git a/server/src/commands/mod/moveuser.js b/server/src/commands/mod/moveuser.js
index e4f6c22..c7fc4bf 100644
--- a/server/src/commands/mod/moveuser.js
+++ b/server/src/commands/mod/moveuser.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin or mod
if (socket.uType === 'user') {
- return server._police.frisk(socket.remoteAddress, 10);
+ return server.police.frisk(socket.remoteAddress, 10);
}
// check user input
diff --git a/server/src/commands/mod/speak.js b/server/src/commands/mod/speak.js
index e2a3ef7..23fc4de 100644
--- a/server/src/commands/mod/speak.js
+++ b/server/src/commands/mod/speak.js
@@ -14,7 +14,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin or mod
if (socket.uType === 'user') {
- return server._police.frisk(socket.remoteAddress, 10);
+ return server.police.frisk(socket.remoteAddress, 10);
}
// check user input
diff --git a/server/src/commands/mod/unban.js b/server/src/commands/mod/unban.js
index 71be9bb..6744d9d 100644
--- a/server/src/commands/mod/unban.js
+++ b/server/src/commands/mod/unban.js
@@ -6,7 +6,7 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin or mod
if (socket.uType === 'user') {
- return server._police.frisk(socket.remoteAddress, 10);
+ return server.police.frisk(socket.remoteAddress, 10);
}
// check user input
@@ -28,7 +28,7 @@ exports.run = async (core, server, socket, data) => {
}
// remove arrest record
- server._police.pardon(target);
+ server.police.pardon(target);
// mask ip if used
if (mode === 'ip') {
diff --git a/server/src/commands/mod/unbanall.js b/server/src/commands/mod/unbanall.js
index a9cf682..c285b80 100644
--- a/server/src/commands/mod/unbanall.js
+++ b/server/src/commands/mod/unbanall.js
@@ -6,11 +6,11 @@
exports.run = async (core, server, socket, data) => {
// increase rate limit chance and ignore if not admin or mod
if (socket.uType === 'user') {
- return server._police.frisk(socket.remoteAddress, 10);
+ return server.police.frisk(socket.remoteAddress, 10);
}
// remove arrest records
- server._police._records = {};
+ server.police.records = {};
console.log(`${socket.nick} [${socket.trip}] unbanned all`);