Bots Home
|
Create an App
Secondary Goal Tracker
Author:
lotanus
Description
Source Code
Launch Bot
Current Users
Created by:
Lotanus
var foreground = '#000000'; var fgWarn = '#FF0000'; var background = '#DBEAFF'; var tokenValues = [cb.settings.tokenValue1, cb.settings.tokenValue2, cb.settings.tokenValue3, cb.settings.tokenValue4, cb.settings.tokenValue5]; var tokenBuyout = cb.settings.tokenBuyout; var tokenBuyoutActive = cb.settings.tokenBuyoutActive; var tokenProgress = 0; cb.settings_choices = [ {name: 'goalTitle', type: 'str', minLength: 1, maxLength: 255, label: 'Goal Title', default: ' 10 minute quickie when we hit the goal! '}, {name: 'goalInstructions', type: 'str', minLength: 1, maxLength: 255, label: 'Goal Instructions', default: ' Tip 4, 44 or 444 tokens for a quick fap! Goal is reached at 1000 tokens, or with one single tip of 656 tokens! Type !goal at any time to see the current status. '}, {name: 'goalTargetShort', type: 'str', minLength: 1, maxLength: 255, label: 'Short target name', default: 'a quickie!'}, {name: 'goalLineEmote', type: 'str', minLength: 1, maxLength: 255, label: 'Emote around first line of goal notice', default: ':fapp', required: false}, {name: 'statusInterval', type: 'int', minValue: 1, default: 3, label: 'Status display interval (mins)'}, {name: 'tokenValue1', type: 'int', minValue: 1, default: 4, label: 'Token amount 1'}, {name: 'tokenValue2', type: 'int', minValue: 1, default: 44, label: 'Token amount 2'}, {name: 'tokenValue3', type: 'int', minValue: 0, default: 444, label: 'Token amount 3', required: false}, {name: 'tokenValue4', type: 'int', minValue: 0, default: 0, label: 'Token amount 4', required: false}, {name: 'tokenValue5', type: 'int', minValue: 0, default: 0, label: 'Token amount 5', required: false}, {name: 'tokenBuyoutActive', type: 'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label: "Have a single value buyout amount?"}, {name: 'tokenBuyout', type: 'int', minValue: 1, default: 656, label: 'Buyout amount (insta-goal)', required: false}, {name: 'goalTarget', type: 'int', minValue: 1, default: 1000, label: 'How many tokens to win?'} ]; function showStatus(user) { var response1 = " " + cb.settings.goalLineEmote + " " + cb.settings.goalTitle + " " +' Goal status '; var response2 = tokenProgress + "/" + cb.settings.goalTarget + " " + ('' == user ? ' (sent to all)' : '') + cb.settings.goalLineEmote; var response3 = cb.settings.goalInstructions; if (undefined == user) { // we were triggered by a timeout user = ''; cb.setTimeout(showStatus, cb.settings.statusInterval*60*1000); } cb.sendNotice(response1 + response2, user, background, foreground, 'bold'); cb.sendNotice(response3, user, background, foreground); } cb.onMessage(function (m) { switch (m['m']) { case '!goal': // other users don't need to see this message var is_mod = (cb.room_slug == m['user'] || m['is_mod']); m['X-Spam'] = !is_mod; if (is_mod) { showStatus(''); } else { showStatus(m['user']); } break; } }); cb.onTip(function (tip) { var amount = parseInt(tip['amount']); for (i=0; i<tokenValues.length; i++) { if (amount == tokenValues[i]) { cb.sendNotice(tip['from_user'] + " has tipped towards " + cb.settings.goalTargetShort, '', background, foreground); tokenProgress += amount; } } if(amount == cb.settings.tokenBuyout && cb.settings.tokenBuyoutActive == 'yes'){ var winMessage = "*******************************************\n" winMessage += tip['from_user'] + " has hit the goal, it's time for " + cb.settings.goalTargetShort; winMessage += "\n*******************************************" cb.sendNotice(winMessage, '', background, foreground, 'bold'); } else if(tokenProgress > cb.settings.goalTarget) { tokenProgress = tokenProgress - cb.settings.goalTarget; var winMessage = "*******************************************\n" winMessage += tip['from_user'] + " has hit the goal, it's time for " + cb.settings.goalTargetShort; winMessage += "\n*******************************************" cb.sendNotice(winMessage, '', background, foreground, 'bold'); } }); showStatus();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.