Skip to content

Commit

Permalink
howdyai#1386: Additional global parameter that can be set to change t…
Browse files Browse the repository at this point in the history
…he typing delay factor.
  • Loading branch information
lisa_schmitz committed Jun 14, 2018
1 parent c5b55d9 commit 1c15e2e
Show file tree
Hide file tree
Showing 3 changed files with 1,589 additions and 1,583 deletions.
6 changes: 6 additions & 0 deletions lib/CoreBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function Botkit(configuration) {
teams: {},
},
tickDelay: 1500,
typingDelayFactor: 1,
};

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
Expand Down Expand Up @@ -1438,6 +1439,11 @@ function Botkit(configuration) {
}
};

// change the speed of typing a reply in a conversation
botkit.setTypingDelayFactor = function(delayFactor) {
botkit.typingDelayFactor = delayFactor;
};

botkit.startTask = function(bot, message, cb) {


Expand Down
2 changes: 1 addition & 1 deletion lib/Web.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function WebBot(configuration) {
var avgWPM = 150;
var avgCPM = avgWPM * 7;

typingLength = Math.min(Math.floor(textLength / (avgCPM / 60)) * 1000, 2000);
typingLength = Math.min(Math.floor(textLength / (avgCPM / 60)) * 1000, 2000) * bot.botkit.typingDelayFactor;
}

setTimeout(function() {
Expand Down
Loading

0 comments on commit 1c15e2e

Please sign in to comment.