Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prg-chatbot

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prg-chatbot - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

2

package.json
{
"name": "prg-chatbot",
"version": "0.11.0",
"version": "0.12.0",
"description": "Facebook Messenger Chatbot Framework",

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

@@ -747,3 +747,3 @@ # Prg-chatbot - Facebook Messenger platform framework

* [new Router()](#new_Router_new)
* [.use([action], [pattern], reducer)](#Router+use) ⇒ <code>Object</code>
* [.use([action], [pattern], ...reducers)](#Router+use) ⇒ <code>Object</code>
* [.reduce(req, res, postBack)](#ReducerWrapper+reduce)

@@ -758,3 +758,3 @@

### router.use([action], [pattern], reducer) ⇒ <code>Object</code>
### router.use([action], [pattern], ...reducers) ⇒ <code>Object</code>
Appends middleware, action handler or another router

@@ -768,3 +768,3 @@

| [pattern] | <code>RegExp</code> &#124; <code>string</code> &#124; <code>function</code> | |
| reducer | <code>function</code> &#124; <code>[Router](#Router)</code> | |
| ...reducers | <code>function</code> &#124; <code>[Router](#Router)</code> | |

@@ -783,3 +783,4 @@ **Example**

// route with matching function
// route with matching function (the function is considered as matcher
// in case of the function accepts zero or one arguments)
router.use('action', req => req.text() === 'a', (req, res) => {

@@ -789,2 +790,8 @@ res.text('Hello!');

// use multiple reducers
router.use('/path', reducer1, reducer2)
.next('exitAction', (data, req, res, postBack, next) => {
postBack('anotherAction', { someData: true })
});
// append router with exit action

@@ -791,0 +798,0 @@ router.use('/path', subRouter)

@@ -24,9 +24,30 @@ /*

* @param {ReducerWrapper|function|Router} reducer
* @param {{appUrl?:string, translator?:function, timeout?:number, log?:object,
defaultState?:object, cookieName?:string, pageToken:string, appSecret:string,
chatLog?:object, tokenStorage?:object, senderFnFactory?:function,
securityMiddleware?:object, loadUsers?:boolean, loadUsers?:object,
onSenderError?:function }} options
* @param {{getOrCreateAndLock:function, saveState:function,
onAfterStateLoad:function}} [stateStorage]
* @param {{
pageToken:string,
appSecret:string,
appUrl?:string,
translator?:function,
timeout?:number,
log?:object,
defaultState?:object,
cookieName?:string,
chatLog?:object,
tokenStorage?:object,
senderFnFactory?:function,
securityMiddleware?:object,
loadUsers?:boolean,
loadUsers?:object,
onSenderError?:function,
autoTyping?: boolean|{
time?: number,
perCharacters?: number,
minTime?: number,
maxTime?: number
}
}} options
* @param {{
getOrCreateAndLock:function,
saveState:function,
onAfterStateLoad:function
}} [stateStorage]
*

@@ -33,0 +54,0 @@ * @memberOf Processor

@@ -36,2 +36,10 @@ /*

Object.assign(this.options, options);
if (this.options.autoTyping) {
this.options.autoTyping = Object.assign({
time: 600,
perCharacters: 'Sample text Sample texts'.length,
minTime: 500,
maxTime: 2700
}, this.options.autoTyping);
}

@@ -99,2 +107,3 @@ this._t = this.options.translator;

this._autoTypingIfEnabled(messageData.message.text);
this._send(messageData);

@@ -180,2 +189,3 @@ return this;

this._autoTypingIfEnabled(null);
this._send(messageData);

@@ -202,2 +212,3 @@ return this;

this._autoTypingIfEnabled(null);
this._send(messageData);

@@ -359,4 +370,31 @@ return this;

}
_autoTypingIfEnabled (text) {
if (!this.options.autoTyping) {
return;
}
const typingTime = this._getTypingTimeForText(text);
this.typingOn().wait(typingTime);
}
_getTypingTimeForText (text) {
const textLength = typeof text === 'string'
? text.length
: this.options.autoTyping.perCharacters;
const timePerCharacter = this.options.autoTyping.time
/ this.options.autoTyping.perCharacters;
return Math.min(
Math.max(
textLength * timePerCharacter,
this.options.autoTyping.minTime
),
this.options.autoTyping.maxTime
);
}
}
module.exports = Responder;
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc