Apps Home
|
Create an App
goal two
Author:
billywithoutmandyrnb
Description
Source Code
Launch App
Current Users
Created by:
Billywithoutmandyrnb
var tipKing = '', tipKingColour = '#cc0000'; var totalTipped = 0, highestSingleTip = 0, topTipper = '', topTippers = [], topTippersLimit = 5, latestUserTip = '', latestUserTipAmount = 0; var defChatcolour = '#333333', defBackgroundColour = '#ffffff' var userList = {}, silenceGreys = false, appInit = false; var commandRegex = /((\/|\!)+[a-z_]+)\s?(.*)?/; var goalList = [], goalListId = 0, mainGoal = 0, mainGoalTitle = '', mainGoalEnabled = false, roomSubject = ''; var drawPanelTemplate = {}, drawPanel = false; // Tip queue for delayed responses so that the onTip event doesn't die for slow response var tipQueue = [], onTipEnabled = false, canBroadcastTopTippers = false, regeneratePanel = false; var topTipperColours = { 1: {text: '#000000',back: '#ff8585'}, 2: {text: '#333333',back: '#ffbbf9'}, 3: {text: '#333333',back: '#bbbeff'}, 4: {text: '#333333',back: '#bbffe6'}, 5: {text: '#333333',back: '#fff3bb'} }; cb.settings_choices = [ {name: 'room_subject', type:'str', minLength:0, maxLength:255, defaultValue:'', label:'Room Subject', required:true}, {name: 'allow_notokens', type:'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label:'Allow User Chat With No Tokens', required:true}, {name: 'goal_main', type:'int', minValue:0, maxValue:100000, defaultValue:0, label:'Main Goal Token Amount1', required:false}, {name: 'goal_main_title', type:'str', minLength:0, maxLength:255, defaultValue:'', label:'Main Goal1(eg. Cum Show)', required:false}, {name: 'goal_main', type:'int', minValue:0, maxValue:100000, defaultValue:0, label:'Main Goal Token Amount', required:false}, {name: 'goal_main_title', type:'str', minLength:0, maxLength:255, defaultValue:'', label:'Main Goal2 (eg. Cum Show)', required:false}, {name: 'goal_main', type:'int', minValue:0, maxValue:100000, defaultValue:0, label:'Main Goal Token Amount', required:false}, /*{name: 'tipking_enable', type:'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label:'Use Tip King'}, {name: 'tipking_tokenpermin', type:'int', minValue:0, maxValue:10000, defaultValue:25, label:'Tokens per minute for tip king'}, {name: 'limitcam_enable', type:'choice', choice1: 'yes', choice2: 'no', defaultValue: 'yes', label:'Use LimitCam'}, {name: 'limitcam_threshold', type:'int', minValue:0, maxValue:10000, defaultValue:500, label:'Minimum tip for LimitCam show'}, {name: 'limit_gender', type:'choice', choice1: 'No', choice2: 'M', choice3: 'F', defaultValue: 'No', label:'Limit Gender'}*/ ]; var room_rules = [ 'Welcome to {user}\'s room!', 'Please follow my room rules and enjoy your stay here!', 'Rule 1: Beggars are banned immediately', 'Rule 2: Fighting with others in my room will get you banned', 'Rule 3: Don\'t advertise other models!', 'Rule 4: No graphics, it will get you banned', 'Rule 5: Shouting will get you banned!', 'PS: Type !goals to see what goals I have :)' ]; var messages = { notokens: 'I see that you don\'t have any tokens! I don\'t let users without tokens speak, so please buy some and chat with me ;)', congratstokens: 'Please say hi and enjoy the show ;)', restrictedgender: 'I\'m sorry I currently have restricted gender on, your messages won\'t be visibile in chat', tipthankyou: 'Thank you for your tip!', newtoptipper: 'Congratulations to {user} who is the newest single high tipper with {amount} tokens!' }; var userStatus = { GOOD: 'GOOD', SHIT: 'SHIT' }; var commandTopics = [ {cmd: '!help', desc: 'Shows the following broadcaster tools'}, {cmd: '!goals', desc: 'Users can see what goals you have created'}, {cmd: '/add_goal {Token} {Name}', desc: 'You can add another goal for users to tip for, eg. /add_goal 100 Show Tits'}, {cmd: '/show_goals', desc: 'You can see what goals you\'ve set for your users, will print {ID} {Name} {Tokens} eg. 1 Show Tits 50'}, {cmd: '/remove_goal {ID}', desc: 'You can remove a goal you\'ve created using the goal ID from /show_goals eg. /remove_goal 1'}, {cmd: '/silence_greys', desc: 'You can silence users who don\'t have tokens. All of their messages will be ignored'}, {cmd: '/unsilence_greys', desc: 'You can turn off the grey silence from above, future messages will display'}, {cmd: '/set_main_goal {Token} {Name}', desc: 'Set the main goal amount, eg. 2000 for full naked, /set_main_goal 2000 Cum Show'}, {cmd: '/disable_main_goal', desc: 'Disables the main goal set from the previous command'}, {cmd: '/set_topic {Topic}', desc: 'Set the room topic, eg. /set_topic Tip 777 to be my Lover and get 2 free POV videos'} ]; var adminCommands = ['!help','/add_goal','/show_goals','/remove_goal','/silence_greys','/unsilence_greys','/set_main_goal','/disable_main_goal','/set_topic']; cb.onEnter(function(user) { if (!appInit) { init(); } // Room model if (user['user'] == cb.room_slug) { return; } if (!checkCanTalk(user['has_tokens'], user['is_mod'], user['in_fanclub'], user['tipped_recently'])) { cb.sendNotice(messages.notokens, user['user'], '#ff0000', '#ffffff'); setUserStatus(user['user'], userStatus.SHIT); } if (checkRestrictedGender(cb.settings.limit_gender, user['gender'])) { cb.sendNotice(messages.restrictedgender, user['user'], '#ff0000', '#ffffff'); setUserStatus(user['user'], userStatus.SHIT); } setUserStatus(user['user'], userStatus.GOOD); announceRules(user['user']); cb.sendNotice(messages.congratstokens, user['user'], '#009226', '#ffffff'); }); cb.onMessage(function (msg) { if (!appInit) { init(); } if (msg['user'] == cb.room_slug && commandRegex.test(msg['m'])) { handleAdminMessageInput(msg['m']); msg['X-Spam'] = true; return msg; } if (msg['m'] == '!goals' || msg['m'].substring(0, 6) == '!goals') { msg['X-Spam'] = true; for (i = 0; i < goalList.length; i++) { var str = goalList[i].title + ', ' + goalList[i].amount + ' tokens'; cb.chatNotice(str, msg['user'], '#eeeeee', '#333333'); } return msg; } // Room model if (msg['user'] == cb.room_slug) { return msg; } // App started while users in room? Put everyone in the shit list and enable them as they message & have tokens etc. if (!userList.hasOwnProperty(msg['user'])) { announceRules(msg['user']); setUserStatus(msg['user'], userStatus.SHIT); } if (userList[msg['user']].tokenCount > 0 || checkCanTalk(cb.settings.allow_notokens, msg['has_tokens'], msg['is_mod'], msg['in_fanclub'], msg['tipped_recently'])) { if (userList[msg['user']].userStatus == userStatus.SHIT) { setUserStatus(msg['user'], userStatus.GOOD); } } else { cb.sendNotice(messages.notokens, msg['user'], '#ff0000', '#ffffff'); setUserStatus(msg['user'], userStatus.SHIT); msg['X-Spam'] = true; return msg; } // Check if user is tip king, and then in top tippers list, or just normal user if (cb.settings.tipking_enable == 'yes' && tipKing == msg['user']) { msg['background'] = tipKingColour; msg['c'] = '#ffffff'; } else if (topTippers.indexOf(msg['user']) > -1) { var idx = topTippers.indexOf(msg['user']) + 1; msg['background'] = topTipperColours[idx].back; msg['c'] = topTipperColours[idx].text; } else { msg['background'] = defBackgroundColour; msg['c'] = defChatcolour; } if (topTipper != '' && msg['user'] == topTipper) { msg['m'] = '[high tipper] ' + msg['m']; } return msg; }); // This is the actual tip handler. the cb.onTip event handler adds an event item to the // tip queue, this handler processes the tip queue up to 5 at a time. function cbOnTip() { if (tipQueue.length == 0) { // This will always act on a loop cb.setTimeout(cbOnTip, 5000); return; } // transfer queue items to temp list up to max 5 var tips = []; var limit = tipQueue.length >= 5 ? 5 : tipQueue.length; if (limit > 0) { for (i = 0; i < limit; i++) { tips.push(tipQueue.shift()); } } for (i = 0; i < tips.length; i++) { var tip = tips[i]; cb.sendNotice(messages.tipthankyou, tip['from_user'], '#009226', '#ffffff'); // App started while users in room? Put everyone in the good list if (!userList.hasOwnProperty(tip['from_user'])) { announceRules(tip['from_user']); setUserStatus(tip['from_user'], userStatus.GOOD); } // Always make tippers good :) userList[tip['from_user']].userStatus = userStatus.GOOD; totalTipped += tip['amount']; handleTip(tip['from_user'], tip['amount']); if (tip['amount'] > highestSingleTip) { highestSingleTip = tip['amount']; topTipper = tip['from_user']; cb.chatNotice(messages.newtoptipper.replace('{user}', topTipper).replace('{amount}', highestSingleTip), '', '#009226', '#ffffff'); } updateTopTippers(tip['from_user']); userList[tip['from_user']].tokenCount += tip['amount']; latestUserTip = tip['from_user']; latestUserTipAmount = tip['amount']; if (mainGoalEnabled) { mainGoal = tip['amount'] >= mainGoal ? 0 : mainGoal - tip['amount']; } } setRoomTopic(); // Set semaphores for draw panel, update tippers & regen panel if (!drawPanel) { drawPanel = true; } if (!regeneratePanel) { regeneratePanel = true; cb.setTimeout(regenerateDrawPanelTemplate, 5000); } if (!canBroadcastTopTippers) { canBroadcastTopTippers = true; cb.setTimeout(broadcastTopTippers, 5000); } // This will always act on a loop cb.setTimeout(cbOnTip, 5000); } cb.onTip(function(tip) { if (!appInit) { init(); } tipQueue.push(tip); if (!onTipEnabled) { onTipEnabled = true; setTimeout(cbOnTip, 5000); } }); function regenerateDrawPanelTemplate() { var t = { 'template': '3_rows_of_labels', 'row1_label': 'Tips received :', 'row1_value': totalTipped, 'row2_label': 'Highest Tip:', 'row2_value': (topTipper != '' ? topTipper + ' (' + highestSingleTip + ')' : ''), 'row3_label': 'Latest Tip:', 'row3_value': (latestUserTip != '' ? latestUserTip + ' (' + latestUserTipAmount + ')' : '') }; drawPanelTemplate = t; if (drawPanel) { cb.drawPanel(); drawPanel = false; } if (regeneratePanel) { regeneratePanel = false; } } cb.onDrawPanel(function(user) { return drawPanelTemplate; }); function announceRules(user) { for (var i = 0; i < room_rules.length; i++) { cb.chatNotice(room_rules[i].replace('{user}', cb.room_slug), user, '#cccccc', '#000000'); } } /** * Helper functions */ function handleTip(user, amount) { if (mainGoalEnabled && amount >= mainGoal) { announceTipGoal(user, mainGoalTitle + ' goal has been reached!'); return; } if (goalList.length > 0) { for (i = 0; i < goalList.length; i++) { if (goalList[i].amount == amount) { announceTipGoal(user, goalList[i].goal); break; } } } } function announceTipGoal(user, goal) { goal += ' Thanks ' + user + '!'; cb.chatNotice(goal, '', '#009226', '#ffffff'); } function checkCanTalk(hasTips, isMod, isFan, hasTippedRecently) { if (!hasTips && !isMod && !isFan && !hasTippedRecently && silenceGreys) { return false; } return true; } function checkRestrictedGender(restrictGender, gender) { if (!restrictGender || restrictGender == 'No') { return false; } return gender == restrictGender.toLowerCase(); } function setUserStatus(user, status) { if (!userList.hasOwnProperty(user)) { userList[user] = {tokenCount: 0, userStatus: status}; return; } userList[user].userStatus = status; return; } function resetUserTokenCount(user) { if (userList.hasOwnProperty(user)) { userList[user].tokenCount = 0; } } function updateTopTippers(user) { // Already in list! if (topTippers.indexOf(user) != -1) { return; } // Is the list full yet? if (topTippers.length == 0 || topTippers.length < topTippersLimit) { topTippers.push(user); return; } // User not in list, can it be added? var idx = -1; for (i = 0; i < topTippers.length; i++) { if (usersList[user].tokenCount > usersList[topTippers[i]]) { idx = i; } else { break; } } // Not high enough to enter list if (idx == -1) { return; } else { topTippers.splice(idx, 1); topTippers.push(user); } } function reorderTopTippers() { // Don't order if empty or 1 if (topTippers.length < 2) { return; } var list = [], curHigh = -1, tipper = '', idx = -1, curList = topTippers.slice(0, topTippers.length); while(list.length < topTippers.length) { for (i = 0; i < curList.length; i++) { if (userList[curList[i]].tokenCount > curHigh) { curHigh = userList[curList[i]].tokenCount; tipper = curList[i]; idx = i; } } curList.splice(idx, 1); list.push(tipper); curHigh = -1; tipper = ''; idx = -1; } // Copy over old array topTippers = curList.slice(0, curList.length); } function broadcastTopTippers() { if (canBroadcastTopTippers) { canBroadcastTopTippers = false; } if (topTippers.length == 0) { return; } // Reorder top tippers before broadcast reorderTopTippers(); var str = []; str.push('High Tipper Leaderboard'); str.push('Highest single tip: ' + topTipper + ' with ' + highestSingleTip + ' tokens!'); for (i = 0; i < topTippers.length; i++) { str.push('No ' + (i+1) + ': ' + topTippers[i] + ' with ' + userList[topTippers[i]].tokenCount + ' tokens!'); } for (i = 0; i < str.length; i++) { cb.chatNotice(str[i], '', '#dec8f0', '#333333'); } } function handleAdminMessageInput(message) { var matches = commandRegex.exec(message); var cmd = matches[1], params = ''; if (matches.length == 4) { params = matches[3]; } // Show help topics if (cmd == '!help') { printBroadcasterHelpTopics(); return; } // Show defined goals if (cmd == '/show_goals') { printBroadcasterGoals(); return; } // Add a goal if (cmd == '/add_goal') { var m = /([0-9]+)\s(.*)/.exec(params); goalList.push({id: goalListId, amount: m[1], title: m[2], goal: 'Goal reached! ' + m[2] + '!'}); goalListId++; var str = 'Goal: ' + m[2] + ' (' + m[1] + ' tokens) has been added'; cb.chatNotice(str, '', '#009226', '#ffffff'); } // Remove defined goal if (cmd == '/remove_goal' && /([0-9]+)/.test(params)) { var idx = -1; for (i = 0; i < goalList.length; i++) { if (goalList[i].id == params) { idx = goalList[i].id; break; } } if (idx > -1) { var str = 'Goal: ' + goalList[idx].title + ' (' + goalList[idx].amount + ' tokens) has been removed'; cb.chatNotice(str, '', '#009226', '#ffffff'); goalList.splice(idx, 1); } return; } if (cmd == '/silence_greys') { silenceGreys = true; cb.chatNotice('Greys have been silenced', '', '#009226', '#ffffff'); return; } if (cmd == '/unsilence_greys') { cb.chatNotice('Greys have been unsilenced', '', '#009226', '#ffffff'); silenceGreys = false; return; } // Set the main goal if (cmd == '/set_main_goal') { var m = /([0-9]+)\s(.*)/.exec(params); mainGoal = m[1]; mainGoalTitle = m[2]; mainGoalEnabled = true; setRoomTopic(); return; } if (cmd == '/disable_main_goal') { mainGoalEnabled = false; setRoomTopic(); return; } if (cmd == '/set_topic') { roomSubject = params; setRoomTopic(); return; } } function printBroadcasterHelpTopics() { for (i = 0; i < commandTopics.length; i++) { var str = 'Command: ' + commandTopics[i].cmd + ', ' + commandTopics[i].desc; cb.chatNotice(str, cb.room_slug, '#009226', '#ffffff'); } } function printBroadcasterGoals() { if (goalList.length == 0) { cb.chatNotice('You don\'t have any goals set, you can set some with /add_goal {tokens} {name}, use !help for more information', cb.room_slug, '#009226', '#ffffff'); return; } for (i = 0; i < goalList.length; i++) { var str = goalList[i].id + ': ' + goalList[i].title + ', ' + goalList[i].amount + ' tokens'; cb.chatNotice(str, cb.room_slug, '#009226', '#ffffff'); } } function setRoomTopic() { var thisSubject = roomSubject; if (mainGoalEnabled) { thisSubject += ' - ' + mainGoal + ' tokens left until ' + mainGoalTitle; } if (goalList.length > 0) { thisSubject += ', type !goals to see what the model has set' } cb.changeRoomSubject(thisSubject); } function init() { if (cb.settings.room_subject.length > 0) { roomSubject = cb.settings.room_subject; } // Check that main goal has been set if (cb.settings.goal_main > 0 && cb.settings.goal_main_title.length > 0) { mainGoalEnabled = true; mainGoal =cb.settings.goal_main; mainGoalTitle = cb.settings.goal_main_title; } if (cb.settings.allow_notokens == 'no') { silenceGreys = true; } // Check if each predefined goal is set with token count more than 0 var idx = 1; if (cb.settings.goal_boobs > 0) { goalList.push({id: idx, amount: cb.settings.goal_boobs, title: 'Show Boobs', goal: 'Goal reached! Tit flash!'}); idx++; } if (cb.settings.goal_pussy > 0) { goalList.push({id: idx, amount: cb.settings.goal_pussy, title: 'Show Pussy', goal: 'Goal reached! Pussy flash!'}); idx++; } if (cb.settings.goal_pussyf > 0) { goalList.push({id: idx, amount: cb.settings.goal_pussyf, title: 'Show Pussy With Finger', goal: 'Goal reached! Pussy finger flash!'}); idx++; } if (cb.settings.goal_ass > 0) { goalList.push({id: idx, amount: cb.settings.goal_ass, title: 'Show Ass', goal: 'Goal reached! Ass flash!'}); idx++; } if (cb.settings.goal_braoff > 0) { goalList.push({id: idx, amount: cb.settings.goal_braoff, title: 'Take Bra Off', goal: 'Goal reached! Bra off!'}); idx++; } if (cb.settings.goal_pantyoff > 0) { goalList.push({id: idx, amount: cb.settings.goal_pantyoff, title: 'Take Panty Off', goal: 'Goal reached! Panties off!'}); idx++; } if (cb.settings.goal_fullnaked > 0) { goalList.push({id: idx, amount: cb.settings.goal_fullnaked, title: 'Get Me Fully Naked', goal: 'Goal reached! Full naked!'}); idx++; } goalListId = idx; setRoomTopic(); appInit = true; }
© Copyright Chaturbate 2011- 2026. All Rights Reserved.