Limit CTCP requests to prevent easy spamming

This commit is contained in:
Jérémie Astori 2018-01-02 19:53:42 -05:00
parent e03694b49c
commit fa4331bcd9
No known key found for this signature in database
GPG key ID: B9A4F245CD67BDE8

View file

@ -1,5 +1,6 @@
"use strict";
const _ = require("lodash");
const Helper = require("../../helper");
const Msg = require("../../models/msg");
const User = require("../../models/user");
@ -35,7 +36,8 @@ module.exports = function(irc, network) {
chan.pushMessage(client, msg);
});
irc.on("ctcp request", (data) => {
// Limit requests to a rate of one per second max
irc.on("ctcp request", _.throttle((data) => {
const response = ctcpResponses[data.type];
if (response) {
@ -51,5 +53,5 @@ module.exports = function(irc, network) {
ctcpMessage: data.message,
});
lobby.pushMessage(client, msg);
});
}, 1000, {trailing: false}));
};