Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1387 from zauberware/global_typing_delay
Browse files Browse the repository at this point in the history
#1386: Additional global parameter that can be set to change the typi…
  • Loading branch information
Ben Brown authored Jul 9, 2018
2 parents cd7c15e + 04fd8ed commit 42b5fbf
Show file tree
Hide file tree
Showing 2 changed files with 1,592 additions and 1,583 deletions.
11 changes: 10 additions & 1 deletion lib/Web.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ function WebBot(configuration) {

var controller = Botkit(configuration || {});

if (controller.config.typingDelayFactor === undefined) {
controller.config.typingDelayFactor = 1;
}

controller.excludeFromConversations(['hello', 'welcome_back', 'reconnect']);

controller.openSocketServer = function(server) {
Expand Down Expand Up @@ -203,7 +207,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) * controller.config.typingDelayFactor;
}

setTimeout(function() {
Expand Down Expand Up @@ -344,6 +348,11 @@ function WebBot(configuration) {
controller.ingest(controller.spawn({}), payload, res);
};

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

// Substantially shorten the delay for processing messages in conversations
controller.setTickDelay(10);

Expand Down
Loading

0 comments on commit 42b5fbf

Please sign in to comment.