Package Exports
- antispammer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (antispammer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Antispammer
Antispammer allows you to check if a user is spamming, which is set through a threshold of uses in an amount of time. You get to set what happens if the user is spamming and what happens when they aren't. Input a user by ID every time they do something to allow this to happen!
Usage:
Install:
npm install antispammerconst antispam = require('antispammer');Methods:
check:
antispam.check(
id, //string
timeout, //integer
threshold, //integer
notSpamming, //function
spamming //function
);Adds a use by a user and tests for spamming with set thresholds.
clear:
antispam.clear(
id //string
);Clear the user from the spammer list.
has:
antispam.has(
id, //string
threshold //integer
);Checks if the user is on the spam list. Returns a boolean.
Properties:
list:
antispam.list //arrayGet the entire list of user IDs as an array.
Example:
const antispam = require('antispammer');
var user = 123;
// The user ID
function notSpamming() {
console.log(`${user} is not spamming!`);
}
// Defining what happens when the user is not spamming
function spamming() {
console.log('Stop spammer!');
}
// Defining what happens when the user is spamming
for (i=0;i<6;i++) {
antispam.check(user, 30000, 4, notSpamming, spamming);
if (antispam.has(user, 5)) {
antispam.clear(user);
}
}
console.log(antispam.list);Expected Output:
123 is not spamming!
123 is not spamming!
123 is not spamming!
123 is not spamming!
Stop spammer!
Stop spammer!
[ 123, 123, 123, 123 ]