some more chat stuff

This commit is contained in:
HF 2020-04-30 00:20:12 +02:00
parent 2c85ad18c9
commit 5808d8a595

View File

@ -7,6 +7,7 @@ import User from '../data/models/User';
import webSockets from '../socket/websockets'; import webSockets from '../socket/websockets';
import { CHAT_CHANNELS } from './constants'; import { CHAT_CHANNELS } from './constants';
import { cheapDetector } from './isProxy';
class ChatProvider { class ChatProvider {
@ -27,6 +28,18 @@ class ChatProvider {
regexp: /ADMIN/gi, regexp: /ADMIN/gi,
matches: 3, matches: 3,
}, },
{
regexp: /ADMlN/gi,
matches: 3,
},
{
regexp: /ADMlN/gi,
matches: 3,
},
{
regexp: /lCE CREAM/gi,
matches: 3,
},
{ {
regexp: /ICE CREAM/gi, regexp: /ICE CREAM/gi,
matches: 1, matches: 1,
@ -68,7 +81,7 @@ class ChatProvider {
? 'il' ? 'il'
: country; : country;
if (name.startsWith('pop')) return null; if (name.toUpperCase().startsWith('POP')) return null;
if (!name) { if (!name) {
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
return 'Couldn\'t send your message, pls log out and back in again.'; return 'Couldn\'t send your message, pls log out and back in again.';
@ -93,6 +106,14 @@ class ChatProvider {
} }
} }
if (user.ip && await cheapDetector(user.ip)) {
logger.info(
`${name} / ${user.ip} tried to send chat message with proxy`,
);
return 'You can not send chat messages with a proxy';
}
for (let i = 0; i < this.substitutes.length; i += 1) { for (let i = 0; i < this.substitutes.length; i += 1) {
const subsitute = this.substitutes[i]; const subsitute = this.substitutes[i];
message = message.replace(subsitute.regexp, subsitute.replace); message = message.replace(subsitute.regexp, subsitute.replace);