diff --git a/modules/quotes/config.json b/modules/quotes/config.json index 32c3324..3a7dc05 100644 --- a/modules/quotes/config.json +++ b/modules/quotes/config.json @@ -1,3 +1,4 @@ { - "dbKeys": [ "quoteArrs" ] + "dbKeys": [ "quoteArrs" ], + "rmLimit": 10 } diff --git a/modules/quotes/quotes.js b/modules/quotes/quotes.js index abcc073..6b8cdc8 100644 --- a/modules/quotes/quotes.js +++ b/modules/quotes/quotes.js @@ -3,6 +3,9 @@ var quotes = function(dbot) { var quotes = dbot.db.quoteArrs; var addStack = []; var rmAllowed = true; + dbot.sessionData.rmCache = []; + var rmCache = dbot.sessionData.rmCache; + var rmTimer; // Retrieve a random quote from a given category, interpolating any quote // references (~~QUOTE CATEGORY~~) within it @@ -32,12 +35,69 @@ var quotes = function(dbot) { return quoteString; }; + var resetRemoveTimer = function(event, key, quote) { + rmAllowed = false; + dbot.timers.addOnceTimer(5000, function() { + rmAllowed = true; + }); + + rmCache.push({'key': key, 'quote': quote}); + dbot.timers.clearTimeout(rmTimer); + if(rmCache.length < dbot.config.quotes.rmLimit) { + rmTimer = dbot.timers.addOnceTimer(600000, function() { + rmCache.length = 0; // lol what + }); + } else { + for(var i=0;i