Apps Home
|
Create an App
Dana
Author:
danaalf
Description
Source Code
Launch App
Current Users
Created by:
Danaalf
var total_tipped = 0; var subject_is_set_with_0 = false; var tickets = Array(); var noticeArray = []; var noticeNum = 0; var notifierTimer = parseInt(cb.settings.notifierTimer); var notifierTimeout = 0; var notifierSpamTGL = 1; var tipmenu = ''; var tip_amt = 0; var separator_char = "| "; var msg; var MAXITEMS=20; var tipmenuprice = []; var tipmenuitem= []; var MAXSEP = 9; var HEART = '\u2665'; // ♥ BDIAMOND = '\u2666'; // ♦ BSTAR = '\u2605'; // ★ separators = [ {label:'Hearts',shortcut:':heart2'}, {label:'Glitter',shortcut:':pixelglitter'}, {label:'Flowers',shortcut:':tinyflower2'}, {label:'Bow',shortcut:':bluebow'}, {label:'Hearts2',shortcut:':pixelheart'}, {label:'Smiley',shortcut:':smile'}, {label:'Text Heart',shortcut:HEART}, {label:'Text Diamond',shortcut:BDIAMOND}, {label:'Text Star',shortcut:BSTAR}, ] cb.settings_choices = [ {name: 'tokens', label: 'Tokens to goal', type: 'int', minValue: 1, default: 2500}, {name: 'goal_description', label: 'Description', type: 'str', minLength: 1, maxLength: 255}, {name : "notifierSpam", label : "ROTATING NOTIFIER", type : "choice", choice1 : "Yes", choice2 : "No", defaultValue : "No", required : false }, { name : "notifierTimer", label : "Interval (sec) for rotating notices", type : "int", minValue : 1, maxValue : 2000, defaultValue : 180, required : false }, { name : "notice_color", label : "Text color", type : "str", minLenght : 4, maxLenght : 7, default : '#000000', required : false }, { name : "spamMessage1", label : "Notice #1", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage2", label : "Notice #2", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage3", label : "Notice #3", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage4", label : "Notice #4", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage5", label : "Notice #5", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage6", label : "Notice #6", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage7", label : "Notice #7", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage8", label : "Notice #8", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage9", label : "Notice #9", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, { name : "spamMessage10", label : "Notice #10", type : "str", minLength : 1, maxLength : 1E3, defaultValue : "", required : false }, {name : "tipmenu", label : "Tipmenu on", type : "choice", choice1 : "Yes", choice2 : "No", defaultValue : "No", required : false }, {name:'item1', type:'str', required: false, label:'Item 1',}, {name:'item2', type:'str', required: false, label:'Item 2',}, {name:'item3', type:'str', required: false, label:'Item 3',}, {name:'item4', type:'str', required: false, label:'Item 4',}, {name:'item5', type:'str', required: false, label:'Item 5',}, {name:'item6', type:'str', required: false, label:'Item 6',}, {name:'item7', type:'str', required: false, label:'Item 7',}, {name:'item8', type:'str', required: false, label:'Item 8',}, {name:'item9', type:'str', required: false, label:'Item 9',}, {name:'item10', type:'str', required: false, label:'Item 10',}, {name:'item11', type:'str', required: false, label:'Item 11',}, {name:'item12', type:'str', required: false, label:'Item 12',}, {name:'item13', type:'str', required: false, label:'Item 13',}, {name:'item14', type:'str', required: false, label:'Item 14',}, {name:'item15', type:'str', required: false, label:'Item 15',}, {name:'item16', type:'str', required: false, label:'Item 16',}, {name:'item17', type:'str', required: false, label:'Item 17',}, {name:'item18', type:'str', required: false, label:'Item 18',}, {name:'item19', type:'str', required: false, label:'Item 19',}, {name:'item20', type:'str', required: false, label:'Item 20',}, {name:'tipmenucolor', type:'str', label:'Tipmenu color', defaultValue: '#FF0000'}, {name: 'chat_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 1, label: 'Delay in minutes between notice being displayed (1-999)'} ]; cb.onTip(function(tip) { tip_amt=parseInt(tip['amount']); for (var i = 1; i <= MAXITEMS; i++) { if (tip_amt == tipmenuprice[i]) { cb.sendNotice(tip['from_user'] + ' tipped for ' + tipmenuitem[i],'','',cb.settings['noticecolor'],'bold'); } } total_tipped += tip['amount']; cb.limitCam_addUsers([tip['from_user']]); if (total_tipped >= cb.settings.tokens) { total_tipped = cb.settings.tokens; } update_subject(); //cb.sendNotice("Remains to the goal:" + tips_remaining()); cb.drawPanel(); }); cb.onMessage(function (msg) { var message = msg['m']; var user = msg['user']; var username = ""; if ((cb.room_slug === user || msg.is_mod) && message == '/hds' && !cb.limitCam_isRunning()) { msg['X-Spam'] = true; //output(user + ' has started the show!'); cb.limitCam_start('Tip ' + cb.settings.tokens_hidden_show +' tokens to see the show'); } if ((cb.room_slug === user || msg.is_mod) && message == '/hdo' && cb.limitCam_isRunning()) { msg['X-Spam'] = true; //output(user + ' has stop the show!'); cb.limitCam_stop(); } if ((cb.room_slug === user || msg.is_mod) && message === '/list') { msg['X-Spam'] = true; var userlist = cb.limitCam_allUsersWithAccess(); if (userlist.length > 0) { hideoutput("" + userlist.length + (userlist.length > 1 ? " users" : " user") + " in show: " + cbjs.arrayJoin(userlist, ", "), user); } else { hideoutput("No users in show.", user); } } if ((cb.room_slug === user || msg.is_mod) && message === '/admit') { msg['X-Spam'] = true; cb.limitCam_addUsers(['kostize']); } }); cb.onDrawPanel(function(user) { if (total_tipped >= cb.settings.tokens) { return { 'template': '3_rows_11_21_31', 'row1_value': 'Goal reached!', 'row2_value': '', 'row3_value': '' }; } else{ return { 'template': '3_rows_12_21_31', 'row1_label': 'Tip Received / Goal :', 'row1_value': '' + total_tipped + ' / ' + cb.settings.tokens, 'row2_value': '', 'row3_value': '' }; } }); function update_subject() { if (tips_remaining() == 0) { if (subject_is_set_with_0) { return; } subject_is_set_with_0 = true; } else { subject_is_set_with_0 = false; } var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function tips_remaining() { var r = cb.settings.tokens - total_tipped; if (r < 0) { return 0; } else { return r; } } function chatAd() { if (msg!='Tip Menu: ') { cb.sendNotice(msg,'','',cb.settings.tipmenucolor,'bold'); } cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); } cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); function notifierSpam() { notifierTimeout = setTimeout(function() { if (1 == notifierSpamTGL) { if (noticeArray.length) { sendRotating(); notifierSpam(); } } }, cb.settings.notifierTimer*1000); } /** * @param {?} text * @return {undefined} */ function addNotice(text) { if (text!='') { noticeArray.push(text); } } /** * @return {undefined} */ function parseRotating() { addNotice(cb.settings.spamMessage1); addNotice(cb.settings.spamMessage2); addNotice(cb.settings.spamMessage3); addNotice(cb.settings.spamMessage4); addNotice(cb.settings.spamMessage5); addNotice(cb.settings.spamMessage6); addNotice(cb.settings.spamMessage7); addNotice(cb.settings.spamMessage8); addNotice(cb.settings.spamMessage9); addNotice(cb.settings.spamMessage10); } /** * @return {undefined} */ function sendRotating() { if (noticeArray.length) { if (noticeArray[noticeNum]) { cb.sendNotice(noticeArray[noticeNum], '', '#FFFFFF', cb.settings.notice_color, 'bold'); } noticeNum += 1; if (noticeNum >= noticeArray.length) { noticeNum = 0; } } } function output(message) { cb.chatNotice(message); } function hideoutput(message, recipient) { cb.sendNotice(message, recipient); } function init() { update_subject(); if(cb.settings['tipmenu']=='Yes'){ for (i=0;i<=MAXSEP-1;i++) { if (cb.settings['sepchar'] == separators[i].label) { separator_char = separators[i].shortcut + ' '; } } msg = 'Tip Menu: \n'; for (i=1;i<=MAXITEMS;i++) { var tmp; tmp=cb.settings['item' + i]; if (tmp) { if(i!=1) msg += '\n'; var arr= tmp.split('--'); if (arr[1]===undefined) { cb.sendNotice('Error-You need two dashes to separate the tip amount and menu item for item no '+ i,'','',cb.settings['noticecolor'],'bold'); } else { var amt=parseInt(arr[0]); if (amt>0) { tipmenuprice[i]=amt; tipmenuitem[i]=arr[1]; msg += arr[1] + '(' + amt + ') '; tipmenu = msg; } } } } if (msg!= 'Tip Menu: ') { cb.sendNotice(msg,'','',cb.settings['tipmenucolor'],'bold'); } else { cb.sendNotice('Error-No menu items found','','',cb.settings['noticecolor'],'bold'); } } if(cb.settings.notifierSpam=="Yes"){ parseRotating(); sendRotating(); notifierSpam(); } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.