diff --git a/bot.js b/bot.js index a67cd9b..8172a95 100644 --- a/bot.js +++ b/bot.js @@ -16,6 +16,8 @@ let configurations = JSON.parse(configFile); let defaultConfig = { word: "butt", chance: 20, + pity: 0, + currentPity: 0, limit: 10, syllableCount: 2, ignoredUsers: [] @@ -117,6 +119,16 @@ function onMessageHandler (channel, userstate, message, self) { client.say(channel, "Expected a number, got " + value); } break; + case "pity": + if (isNumeric(value)) { + config.pity = parseInt(value); + configurations[channel] = config; + fs.writeFileSync('buttsbot.config', JSON.stringify(configurations)); + client.say(channel, "Pity set to " + value); + } else { + client.say(channel, "Expected a number, got " + value); + } + break; case "ignore": if (value && value !== "") { console.log(`* ignore: value ok`); @@ -226,7 +238,9 @@ function onMessageHandler (channel, userstate, message, self) { // random chance // TODO: find a better alternative var number = Math.random() * 100; - if (number <= config.chance) { + if (number <= config.chance || config.currentPity == config.pity) { + + config.currentPity = 0; counter.converted++; @@ -261,6 +275,8 @@ function onMessageHandler (channel, userstate, message, self) { }); client.say(channel, newMessage.trim()); + } else { + config.currentPity++; } console.log(channel + ": " + JSON.stringify(counter));