add subsitution regexp for chat messages (currently unused)
This commit is contained in:
parent
29129b98f7
commit
1ca9932b84
|
@ -18,26 +18,19 @@ class ChatProvider {
|
|||
this.history = [];
|
||||
this.filters = [
|
||||
{
|
||||
regexp: /ADMIN/g,
|
||||
regexp: /ADMIN/gi,
|
||||
matches: 2,
|
||||
},
|
||||
{
|
||||
regexp: /FUCK/g,
|
||||
regexp: /FUCK/gi,
|
||||
matches: 2,
|
||||
},
|
||||
{
|
||||
regexp: /admin/g,
|
||||
matches: 3,
|
||||
},
|
||||
{
|
||||
regexp: /fuck/g,
|
||||
matches: 3,
|
||||
},
|
||||
{
|
||||
regexp: /FACK/g,
|
||||
regexp: /FACK/gi,
|
||||
matches: 3,
|
||||
},
|
||||
];
|
||||
this.substitutes = [];
|
||||
}
|
||||
|
||||
addMessage(name, message) {
|
||||
|
@ -48,7 +41,7 @@ class ChatProvider {
|
|||
}
|
||||
|
||||
async sendMessage(user, message) {
|
||||
if (message.length > 300) {
|
||||
if (message.length > 200) {
|
||||
// eslint-disable-next-line max-len
|
||||
return 'You can\'t send a message this long :(';
|
||||
}
|
||||
|
@ -63,7 +56,7 @@ class ChatProvider {
|
|||
}
|
||||
|
||||
if (message === message.toUpperCase()) {
|
||||
return null;
|
||||
return 'Stop shouting';
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.filters.length; i += 1) {
|
||||
|
@ -75,6 +68,11 @@ class ChatProvider {
|
|||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.substitutes.length; i += 1) {
|
||||
const subsitute = this.substitutes[i];
|
||||
message = message.replace(subsitute.regexp, subsitute.replace);
|
||||
}
|
||||
|
||||
if (user.isAdmin() && message.charAt(0) === '/') {
|
||||
// admin commands
|
||||
const cmd = message.split(' ');
|
||||
|
|
Loading…
Reference in New Issue
Block a user