Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
patrinhani-ciandt committed Oct 27, 2017
1 parent 11e113f commit 69731e4
Show file tree
Hide file tree
Showing 12 changed files with 7,457 additions and 290 deletions.
4 changes: 4 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"esversion": 6,
"loopfunc": true
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"javascript.validate.enable": true,
"jshint.enable": true
}
38 changes: 38 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<dl>
<dt><a href="#AbbottFramework">AbbottFramework</a></dt>
<dd></dd>
<dt><a href="#BaseController">BaseController</a></dt>
<dd></dd>
<dt><a href="#BaseProcessor">BaseProcessor</a></dt>
<dd></dd>
</dl>

## Typedefs
Expand Down Expand Up @@ -32,6 +36,40 @@
| options | AbbottFrameworkOptions |


<br/><br/><br/>

<a id="BaseController"></a>

<h5 style="margin: 10px 0px; border-width: 5px 0px; padding: 5px; border-style: solid;">
BaseController</h5>
<br/><br/><br/>

<a id="new_BaseController_new"></a>

<h5 style="margin: 10px 0px; border-width: 5px 0px; padding: 5px; border-style: solid;">
new BaseController()</h5>Controller Base Class for chat engines.


<br/><br/><br/>

<a id="BaseProcessor"></a>

<h5 style="margin: 10px 0px; border-width: 5px 0px; padding: 5px; border-style: solid;">
BaseProcessor</h5>
<br/><br/><br/>

<a id="new_BaseProcessor_new"></a>

<h5 style="margin: 10px 0px; border-width: 5px 0px; padding: 5px; border-style: solid;">
new BaseProcessor(key, abbottCore)</h5>NLP Processor base class.


| Param | Type |
| --- | --- |
| key | string |
| abbottCore | Object |


<br/><br/><br/>

<a id="AbbottFramework-Options"></a>
Expand Down
2 changes: 1 addition & 1 deletion lib/abbott.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ logger.debug('lib imported!');
* @class
* @param {AbbottFrameworkOptions} options
*/
module.exports = class AbbottFramework {
module.exports = class {
constructor(options) {
this.options = options || {};
this.options.debug = this.options.debug || false;
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/slack/components/rtm_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function(abbotController) {
if (managed_bots[bot.config.token]) {
if (managed_bots[bot.config.token].rtm) {
debug('Stop RTM: Stopping bot');
managed_bots[bot.config.token].closeRTM()
managed_bots[bot.config.token].closeRTM();
}
}
},
Expand Down
22 changes: 11 additions & 11 deletions lib/core/intent-flow-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module.exports = class IntentFlowHandler {
content_type: 'text',
title: item,
payload: item
}
};
});

response = {
Expand All @@ -183,12 +183,12 @@ module.exports = class IntentFlowHandler {
}

_customPayloadHasCustomPlatforms(payload) {
return (('default' in payload)
|| ('abbott' in payload)
|| ('slack' in payload)
|| ('google' in payload)
|| ('facebook' in payload)
|| ('gchats' in payload)) ? true : false;
return (('default' in payload) ||
('abbott' in payload) ||
('slack' in payload) ||
('google' in payload) ||
('facebook' in payload) ||
('gchats' in payload)) ? true : false;
}

_addCustomPayloadPlatform(payload, targetPayloadPlatforms) {
Expand Down Expand Up @@ -261,15 +261,15 @@ module.exports = class IntentFlowHandler {

if (this.botType in textMessages) {
if ((textMessages[this.botType]) && (textMessages[this.botType].length > 0)) {
for (var i = 0; i < textMessages[this.botType].length; i++) {
for (let i = 0; i < textMessages[this.botType].length; i++) {
responsePromises.push({
source: 'apiai',
response: textMessages[this.botType][i]
});
}
}
} else if ((textMessages.default) && (textMessages.default.length > 0)) {
for (var i = 0; i < textMessages.default.length; i++) {
for (let i = 0; i < textMessages.default.length; i++) {
responsePromises.push({
source: 'apiai',
response: textMessages.default[i]
Expand All @@ -286,7 +286,7 @@ module.exports = class IntentFlowHandler {
payloadApis = customPayloads.default;
}

for (var i = 0; i < payloadApis.length; i++) {
for (let i = 0; i < payloadApis.length; i++) {
var customPayload = payloadApis[i];

try {
Expand Down Expand Up @@ -463,7 +463,7 @@ module.exports = class IntentFlowHandler {
}

let defaulVaules = jspath.apply('..*{.default}', respMap);
for (var i = 0; i < defaulVaules.length; i++) {
for (let i = 0; i < defaulVaules.length; i++) {
let defaulVaulesParent = defaulVaules[i];

let tmpDefaultValue = defaulVaulesParent.default;
Expand Down
4 changes: 1 addition & 3 deletions lib/core/responseBuilders/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ module.exports = class {
var curResponse = this.responseFormattersBySource[respItem.source](respItem);

if (finalResponse.trim().length > 0) {
finalResponse += ((respItem.source === 'abbott')
? '<br/>'
: '\n') + curResponse;
finalResponse += ((respItem.source === 'abbott') ? '<br/>' : '\n') + curResponse;
} else {
finalResponse += curResponse;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/core/responseBuilders/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const richResponseAppenderBySource = {
}
}

if (((respItem.response.carousel) && (respItem.response.carousel.items))
|| ((respItem.response.list) && (respItem.response.list.items))) {
if (((respItem.response.carousel) && (respItem.response.carousel.items)) ||
((respItem.response.list) && (respItem.response.list.items))) {

var buildObj = null;
var arrayItems = [];
Expand Down
9 changes: 8 additions & 1 deletion lib/nlpProcessors/base-processor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
const logging = require('../logging');

module.exports = class BaseProcessor {
/**
* NLP Processor base class.
* @name BaseProcessor
* @class
* @param {string} key
* @param {Object} abbottCore
*/
module.exports = class {
get logger() {
if (!this.__logger) {
this.__logger = logging(`abbott-framework:nlp-processors:${this.key}`);
Expand Down
Empty file removed lib/nlpProcessors/index.js
Empty file.
Loading

0 comments on commit 69731e4

Please sign in to comment.