Add delay to whitelist warning message to prevent spamming
This commit is contained in:
parent
3dc55070f7
commit
49b80f6323
9
index.js
9
index.js
@ -127,7 +127,14 @@ Searxng.prototype.handleMessage = function(event, room) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (this.roomUserWhitelists.has(room.roomId) && this.roomUserWhitelists.get(room.roomId).indexOf(event.getSender()) < 0) {
|
else if (this.roomUserWhitelists.has(room.roomId) && this.roomUserWhitelists.get(room.roomId).indexOf(event.getSender()) < 0) {
|
||||||
this.matrixClient.sendNotice(room.roomId, "You are not on the whitelist for this room.");
|
const lastRoomWarningTime = lastWarningTimes.get(room.roomId);
|
||||||
|
|
||||||
|
const currentTime = Date.now();
|
||||||
|
|
||||||
|
if (isNaN(lastRoomWarningTime) || (Date.now() - lastRoomWarningTime) > 10000) {
|
||||||
|
this.matrixClient.sendNotice(room.roomId, "You are not on the whitelist for this room.");
|
||||||
|
lastWarningTimes.set(room.roomId, currentTime);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (this.cooldownImmuneUsers.indexOf(event.getSender()) < 0) {
|
else if (this.cooldownImmuneUsers.indexOf(event.getSender()) < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user