Socket
Socket
Sign inDemoInstall

antispammer

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    antispammer

Have the ability to check if a user is spamming and act upon it!


Version published
Maintainers
1
Created

Readme

Source

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 antispammer
const antispam = require('antispammer');

Create a new filter:

const spamfilter({
  time: number, // default: 60000
  max: number, // default: 100
  onGood: function, // default: returns => object
  onBad: function, // default: returns => object
});

Methods:

.setTime(number)
antispam.setTime(time) // returns => object
.setMax(number)
antispam.setMax(threshold) // returns => object
.setOnGood(function)
antispam.setOnGood(notSpammingFunction) // returns => object
.setOnBad(function)
antispam.setOnBad(spammingFunction) // returns => object
.check(id)
antispam.check(string) // returns => function
.clear(id)
antispam.clear(string) // returns => void
.has(id)
antispam.has(string) // returns => boolean
.list()
antispam.list() // returns => array

Example:

const antispam = require('antispammer');
const user = 123;
const spamFilter = new antispam({
  time: 30000, // 30 seconds
  max: 20
});

function spammer() {
  console.log('Spammer no spamming!');
  spamFilter.clear(user);
};

spamFilter.setOnBad(spammer);


spamFilter(user);

console.log(spamFilter.list()); //['123']

console.log(spamFilter.has('123')); //false

Keywords

FAQs

Last updated on 04 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc