From 9a020e1dcb5eb0bddb21849eab63d9bbc0e6b8d8 Mon Sep 17 00:00:00 2001 From: Scritches Date: Thu, 25 Apr 2019 12:21:01 -0400 Subject: [PATCH] added rate limiting for large todo lists --- modules/todo/todo.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/todo/todo.js b/modules/todo/todo.js index b1526cf..b19ac88 100644 --- a/modules/todo/todo.js +++ b/modules/todo/todo.js @@ -52,10 +52,16 @@ var todo = function(dbot) { evt.reply(dbot.t('empty-list', {'user': evt.user})); } else { evt.reply('[' + evt.user + ']:'); - for (let i = 0; i < myTodos.length; i++) { + var i = 0; + + function loop() { var todo = myTodos[i]; - evt.reply((i+1) + ': ' + todo); + evt.reply((i + 1) + ': ' + todo); + i = i + 1; + if (i < myTodos.length) setTimeout(loop, 1000); } + + loop(); } },