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

Comparing version 1.3.0 to 1.4.0

2

.upm/store.json

@@ -1,1 +0,1 @@

{"version":2,"languages":{"nodejs-npm":{"specfileHash":"ece44f0636e5440c4d0ffe2f3f7a2dc3","lockfileHash":"7168a1c32aa34efa6944823612e30dfe","guessedImportsHash":"990a2e6019984149a64a08919cff5afb"}}}
{"version":2,"languages":{"nodejs-npm":{"specfileHash":"02b0dd20e97a9322c59fe17eacac987b","lockfileHash":"0508942b872be0f8ad5f69c149c5aea2"}}}

@@ -1,2 +0,2 @@

function antispam(options) {
function filter(options) {
this.data = new Object();

@@ -7,23 +7,23 @@ function noneSet() {

if (options) {
if (options.time) {
this.data.timeout = options.time;
if (options.time) {
this.data.timeout = options.time;
} else {
this.data.timeout = 60000;
};
if (options.max) {
this.data.threshold = options.max;
} else {
this.data.threshold = 100;
};
if (options.onGood) {
this.data.notSpamming = options.onGood;
} else {
this.data.notSpamming = noneSet;
};
if (options.onBad) {
this.data.spamming = options.onBad;
} else {
this.data.spamming = noneSet;
};
} else {
this.data.timeout = 60000;
};
if (options.max) {
this.data.threshold = options.max;
} else {
this.data.threshold = 100;
};
if (options.onGood) {
this.data.notSpamming = options.onGood;
} else {
this.data.notSpamming = noneSet;
};
if (options.onBad) {
this.data.spamming = options.onBad;
} else {
this.data.spamming = noneSet;
};
} else {
var options = {

@@ -40,2 +40,3 @@ time: 60000,

}
this.data.override = false;

@@ -65,14 +66,14 @@ this.data.list = new Array();

if (thisId.length === 0) {
var startCheck = () => {
var checkTimeout = () => {
var tId = this.data.list.filter(value => value === id);
if (tId.length !== this.data.threshold) {
this.data.list = withoutId;
}
};
setTimeout(checkTimeout, this.data.timeout);
var startCheck = () => {
var checkTimeout = () => {
var tId = this.data.list.filter(value => value === id);
if (tId.length !== this.data.threshold) {
this.data.list = withoutId;
}
};
this.data.list.push(id);
this.data.notSpamming();
return startCheck();
setTimeout(checkTimeout, this.data.timeout);
};
this.data.list.push(id);
this.data.notSpamming();
return startCheck();
};

@@ -103,2 +104,38 @@ if (thisId.length === this.data.threshold) {

module.exports = antispam;
function complex(filters) {
this.filters = filters;
this.addFilter = (filter) => {
this.filters.push(filter);
return this.filters;
};
this.removeFilter = (filterIndex) => {
this.filters.splice(filterIndex, filterIndex+1);
return this.filters;
}
this.check = (id) => {
this.filters.forEach(filt => {
if (filt.has(id)) {
this.filters.forEach(f => {
while (f.has(id)===false) {
f.data.list.push(id);
}
});
}
filt.check(id);
});
};
this.clear = (id) => {
this.filters.forEach(filt => {
filt.clear(id);
})
};
this.has = (id) => {
return this.filters[0].has(id);
};
}
module.exports = { filter, complex };
{
"name": "antispammer",
"version": "1.3.0",
"version": "1.4.0",
"description": "Have the ability to check if a user is spamming and act upon it!",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,66 +12,2 @@ # Antispammer

```
### Create a new filter:
```js
const spamfilter({
time: number, // default: 60000
max: number, // default: 100
onGood: function, // default: returns => object
onBad: function, // default: returns => object
});
```
### Methods:
#### .setTime(number)
```js
antispam.setTime(ms) // returns => object
```
#### .setMax(number)
```js
antispam.setMax(threshold) // returns => object
```
#### .setOnGood(function)
```js
antispam.setOnGood(notSpammingFunction) // returns => object
```
#### .setOnBad(function)
```js
antispam.setOnBad(spammingFunction) // returns => object
```
#### .check(id)
```js
antispam.check(string) // returns => function
```
#### .clear(id)
```js
antispam.clear(string) // returns => void
```
#### .has(id)
```js
antispam.has(string) // returns => boolean
```
#### .list()
```js
antispam.list() // returns => array
```
### Example:
```js
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
```
# [Documentation Here](https://imthehumanoid.gitbook.io/antispammer/)
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