fraight-bot-client
Advanced tools
Comparing version 0.2.1 to 0.2.2
20
index.js
@@ -7,3 +7,3 @@ const express = require('express'); | ||
constructor(params) { | ||
constructor(params = { delay: 1000 }) { | ||
this.params = params; | ||
@@ -26,2 +26,3 @@ this.setupServer(); | ||
headers: this.headers, | ||
delay: this.params.delay | ||
}); | ||
@@ -103,2 +104,3 @@ next(); | ||
constructor({ botThread, message, headers, host}) { | ||
this.seen_at = Date.now(); | ||
Object.assign(this, botThread); | ||
@@ -110,2 +112,10 @@ this.commands = []; | ||
get timeToSend() { | ||
const toWait = this.delay - (Date.now() - this.seen_at); | ||
if (toWait < 0) { | ||
return 0; | ||
} | ||
return toWait; | ||
} | ||
get requestOptions() { | ||
@@ -174,4 +184,10 @@ return { | ||
async exec() { | ||
return axios(this.requestOptions); | ||
return new Promise((resolve, reject) => { | ||
setTimeout(() => | ||
axios(this.requestOptions) | ||
.then(resolve) | ||
.catch(reject), | ||
this.toWait); | ||
}) | ||
} | ||
} |
{ | ||
"name": "fraight-bot-client", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74645
2091