remove ui/chat spam traps
parent
ee55e9f275
commit
ed2c432f83
|
@ -1,7 +1,6 @@
|
|||
import { h, thunk } from 'snabbdom'
|
||||
import { VNode, VNodeData } from 'snabbdom/vnode'
|
||||
import { Ctrl, Line } from './interfaces'
|
||||
import * as spam from './spam'
|
||||
import enhance from './enhance';
|
||||
import { presetView } from './preset';
|
||||
import { lineAction } from './moderation';
|
||||
|
@ -72,8 +71,7 @@ function renderInput(ctrl: Ctrl): VNode | undefined {
|
|||
const kbm = document.querySelector('.keyboard-move input') as HTMLElement;
|
||||
if (kbm) kbm.focus();
|
||||
} else {
|
||||
spam.report(txt);
|
||||
if (ctrl.opts.public && spam.hasTeamUrl(txt)) alert("Please don't advertise teams in the chat.");
|
||||
if (ctrl.opts.public && hasTeamUrl(txt)) alert("Please don't advertise teams in the chat.");
|
||||
else ctrl.post(txt);
|
||||
el.value = '';
|
||||
el.classList.remove('whisper');
|
||||
|
@ -92,8 +90,7 @@ function selectLines(ctrl: Ctrl): Array<Line> {
|
|||
ctrl.data.lines.forEach(line => {
|
||||
if (!line.d &&
|
||||
(!prev || !sameLines(prev, line)) &&
|
||||
(!line.r || ctrl.opts.kobold) &&
|
||||
!spam.skip(line.t)
|
||||
(!line.r || ctrl.opts.kobold)
|
||||
) ls.push(line);
|
||||
prev = line;
|
||||
});
|
||||
|
@ -139,3 +136,8 @@ function renderLine(ctrl: Ctrl, line: Line) {
|
|||
textNode
|
||||
] : [userNode, textNode]);
|
||||
}
|
||||
|
||||
const teamUrlRegex = /lichess\.org\/team\//
|
||||
function hasTeamUrl(txt: string) {
|
||||
return !!txt.match(teamUrlRegex);
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
export function skip(txt: string) {
|
||||
return analyse(txt) && isSpammer.get() != '1';
|
||||
}
|
||||
export function hasTeamUrl(txt: string) {
|
||||
return !!txt.match(teamUrlRegex);
|
||||
}
|
||||
export function report(txt: string) {
|
||||
if (analyse(txt)) {
|
||||
$.post('/jslog/____________?n=spam');
|
||||
isSpammer.set('1');
|
||||
}
|
||||
}
|
||||
|
||||
const isSpammer = window.lichess.storage.make('spammer');
|
||||
|
||||
const spamRegex = new RegExp([
|
||||
'xcamweb.com',
|
||||
'chess-bot',
|
||||
'coolteenbitch',
|
||||
'goo.gl/',
|
||||
'letcafa.webcam',
|
||||
'tinyurl.com/',
|
||||
'wooga.info/',
|
||||
'bit.ly/',
|
||||
'wbt.link/',
|
||||
'eb.by/',
|
||||
'001.rs/',
|
||||
'shr.name/',
|
||||
'u.to/',
|
||||
].map(url => {
|
||||
return url.replace(/\./g, '\\.').replace(/\//g, '\\/');
|
||||
}).join('|'));
|
||||
|
||||
function analyse(txt: string) {
|
||||
return !!txt.match(spamRegex);
|
||||
}
|
||||
|
||||
const teamUrlRegex = /lichess\.org\/team\//
|
Loading…
Reference in New Issue