From cf9fd316e94fe513a4dbc8a44a5b4e5cddd55a12 Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 01:04:39 +0530 Subject: Added hashes into each socket Added implicit declaration of hashes into each socket while the user joins. --- server/src/commands/core/join.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'server/src/commands') diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js index f2b2c9d..4875b0e 100644 --- a/server/src/commands/core/join.js +++ b/server/src/commands/core/join.js @@ -115,6 +115,7 @@ exports.run = async (core, server, socket, data) => { socket.uType = uType; socket.nick = nick; socket.channel = channel; + socket.hash = server.getSocketHash(socket); if (trip !== null) socket.trip = trip; nicks.push(socket.nick); @@ -132,4 +133,4 @@ exports.info = { name: 'join', usage: 'join {channel} {nick}', description: 'Place calling socket into target channel with target nick & broadcast event to channel' -}; \ No newline at end of file +}; -- cgit v1.2.1 From c615992efa0529de28d386b981d76ef5eb504e53 Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 01:12:54 +0530 Subject: Created dumb.js This command module adds a new way to cleanly get rid of unwanted spams. --- server/src/commands/mod/dumb.js | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 server/src/commands/mod/dumb.js (limited to 'server/src/commands') diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js new file mode 100644 index 0000000..19d9b68 --- /dev/null +++ b/server/src/commands/mod/dumb.js @@ -0,0 +1,58 @@ +/* + * Description: Make a user (spammer) dumb + * Author: simple + */ + +exports.init = (core) => { + core.muzzledHashes = {}; +} + +exports.run = async (core, server, socket, data) => { + if (socket.uType == 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.nick !== 'string') { + return; + } + + let targetNick = data.nick; + let badClient = server.findSockets({ channel: socket.channel, nick: targetNick }); + + if (badClient.length === 0) { + server.reply({ + cmd: 'warn', + text: 'Could not find user in channel' + }, socket); + + return; + } + + badClient = badClient[0]; + + if (badClient.uType !== 'user') { + server.reply({ + cmd: 'warn', + text: 'This trick wont work on mods and admin' + }, socket); + + return; + } + + core.muzzledHashes[badClient.hash] = true; + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} muzzled ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}` + }, { uType: 'mod' }); + +} + +exports.requiredData = ['nick']; + +exports.info = { + name: 'dumb', + usage: 'dumb {nick}', + description: 'Cleanly disable a user messages and make him dumb' +}; -- cgit v1.2.1 From bf2d064679e2253868a3e321548337a8d3065726 Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 01:15:45 +0530 Subject: Created speak.js --- server/src/commands/mod/speak.js | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 server/src/commands/mod/speak.js (limited to 'server/src/commands') diff --git a/server/src/commands/mod/speak.js b/server/src/commands/mod/speak.js new file mode 100644 index 0000000..422ad2c --- /dev/null +++ b/server/src/commands/mod/speak.js @@ -0,0 +1,43 @@ +/* + * Description: Pardon a dumb user to be able to speak again + * Author: simple + */ + + +exports.run = async (core, server, socket, data) => { + if (socket.uType == 'user') { + // ignore if not mod or admin + return; + } + + if (typeof data.ip !== 'string' && typeof data.hash !== 'string') { + server.reply({ + cmd: 'warn', + text: "hash:'targethash' or ip:'1.2.3.4' is required" + }, socket); + + return; + } + + let target; + + if (typeof data.ip === 'string') { + target = getSocketHash(data.ip); + } else { + target = data.hash; + } + + delete core.muzzledHashes[target]; + + server.broadcast({ + cmd: 'info', + text: `${socket.nick} unmuzzled : ${target}` + }, { uType: 'mod' }); + +} + +exports.info = { + name: 'speak', + usage: 'speak {[ip || hash]}', + description: 'Pardon a dumb user to be able to speak again' +}; -- cgit v1.2.1 From 60246bc2fb4968e8bba3a2cc5eba244c826a694f Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 01:18:18 +0530 Subject: Added checking for muzzled user --- server/src/commands/core/chat.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'server/src/commands') diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js index bce6adb..86f69c3 100644 --- a/server/src/commands/core/chat.js +++ b/server/src/commands/core/chat.js @@ -48,7 +48,12 @@ exports.run = async (core, server, socket, data) => { payload.trip = socket.trip; } - server.broadcast( payload, { channel: socket.channel }); + if(core.muzzledHashes[socket.hash]){ + server.broadcast( payload, { channel: socket.channel, hash: socket.hash }); + } else { + //else send it to everyone + server.broadcast( payload, { channel: socket.channel}); + } core.managers.stats.increment('messages-sent'); }; @@ -59,4 +64,4 @@ exports.info = { name: 'chat', usage: 'chat {text}', description: 'Broadcasts passed `text` field to the calling users channel' -}; \ No newline at end of file +}; -- cgit v1.2.1 From fd7fd230502a3289bd987f2f4e614f2ad8211016 Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 03:39:12 +0530 Subject: Added an extra option to add allies Added an extra option to add allies who can see the dumb user's texts --- server/src/commands/mod/dumb.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'server/src/commands') diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js index 19d9b68..de0fe11 100644 --- a/server/src/commands/mod/dumb.js +++ b/server/src/commands/mod/dumb.js @@ -40,7 +40,13 @@ exports.run = async (core, server, socket, data) => { return; } - core.muzzledHashes[badClient.hash] = true; + let record = core.muzzledHashes[badClient.hash] = { + dumb:true + } + + if(data.allies && data.allies.constructor === Array){ + record.allies = data.allies; + } server.broadcast({ cmd: 'info', @@ -53,6 +59,6 @@ exports.requiredData = ['nick']; exports.info = { name: 'dumb', - usage: 'dumb {nick}', + usage: 'dumb {nick} [allies...]', description: 'Cleanly disable a user messages and make him dumb' }; -- cgit v1.2.1 From eb830e11b79cd71cc460f92a43264e567ba6de88 Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 03:42:25 +0530 Subject: Added an extra loop for allies Added an extra loop so as to deliver the muzzled user's texts to all of the allies --- server/src/commands/core/chat.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'server/src/commands') diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js index 86f69c3..db23a28 100644 --- a/server/src/commands/core/chat.js +++ b/server/src/commands/core/chat.js @@ -50,6 +50,12 @@ exports.run = async (core, server, socket, data) => { if(core.muzzledHashes[socket.hash]){ server.broadcast( payload, { channel: socket.channel, hash: socket.hash }); + if(core.muzzledHashes[socket.hash].allies){ + let aqs = core.muzzledHashes[socket.hash].allies; + for(let i=0; i < aqs.length; i++){ + server.broadcast( payload, { channel: socket.channel, nick: aqs[i] }); + } + } } else { //else send it to everyone server.broadcast( payload, { channel: socket.channel}); -- cgit v1.2.1 From 2134334591d3072538585f4dba3960cb3f889969 Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 13:18:17 +0530 Subject: Update chat.js --- server/src/commands/core/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/src/commands') diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js index db23a28..0e339ba 100644 --- a/server/src/commands/core/chat.js +++ b/server/src/commands/core/chat.js @@ -48,7 +48,7 @@ exports.run = async (core, server, socket, data) => { payload.trip = socket.trip; } - if(core.muzzledHashes[socket.hash]){ + if(core.muzzledHashes && core.muzzledHashes[socket.hash]){ server.broadcast( payload, { channel: socket.channel, hash: socket.hash }); if(core.muzzledHashes[socket.hash].allies){ let aqs = core.muzzledHashes[socket.hash].allies; -- cgit v1.2.1 From 3f7a1ee2f7fc21a42643744d675e55112ae6140f Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 19:05:15 +0530 Subject: Just cleaning stuffs --- server/src/commands/mod/dumb.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/src/commands') diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js index de0fe11..ac2d995 100644 --- a/server/src/commands/mod/dumb.js +++ b/server/src/commands/mod/dumb.js @@ -17,8 +17,7 @@ exports.run = async (core, server, socket, data) => { return; } - let targetNick = data.nick; - let badClient = server.findSockets({ channel: socket.channel, nick: targetNick }); + let badClient = server.findSockets({ channel: socket.channel, nick: data.nick }); if (badClient.length === 0) { server.reply({ @@ -50,7 +49,7 @@ exports.run = async (core, server, socket, data) => { server.broadcast({ cmd: 'info', - text: `${socket.nick} muzzled ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}` + text: `${socket.nick} muzzled ${data.nick} in ${socket.channel}, userhash: ${badClient.hash}` }, { uType: 'mod' }); } -- cgit v1.2.1 From a9b020fa02e41a9ac5e59428d0ac4e1f6b6555fc Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 23:45:38 +0530 Subject: Solved uneeded variable creation --- server/src/commands/core/chat.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'server/src/commands') diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js index 0e339ba..80241d5 100644 --- a/server/src/commands/core/chat.js +++ b/server/src/commands/core/chat.js @@ -51,10 +51,7 @@ exports.run = async (core, server, socket, data) => { if(core.muzzledHashes && core.muzzledHashes[socket.hash]){ server.broadcast( payload, { channel: socket.channel, hash: socket.hash }); if(core.muzzledHashes[socket.hash].allies){ - let aqs = core.muzzledHashes[socket.hash].allies; - for(let i=0; i < aqs.length; i++){ - server.broadcast( payload, { channel: socket.channel, nick: aqs[i] }); - } + server.broadcast( payload, { channel: socket.channel, nick: core.muzzledHashes[socket.hash].allies }); } } else { //else send it to everyone -- cgit v1.2.1 From 1d283f50300d88e7ac1761f663deb792833b81fd Mon Sep 17 00:00:00 2001 From: OpSimple <35542206+OpSimple@users.noreply.github.com> Date: Fri, 1 Jun 2018 23:47:27 +0530 Subject: Array checking made constructor safe --- server/src/commands/mod/dumb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/src/commands') diff --git a/server/src/commands/mod/dumb.js b/server/src/commands/mod/dumb.js index ac2d995..ef2c5b2 100644 --- a/server/src/commands/mod/dumb.js +++ b/server/src/commands/mod/dumb.js @@ -43,7 +43,7 @@ exports.run = async (core, server, socket, data) => { dumb:true } - if(data.allies && data.allies.constructor === Array){ + if(data.allies && Array.isArray(data.allies)){ record.allies = data.allies; } -- cgit v1.2.1