Bots Home
|
Create an App
Spank Test
Author:
ghdffdgh
Description
Source Code
Launch Bot
Current Users
Created by:
Ghdffdgh
cb.settings_choices = [ { name: "prefix", type: "str", defaultValue: "!", label: "Commands Prefix" }, { name: "onMsg", type: "str", defaultValue: "Spanks have been Enabled!", label: "Spanks On Notice" }, { name: "offMsg", type: "str", defaultValue: "Spanks have been Disabled!", label: "Spanks Off Notice" }, { name: "spOnMsg", type: "str", defaultValue: "A Deal on Spanks has started, Spanks are half off! :leiaspanks", label: "Special Deal Start Notice" }, { name: "spOffMsg", type: "str", defaultValue: "The Deal on Spanks has ended. Total Spanks: spanks", label: "Special Deal End Notice" }, { name: "addMsg", type: "str", defaultValue: "tipper has tipped amt to add Spanks, New Spanks Total: spanks", label: "Add Spanks Notice" }, { name: "subMsg", type: "str", defaultValue: "tipper has tipped amt to remove Spanks, New Spanks Total: spanks", label: "Remove Spanks Notice" }, { name: "spAddMsg", type: "str", defaultValue: "tipper has tipped amt to add Spanks, New Spanks Total: spanks", label: "Special Add Spanks Notice" }, { name: "spSubMsg", type: "str", defaultValue: "tipper has tipped amt to remove Spanks, New Spanks Total: spanks", label: "Special Sub Spanks Notice" }, { name: "addTip", type: "int", defaultValue: "11", label: "Tip Amount to Add Spanks" }, { name: "subTip", type: "int", defaultValue: "12", label: "Tip Amount to Remove Spanks" }, { name: "spAddTip", type: "int", defaultValue: "5", label: "Tip Amount for Special Spanks" }, { name: "spSubTip", type: "int", defaultValue: "6", label: "Tip Amount for Special Spanks" }, { name: "spankAmt", type: "int", defaultValue: "5", label: "Amount Changed per Tip" }, { name: "noticeColor", type: "str", defaultValue: "#0D98BA", label: "Notice Color" }, { name: "addColor", type: "str", defaultValue: "#FFCC80", label: "Add Tip Color" }, { name: "subColor", type: "str", defaultValue: "#E0F2FB", label: "Sub Tip Color" }, { name: "plus", type: "str", defaultValue: "Attack", label: "Positives Leaderboard Name" }, { name: "minus", type: "str", defaultValue: "Defense", label: "Negatives Leaderboard Name" } ]; let spanks = 0; let addTotal = 0; let subTotal = 0; let spAddTotal = 0; let spSubTotal = 0; var spanksOn = true; var spSpanksOn = false; var followOn = false; cb.onMessage (function(msg) { message = msg['m']; sender = msg['user']; if (message.startsWith(cb.settings.prefix)) { msg['X-Spam'] = true; func = message.substr(1) if (sender == cb.room_slug || msg['is_mod']) { var isModerator = true } messageCommands(func, sender, isModerator) } else { return msg; } }); var helpCommands = [ "spanks total", "leaderboard (Added/Cancelled)", "spanks (on/off)", "afk (on/off)", "add spanks #", "spanked #", "reset spanks", "total", "send leaderboard (Spanked/Cancelled)", "start timer # (command)", "follow (on/off)", "follower total" ]; function messageCommands(func, sender, isModerator) { command = func.split(' ') if (func == "help") { if (isModerator) { length = helpCommands.length; } else { length = 2; } cb.chatNotice("Command:", sender, '', cb.settings.noticeColor) for (i = 0; i < length; i ++) { cb.chatNotice(helpCommands[i], sender) } } if (func == "spanks total") { cb.chatNotice("Spanks Total: " + spanks, sender, '', cb.settings.noticeColor) } if (func == "follower total") { getFollowers(sender) } if (func.startsWith("leaderboard")) { if (command[1] == undefined) { displayLeaderboard("Added", 3, sender) displayLeaderboard("Cancelled", 3, sender) } else displayLeaderboard(command[1], 3, sender) } if (isModerator) { if (func.startsWith("send leaderboard")) { if (command[2] == undefined) { displayLeaderboard("Added", 3, '') displayLeaderboard("Cancelled", 3, '') } else displayLeaderboard(command[2], 3, '') } if (func.startsWith("spanks")) { var lever = undefined; if (command[1] == "on") { lever = "on" } else if (command[1] == "off") { lever = "off" } else if (func == "spanks") { if (spanksOn) { lever = "off" } else { lever = "on" } } if (lever == "on") { spanksOn = true; cb.chatNotice(cb.settings.onMsg, '', cb.settings.noticeColor) } else if (lever == "off") { spanksOn = false; cb.chatNotice(cb.settings.offMsg, '', cb.settings.noticeColor) } } if (func.startsWith("afk")) { var lever = undefined; if (command[1] == "on") { lever = "on" } else if (command[1] == "off") { lever = "off" } else if (func = "afk") { if (spSpanksOn) { lever = "off" } else { lever = "on" } } if (lever == "on") { spSpanksOn = true; cb.chatNotice(cb.settings.spOnMsg, '', cb.settings.noticeColor) } else if (lever == "off") { spSpanksOn = false; cb.chatNotice(cb.settings.spOffMsg.replace("spanks", spanks), '', cb.settings.noticeColor) } } if (func.startsWith("follow")) { var lever = undefined; if (command[1] == "on") { lever = "on" } else if (command[1] == "off") { lever = "off" } else if (func == "follow") { if (followOn) { lever = "off" } else { lever = "on" } } if (lever == "on") { followOn = true; cb.chatNotice("Follower Notifications have been Enabled", '', cb.settings.noticeColor) } else if (lever == "off") { followOn = false; cb.chatNotice("Follower Notifications have been Disabled", '', cb.settings.noticeColor) } } if (func.startsWith("add spanks")) { addedSpanks = command[2] if (!(isNaN(addedSpanks))) { spanks += parseInt(addedSpanks) cb.chatNotice(addedSpanks + " Spank(s) have been added to the Spanks Total, new Spanks Total: " + spanks, '', '', cb.settings.noticeColor) } else { cb.chatNotice("Check your spelling, an invalid integer was used.", sender, '', cb.settings.noticeColor) } } if (func.startsWith("spanked")) { removeSpanks = command[1] if (!(isNaN(removeSpanks))) { spanks -= removeSpanks cb.chatNotice(removeSpanks + " Spank(s) have been removed from the Spanks Total, new Spanks Total " + spanks, '', '', cb.settings.noticeColor) if (spanks < 0) { spanks = 0 cb.chatNotice("Maths Error Detected", '', '', cb.settings.noticeColor) cb.chatNotice("Correcting Maths Error", '', '', cb.settings.noticeColor) cb.chatNotice("Spanks have been set to 0", '', '', cb.settings.noticeColor) } } else { cb.chatNotice("Check your spelling, an invalid integer was used.", sender, '', cb.settings.noticeColor) } } if (func.startsWith("reset spanks")) { cb.chatNotice("Spanks have been set to 0 from " + spanks, '', '', cb.settings.noticeColor) spanks = 0 } if (func == "total") { cb.chatNotice("Spanks Added: " + addTotal, sender) cb.chatNotice("Spanks Removed: " + subTotal, sender) cb.chatNotice("Discounted Spanks Added: " + spAddTotal, sender) cb.chatNotice("Discounted Spanks Removed: " + spSubTotal, sender) } if (func.startsWith("start timer")) { time = command[2] func = command[3] startTimer(time, func) } } }; function startTimer(time, func) { if (time == 1) { if (func == undefined) { cb.chatNotice("A Timer for 1 minute has Started", '', cb.settings.noticeColor) } else { cb.chatNotice(func + " will be activated after 1 minute", '', cb.settings.noticeColor) } minuteLeft(func) } else { if (func == undefined) { cb.chatNotice("A Timer for " + time + " minutes has started", '', cb.settings.noticeColor) } else { cb.chatNotice(func + " will be activated after " + time + " minutes", '', cb.settings.noticeColor) } cb.setTimeout(function() {timerCountdown(time, func)}, 60 * 1000) } } function timerCountdown(time, func) { time -- if (time == 0){ if (func == undefined) { cb.chatNotice("The Timer has ended", '', cb.settings.noticeColor) } else { messageCommands(func, '', true) } } else if (time == 1) { if (func == undefined) { cb.chatNotice("1 Minute Remaining", '', '', cb.settings.noticeColor) } else { cb.chatNotice(func + " will be activated in 1 Minute", '', '', cb.settings.noticeColor) } minuteLeft(func) } else { if (func == undefined) { cb.chatNotice(time + " Minutes Remaining", '', '', cb.settings.noticeColor) } else { cb.chatNotice(time + " Minutes Remaining until " + func + " is activated", '', '', cb.settings.noticeColor) } cb.setTimeout(function() {timerCountdown(time, func)}, 60 * 1000) } } function minuteLeft(func) { cb.setTimeout(function () {cb.chatNotice("30 Seconds Left", '', '', cb.settings.noticeColor)}, 30 * 1000) cb.setTimeout(function () {cb.chatNotice("15 Seconds Left", '', '', cb.settings.noticeColor)}, 45 * 1000) cb.setTimeout(function () {cb.chatNotice("5 Seconds Left", '', '', cb.settings.noticeColor)}, 55 * 1000) cb.setTimeout(function () {cb.chatNotice("4 Seconds Left", '', '', cb.settings.noticeColor)}, 56 * 1000) cb.setTimeout(function () {cb.chatNotice("3 Seconds Left", '', '', cb.settings.noticeColor)}, 57 * 1000) cb.setTimeout(function () {cb.chatNotice("2 Seconds Left", '', '', cb.settings.noticeColor)}, 58 * 1000) cb.setTimeout(function () {cb.chatNotice("1 Seconds Left", '', '', cb.settings.noticeColor)}, 59 * 1000) cb.setTimeout(function () {timerCountdown(1, func)}, 60 * 1000) } cb.onTip (function(tip) { if (spanksOn || spSpanksOn) { tipper = tip['from_user']; amount = tip['amount']; if (spanksOn) { if (amount == cb.settings.addTip) { spanks += parseInt(cb.settings.spankAmt) addLeaderboard(tipper, "Added") addTotal ++ tipMessage(cb.settings.addMsg, tipper, amount, cb.settings.addColor) } if (amount == cb.settings.subTip) { spanks -= cb.settings.spankAmt addLeaderboard(tipper, "Cancelled") subTotal ++ if (spanks < 0) { spanks = 0 cb.chatNotice("Spanks have reached a Sub Critical Level, returning to Normal Levels, Spank Total: 0", '', cb.settings.noticeColor) } else { tipMessage(cb.settings.subMsg, tipper, amount, cb.settings.subColor) } } } if (spSpanksOn) { if (amount == cb.settings.spAddTip) { spanks += parseInt(cb.settings.spankAmt) addLeaderboard(tipper, "Added") spAddTotal ++ tipMessage(cb.settings.spAddMsg, tipper, amount, cb.settings.addColor) } if (amount == cb.settings.spSubTip) { spanks -= parseInt(cb.settings.spankAmt) addLeaderboard(tipper, "Cancelled") spSubTotal ++ if (spanks < 0) { spanks = 0 cb.chatNotice("Spanks have reached a Sub Critical Level, returning to Normal Levels, Spank Total: 0", '', cb.settings.noticeColor) } else { tipMessage(cb.settings.spSubMsg, tipper, amount, cb.settings.subColor) } } } } }); function tipMessage(msg, tipper, amount, color) { tipMsg = msg.replace("tipper", tipper) tipMsg = tipMsg.replace("amt", amount) tipMsg = tipMsg.replace("spanks", spanks) cb.chatNotice(tipMsg, '', color) } let leaderboard = {} function addLeaderboard(user, type) { if (!(user in leaderboard)) { leaderboard[user] = { "Added": 0, "Cancelled": 0, } } leaderboard[user][type] ++ } function displayLeaderboard(type, num, toWhom) { if (type == "Added"){ cat = cb.settings.plus } else if (type == "Cancelled"){ cat = cb.settings.minus } cb.chatNotice(cat + " Leaderboard", toWhom, '', cb.settings.noticeColor) var leadersArray = [] for (var user in leaderboard) { o = {} o["name"] = user; o["votes"] = leaderboard[user][type] leadersArray.push(o) } leadersArray.sort(function(a, b) { if (a["votes"] < b["votes"]) { return 1; } if (a["votes"] > b["votes"]) { return -1; } return 0; }) if (leadersArray.length < num) { num = leadersArray.length } for (i = 0; i < num; i ++) { var name = leadersArray[i]["name"]; var count = leadersArray[i]["votes"] cb.chatNotice(name + ": " + count * cb.settings.spankAmt + " Spanks.", toWhom) } } function getFollowers(toWhom) { cb.getRoomOwnerData(ownerData => { if (ownerData['success']) { var totalFollowers = ownerData['data']['followers'] cb.chatNotice("Follower Count: " + totalFollowers + ", New Followers: " + newFollowers, toWhom, '', "#228B22") } }) } let following = []; var newFollowers = 0; followOn = false; cb.onFollow(user => { if (followOn) { if (following.includes(user['user'])) { cb.chatNotice("You were already following " + cb.slug_user, user['user'], "#EE0000") } else { following.push(user['user']) cb.chatNotice(user['user'] + " has started following", '', '', "#228B22") newFollowers ++ } } }) cb.onUnFollow(user => { if (followOn) { if(!(following.includes(user['user']))) { following.push(user['user']) } } })
© Copyright Chaturbate 2011- 2024. All Rights Reserved.