From fcf098b034f49c4bd85d73a8e2bf36e6fafe47e6 Mon Sep 17 00:00:00 2001 From: ToastyStoemp Date: Tue, 7 Jun 2016 22:05:44 +0200 Subject: [PATCH 1/3] Added client sided ban --- client/client.js | 11 ++++++++++- server.js | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/client.js b/client/client.js index 54eff97..6377a7c 100644 --- a/client/client.js +++ b/client/client.js @@ -49,6 +49,7 @@ var myNick = localStorageGet('my-nick') var myChannel = window.location.search.replace(/^\?/, '') var lastSent = [""] var lastSentPos = 0 +var banned = localStorageGet('banned') == 'true' ? true : false; // Ping server every 50 seconds to retain WebSocket connection @@ -75,7 +76,9 @@ function join(channel) { } if (myNick) { localStorageSet('my-nick', myNick) - send({cmd: 'join', channel: channel, nick: myNick}) + if (!banned) { + send({cmd: 'join', channel: channel, nick: myNick}) + } } wasConnected = true } @@ -135,6 +138,12 @@ var COMMANDS = { pushMessage({nick: '*', text: nick + " left"}) } }, + data: function(args) { + if (args.banned) { + banned = true; + localStorageSet('banned', banned) + } + } } diff --git a/server.js b/server.js index a1fc8d6..db67d9d 100644 --- a/server.js +++ b/server.js @@ -305,6 +305,7 @@ var COMMANDS = { } POLICE.arrest(getAddress(badClient)) + send({cmd: 'data', banned: true}, badClient); console.log(this.nick + " [" + this.trip + "] banned " + nick + " in " + this.channel) broadcast({cmd: 'info', text: "Banned " + nick}, this.channel) }, From dc360aae2f5247b5f21681e0a98e94b4a0a8bbc4 Mon Sep 17 00:00:00 2001 From: ToastyStoemp Date: Tue, 7 Jun 2016 22:34:22 +0200 Subject: [PATCH 2/3] improv --- client/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/client.js b/client/client.js index 6377a7c..e963a21 100644 --- a/client/client.js +++ b/client/client.js @@ -49,7 +49,7 @@ var myNick = localStorageGet('my-nick') var myChannel = window.location.search.replace(/^\?/, '') var lastSent = [""] var lastSentPos = 0 -var banned = localStorageGet('banned') == 'true' ? true : false; +var banned = localStorageGet('banned') == 'true'; // Ping server every 50 seconds to retain WebSocket connection From 69ac181ddfa6c014a74923ddfee30d63c521bda2 Mon Sep 17 00:00:00 2001 From: Wolf Van Herreweghe Date: Wed, 5 Apr 2017 17:21:36 +0200 Subject: [PATCH 3/3] Updated Regex for links example of currently faulty link: https://share.lyka.pro/2017-4-5-8.png notice how the last ')' is not part of the link, this only occurs in multiline scenario's also reduced the regex complexity with redundant components also allowing for www. link's --- client/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/client.js b/client/client.js index e963a21..bdf41dc 100644 --- a/client/client.js +++ b/client/client.js @@ -193,7 +193,7 @@ function pushMessage(args) { textEl.classList.add('text') textEl.textContent = args.text || '' - textEl.innerHTML = textEl.innerHTML.replace(/(\?|https?:\/\/)\S+?(?=[,.!?:)]?\s|$)/g, parseLinks) + textEl.innerHTML = textEl.innerHTML.replace(/(\s|^)(\?|https?:\/\/|www\.)\S+/g, parseLinks) if ($('#parse-latex').checked) { // Temporary hotfix for \rule spamming, see https://github.com/Khan/KaTeX/issues/109